form1.cs

来自「这是一个银行储蓄系统的源代码及数据库文件」· CS 代码 · 共 69 行

CS
69
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Store
{
    public partial class form1 : Form
    {
        public form1()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=银行储蓄系统;Integrated Security=SSPI");
            if ((textBox1.Text != "") && (textBox2.Text != ""))
            {
                try
                {
                    connection.Open();
                    string strSQL = "select * from 业务员信息 where 业务员编号='" + textBox1.Text.ToString() + "'and 密码='" + textBox2.Text.ToString() + "'";
                    SqlCommand cmd = new SqlCommand(strSQL, connection);
                    SqlDataReader dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        //this.Close();
                        Form3 form = new Form3();
                        form.Show();
                    }
                    else
                    {
                        MessageBox.Show("用户名或口令有错,请重新输入!");
                    }
                }
                catch (SqlException b)
                {
                    Console.WriteLine(b.Message);
                }
                finally
                {
                    connection.Close();
                }
            }
            else
            {
                MessageBox.Show("请输入完整的正确信息!");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Enter)
            {
                this.button3_Click(button3, new EventArgs());
            }
        }
       
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?