private void btnLogin_Click(object sender, EventArgs e) { //非空验证 if (txtUserName.Text == "") { HintMessageBox.Warning_hint("请输入账户姓名!!"); return; } else if (txtPwd.Text == "") { HintMessageBox.Warning_hint("请输入账户密码!!"); return; } //sql语句 string sql = string.Format("select COUNT(*) from admin_info where admin_name = '{0}' and admin_pwd = '{1}'", txtUserName.Text.Trim(), txtPwd.Text.Trim()); if (db.ExecuteScalar(sql) == null) { return; } if ((int)db.ExecuteScalar(sql) > 0) { HintMessageBox.Information_hint("登录成功!!"); FrmAdmin admin = new FrmAdmin(); admin.Show(); //显示后台管理主窗体 this.Hide(); //隐藏登录窗体 } else { HintMessageBox.Information_hint("用户名或密码错误!!"); } }
//登录 private void btnLogin_Click(object sender, EventArgs e) { if (ValidateInput()) { string message = ""; //调用方法,判断用户是否存在 bool userExist = ValidateUser(this.txtUserName.Text.Trim(), this.txtPwd.Text.Trim(), ref message); if (userExist) { FrmAdmin adminForm = new FrmAdmin(); adminForm.Show(); this.Hide(); } else { MessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }