/// <summary> /// 登录方法 /// </summary> private void Login() { //非空验证 if (string.IsNullOrEmpty(this.txt_username.Text.Trim())) { tp_msg.Show("请输入用户名!", txt_username, 1000); txt_username.Focus(); return; } if (string.IsNullOrEmpty(this.txt_password.Text)) { tp_msg.Show("请输入密码!", this.txt_password, 1000); txt_password.Focus(); return; } //登陆 try { admin.ygxh = txt_username.Text; admin.ygmm = txt_password.Text; Pass.password = txt_password.Text; object flag = Bll_Admin.CheckIdPwd(admin); if (flag.ToString() == "1") { LoginInfo.ygxh = admin.ygxh; LoginInfo.ygmm = admin.ygmm; FrmMain main = new FrmMain(); main.Show(); this.Hide(); } else { MessageBoxEx.Show("用户名或密码错误", "提示", MessageBoxButtons.OK); txt_password.Text = ""; txt_password.Focus(); } } catch (MySqlException ex) { MessageBoxEx.Show("数据库异常:" + ex.Message); } catch (Exception ex) { MessageBoxEx.Show("其它异常:" + ex.Message); } }
/// <summary> /// 初始化用户列表 /// </summary> private void InitTreeView() { this.tv_yhlb.Nodes.Clear(); TreeNode root = new TreeNode("全部"); root.Tag = 0; lst_admin = Bll_Admin.GetAllUser(); foreach (Admin admin in lst_admin) { TreeNode node = new TreeNode(); node.Text = admin.ygxh; node.Tag = admin.ygmm; root.Nodes.Add(node); } this.tv_yhlb.Nodes.Add(root); this.tv_yhlb.ExpandAll(); }
protected void Button1_Click(object sender, EventArgs e) { if (TextBox3.Text.Equals(Session["Code"].ToString(), StringComparison.OrdinalIgnoreCase)) { if (Bll_Admin.Login(new Model.Admin() { AName = TextBox1.Text, APassword = TextBox2.Text }) > 0) { Session["AName"] = TextBox1.Text; Response.Redirect("Main.aspx"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('管理员信息填写有误')</script>"); } } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('验证码错误')</script>"); TextBox3.Text = ""; } }