/// <summary> /// 用户名失去焦点时判断用户是否存在, /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbUid_Leave(object sender, EventArgs e) { if (cbUid.Text.Length > 0) { SYS_USER_BLL bll = new SYS_USER_BLL(); SYS_USER model = bll.CheckUid(cbUid.Text); if (model.USER_NAME == null) { txtRealName.Text = "用户不存在"; } else { txtRealName.Text = model.USER_NAME;//用户名存在时显示真实姓名 } } }
/// <summary> /// 登陆验证 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnLogin_Click(object sender, EventArgs e) { SYS_USER_BLL bll = new SYS_USER_BLL(); if (bll.LoginCheck(cbUid.Text, mtxtbox.Text)) { this.DialogResult = DialogResult.OK;//设置登陆窗体返回值为ok并关闭本窗体 SYS_USER USER = bll.CheckUid(cbUid.Text); if (USER != null)//如用户登陆成功存入全局变量 { GlobalHelper.CurrenLoginUser = USER; //用户登陆成功将用户名保存入配置文件 SaveCofing(USER.USER_CODE); } } else { MessageBox.Show("用户名或密码不对!"); } }