• 疯狂猜成语测试版


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

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

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

       }    

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

  • 相关阅读:
    Caffe2(1)----Ubantu14.04安装
    ROS知识(16)----如何编译时自动链接同一个工作空间的其他包的头文件(包含message,srv,action自动生成的头文件)
    GIT(4)----免输入账号和密码方法
    faceNet编译问题
    Python知识(7)--最小二乘求解
    BeanShell用法汇总(部分摘抄至网络)
    web_custom_request和web_submit_data
    创建一个数组,然后随机输出一个数组的值
    lr常见问题
    通过ctrl+r快速启动程序
  • 原文地址:https://www.cnblogs.com/moshang-zjn/p/3715205.html
Copyright © 2020-2023  润新知