From 05a9bcd866ab49841e400c9b607cf5afd2a96045 Mon Sep 17 00:00:00 2001 From: aufe20200933 Date: Tue, 22 Nov 2022 09:37:23 +0800 Subject: [PATCH] =?UTF-8?q?Delete=20'=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 用户登录实现 | 51 ---------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 用户登录实现 diff --git a/用户登录实现 b/用户登录实现 deleted file mode 100644 index f06cc1c..0000000 --- a/用户登录实现 +++ /dev/null @@ -1,51 +0,0 @@ -// 用户登录代码实现:主要通过sql语句调用DataAccess类中的GetDataSetBySql()方法来实现的 -namespace L019_BookMange -{ - public partial class frmLogin : Form - { - public frmLogin() - { - InitializeComponent(); - } - private void btnLogin_Click(object sender, EventArgs e) - { - //输入账号密码正确 - if (Validate()) - { - string state = this.cboUserType.Text; - int num; - if (state.Equals("管理员"))//判断用户角色,若为管理员 - num = 2; - else //若为读者 - num = 1; - //定义查询语句 - string sql = string.Format("select * from userinfo where uname='{0}'and upwd='{1}'and ustate={2}", this.txtName.Text.Trim(), this.txtPwd.Text.Trim(), num); - DataSet ds = DataAccess.GetDataSetBySql(sql); //操作数据库 - if (ds.Tables[0].Rows.Count > 0) - { - MessageBox.Show("登录成功"); - FrmMain.result = DialogResult.OK;//为变量result赋值 - this.Close(); - } - else - MessageBox.Show("用户名或密码错误,请重新输入"); - } - } - private void frmLogin_Load(object sender, EventArgs e) - { - this.cboUserType.SelectedIndex = 0; - } - private bool Validate() //检测用户名和密码是否为空 - { - if (this.txtName.Text != string.Empty && this.txtPwd.Text != string.Empty) - return true; - else - MessageBox.Show("用户名或密码不能为空"); //返回错误提示信息 - return false; - } - private void btnCancle_Click(object sender, EventArgs e) - { - this.Close(); - } - } -} \ No newline at end of file