• 疯狂猜成语测试版


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

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

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

       }    

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

  • 相关阅读:
    HTTP POST GET 本质区别详解
    本人完成的代码生成器,请多提些建议
    .net实现控件视图状态ViewState
    专门用于微信公众平台的Javascript API导言
    [学习笔记]验证上传文件后缀名类型
    专门用于微信公众平台的Javascript API
    1个月成为HTML5前端工程师
    js中用正则表达式 过滤特殊字符, 校验所有输入域是否含有特殊符号
    SharePoint 2010 根据不同的用户权限显示不同的导航
    (原创)Sharepoint webpart中调用web service报错
  • 原文地址:https://www.cnblogs.com/moshang-zjn/p/3715205.html
Copyright © 2020-2023  润新知