scholastic/Form1_1.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace scholastic
{
    public partial class Form1_1 : Form
    {
        public Form1_1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("输入登录信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);   //提示对话框
            }
            else
            {
                string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";   //连接数据库
                SqlConnection mycon = new SqlConnection(constr);
                mycon.Open();
                string mysql = "select * from users where 用户名='" + textBox1.Text + "'and 密码='" + textBox2.Text + "'";    //Sql查询语句
                SqlDataAdapter myada = new SqlDataAdapter(mysql, mycon);
                DataTable mydt = new DataTable();    //创建DataTable对象实例
                myada.Fill(mydt);            //调用Fill方法填充表
                int i = mydt.Rows.Count;          //利用变量i统计当前记录的个数
                if (i >= 1)
                {
                    mianForm myf = new mianForm();
                    myf.Show();
                    myf.label1.Text = "欢迎" + textBox1.Text + "登陆主界面,其登录密码是: " + textBox2.Text;
                }
                else
                {
                    MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = "";   //清空文本框
            this.textBox2.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

后面还有 13 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。