疯狂猜成语测试版

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

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

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();        

     }    

   }

}

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

       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();        

   }    

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

转载于:https://www.cnblogs.com/moshang-zjn/p/3715205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值