private void LoadTree() { this.advTree1.Nodes.Clear(); _userid = this.textBox1.Text.Trim(); if (string.IsNullOrEmpty(_userid)) { MsgBox.Warning("请输入用户编号..."); _userid = string.Empty; return; } //验证用户是否存在 try { var _mlist = _CoreUser_MST.LoadEntities(t => t.User_Id == _userid && t.User_Status == 1).ToList(); if (_mlist.Count <= 0) { MsgBox.Warning("用户不存在..."); _userid = string.Empty; return; } _LoadTree.CreateRightTree(this.advTree1, _userid); } catch (Exception ex) { _userid = string.Empty; MsgBox.Warning("加载权限出错:" + ex.Message); } }
/// <summary> /// 验证用户 如果正确就直接登录,并更新登录时间 登录IP /// </summary> /// <returns></returns> private User_MST CheckUserIdPWD() { string _UserId = this.textBox1.Text.Trim(); string _PassWord = SecurityUnitity.GetMD5_32(this.textBox2.Text.Trim()); var _list = _CoreUser_MST.LoadEntities(t => t.User_Id == _UserId && t.User_Pwd == _PassWord).ToList(); if (_list.Count == 1) { DateTime _now = new CoreGetTime().GetNow(); _list[0].User_LogTime = _now; _list[0].User_LogIp = NetUnitity.GetLannIP(); int retVal = _CoreUser_MST.UpdateEntityBySomeColums(_list[0], t => new { t.User_LogIp, t.User_LogTime }); return(_list[0]); } else { return(null); } }
private void textBox1_Leave(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text.Trim())) { return; } Task.Factory.StartNew(new Action(() => { try { if (this.textBox1 == null) { return; } string _UserId = this.textBox1.Text.Trim(); CoreUser_MST thread_CoreUser_MST = new CoreUser_MST(); var _list = thread_CoreUser_MST.LoadEntities(t => t.User_Id == _UserId).ToList(); if (_list.Count <= 0) { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.label3.Visible = true; })); } } else { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.label3.Visible = false; })); } } } catch //(Exception) { } })); }
/// <summary> /// 验证 UserId是否可用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBox1_Leave(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text.Trim())) { return; } Task.Factory.StartNew(new Action(() => { try { if (this.textBox1 == null) { return; } string _UserId = this.textBox1.Text.Trim(); CoreUser_MST thread_CoreUser_MST = new CoreUser_MST(); var _mlist = thread_CoreUser_MST.LoadEntities(t => t.User_Id == _UserId).ToList(); if (_mlist.Count <= 0) { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.label6.Text = "用户Id已存在,推荐使用"; this.label6.Visible = false; })); } return;//如果不存在编号 就不是有推荐的 } DataTable _datatable = thread_CoreUser_MST.LoadEntitiesBySql("select user_id*1 as user_id from User_MST order by user_id desc limit 0,1 ;", new List <SqlSugar.SugarParameter>()); if (_datatable.Rows.Count > 0)//用户ID已经存在 { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.label6.Text = "用户Id已存在,推荐使用" + (Convert.ToInt64(_datatable.Rows[0][0]) + 1); this.label6.Visible = true; this.textBox1.Text = (Convert.ToInt64(_datatable.Rows[0][0]) + 1).ToString(); })); } } else { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.label6.Text = "用户Id已存在,推荐使用"; this.label6.Visible = false; })); } } } catch //(Exception) { } })); }