码迷,mamicode.com
首页 > 其他好文 > 详细

疯狂猜成语测试版

时间:2014-05-08 07:32:09      阅读:447      评论:0      收藏:0      [点我收藏+]

标签:blog   class   tar   ext   int   http   

首先展示是我们的首界面。

bubuko.com,布布扣

下面展示的是初级的代码及界面。

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data; using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace 疯狂猜成语2

{    

  public partial class Form1 : Form    

  {        

    static int i = 0;        

     int N = 0;        

    public Form1()        

    {             InitializeComponent();         }

         private void Form1_Load(object sender, EventArgs e)        

    {            

      DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from first");               label1.Text = t.Rows[0]["meaning"].ToString();               

      N = t.Rows.Count;        

    }

          private void btn_submit_Click(object sender, EventArgs e)        

    {            

       string s = textBox1.Text.Trim() + textBox2.Text.Trim() + textBox3.Text.Trim() + textBox4.Text.Trim();            

      if (s == "")            

       {                 MessageBox.Show("不能为空");             }            

      else            

      {                

        DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from first");              

        string ss = t.Rows[i][1].ToString();                

        if (ss == s)                

        {                    

          MessageBox.Show("恭喜答对");                    

          i++;                    

          if (i < N)                    

          {                         label1.Text = t.Rows[i]["meaning"].ToString();                     }                    

          else                    

          {                         MessageBox.Show("恭喜通关");                         this.Close();                     }                

        }                

        else                

        {                     MessageBox.Show("好遗憾");                 }                

        textBox1.Text = "";                 textBox2.Text = "";                 textBox3.Text = "";                 textBox4.Text = "";            

      }        

     }

          private void btn_next_Click(object sender, EventArgs e)        

    {            

      i++;            

      if (i < N)            

      {                 DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from first");                

      label1.Text = t.Rows[i]["meaning"].ToString();            

      }            

      else            

      {                

        MessageBox.Show("恭喜通关");                

        this.Close();            

      }            

      textBox1.Text = "";             textBox2.Text = "";             textBox3.Text = "";             textBox4.Text = "";        

    }

          private void btn_prompt_Click(object sender, EventArgs e)        

     {            

        DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from first");                 textBox1.Text = t.Rows[i]["firstname"].ToString();        

     }    

   }

}

bubuko.com,布布扣

下面展示的是中级的代码及界面。

       private void Form3_Load(object sender, EventArgs e)        

  {            

    DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from second");            

    N = t.Rows.Count;            

    if (File.Exists("pic\\" + t.Rows[i]["pic"].ToString()))            

    {                

      pictureBox1.Image = Image.FromFile("pic\\" + Convert.ToString(t.Rows[i][4]));            

    }        

  }

        private void btn_submit_Click(object sender, EventArgs e)        

  {            

    string s = textBox1.Text.Trim() + textBox2.Text.Trim() + textBox3.Text.Trim() + textBox4.Text.Trim();            

    if (s == "")            

    {                 MessageBox.Show("不能为空");             }            

    else            

    {                

      DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from second");                  string ss = t.Rows[i][1].ToString();                

      if (ss == s)                

      {                    

        MessageBox.Show("恭喜答对");                    

        i++;                    

        if (i < N)                    

        {                        

        if (File.Exists("pic\\" + t.Rows[i]["pic"].ToString()))                        

        {                            

          pictureBox1.Image = Image.FromFile("pic\\" + Convert.ToString(t.Rows[i][4]));                        

        }                    

      }                    

      else                    

      {                        

        MessageBox.Show("恭喜通关");                        

        this.Close();                    

      }                

    }                

    else                

    {                    

      MessageBox.Show("好遗憾");                

    }                

    textBox1.Text = "";                 textBox2.Text = "";                 textBox3.Text = "";                 textBox4.Text = "";            

    }        

  }

        private void btn_next_Click(object sender, EventArgs e)        

   {            

      i++;            

      if (i < N)            

      {               

          DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from second");              

            if (File.Exists("pic\\" + t.Rows[i]["pic"].ToString()))                

          {                    

            pictureBox1.Image = Image.FromFile("pic\\" + Convert.ToString(t.Rows[i][4]));                

          }            

       }            

       else            

      {                

          MessageBox.Show("恭喜通关");                

          this.Close();            

      }            

      textBox1.Text = "";             textBox2.Text = "";             textBox3.Text = "";             textBox4.Text = "";             label1.Text = "";        

    }

        private void btn_prompt_Click(object sender, EventArgs e)        

   {            

      label1.Visible = Enabled;            

      DataTable t = SqlHelper.ExecuteDataTable("server=.;uid=sa;pwd=sa;database=a;", CommandType.Text, "select * from second");               label1.Text = t.Rows[i]["meaning"].ToString();        

   }    

bubuko.com,布布扣

同理,高级的设计方式跟前面基本相同。但由于高级的代码相对前面来说较多,再此就不一一展示了。仅展示下界面。

bubuko.com,布布扣

疯狂猜成语测试版,布布扣,bubuko.com

疯狂猜成语测试版

标签:blog   class   tar   ext   int   http   

原文地址:http://www.cnblogs.com/moshang-zjn/p/3715205.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!