private void FrmSelectedUser_Load(object sender, EventArgs e) { CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_USER_INFO userBll = new Maticsoft.BLL.SMT_USER_INFO(); var models = userBll.GetModelList("IS_DELETE!=1"); this.Invoke(new Action(() => { foreach (var item in models) { Node node = new Node(item.USER_NAME + "[" + item.REAL_NAME + "]"); node.Tag = item; advTree.Nodes[0].Nodes.Add(node); if (_selectUserIds.Contains(item.ID)) { node.Checked = true; } } advTree.Nodes[0].ExpandAll(); })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "加载用户异常!" + ex.Message); } }); waiting.Show(this); }
//执行登陆 private void DoLogin() { Maticsoft.DBUtility.DbHelperSQL.connectionString = SysConfig.GetSqlServerConnectString(); if (tbUserName.Text.Trim() == "") { MessageBox.Show("用户名不能为空!"); tbUserName.Focus(); return; } if (tbPwd.Text == "") { MessageBox.Show("密码不能为空!"); tbPwd.Focus(); return; } SunCreate.Common.ConfigHelper.SetConfigValue("RememberUser", cbRememberUser.Checked.ToString()); string user = tbUserName.Text.Trim(); if (cbRememberUser.Checked) { SunCreate.Common.ConfigHelper.SetConfigValue("LastLoginUser", user); } else { SunCreate.Common.ConfigHelper.SetConfigValue("LastLoginUser", ""); } SunCreate.Common.ConfigHelper.SetConfigValue("RememberPwd", cbRememberPwd.Checked.ToString()); if (cbRememberPwd.Checked) { string p = EncryptUtils.DESEncrypt(tbPwd.Text, "yjdd@@!!", "djifd##c"); SunCreate.Common.ConfigHelper.SetConfigValue("LastLoginPwd", p); } else { SunCreate.Common.ConfigHelper.SetConfigValue("LastLoginPwd", ""); } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_USER_INFO userbll = new Maticsoft.BLL.SMT_USER_INFO(); var users = userbll.GetModelList("USER_NAME='" + tbUserName.Text.Trim() + "' and IS_ENABLE=1 and IS_DELETE=0 and PASS_WORD= substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','" + tbPwd.Text + "')),3,32)"); if (users.Count > 0) { UserInfoHelper.UserInfo = users[0]; UserInfoHelper.OldPwd = tbPwd.Text; PrivateMgr.LoadPrivates(); } this.Invoke(new Action(() => { if (users.Count > 0) { DoEnter(); } else { MessageBox.Show("输入用户信息错误!"); } })); } catch (System.Exception ex) { this.Invoke(new Action(() => { MessageBox.Show("登陆失败:" + ex.Message); })); } }); waiting.Show(this); }