private void btnEditPwd_Click(object sender, EventArgs e) { if (txtPwd1.Text.Trim().ToLower() != txtpwd2.Text.Trim().ToLower()) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "新密码不一致!", txtPwd1, this); txtPwd1.Focus(); return; } if (string.IsNullOrEmpty(txtpwd2.Text.Trim())) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "新密码不能为空", txtpwd2, this); txtOlePwd.Focus(); return; } if (string.IsNullOrEmpty(txtOlePwd.Text.Trim())) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "旧密码不能为空", txtOlePwd, this); txtOlePwd.Focus(); return; } if (LinQBaseDao.Query("select * from UserInfo where userid=" + CommonalityEntity.USERID + "").Tables[0].Rows.Count <= 0) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "登录信息有误,请重新登录!", txtOlePwd, this); GC.Collect(); Application.ExitThread(); Application.Exit(); Process.GetCurrentProcess().Kill(); System.Environment.Exit(System.Environment.ExitCode); Application.ExitThread(); return; } if ((LinQBaseDao.Query("select * from UserInfo where userid=" + CommonalityEntity.USERID + " and UserLoginId='" + CommonalityEntity.USERNAME + "' and UserLoginPwd='" + CommonalityEntity.EncryptDES(txtOlePwd.Text.Trim()) + "'").Tables[0].Rows.Count <= 0)) { mf.ShowToolTip(ToolTipIcon.Info, "提示", "旧密码有误!", txtOlePwd, this); txtOlePwd.Focus(); return; } Action <UserInfo> action = n => { n.UserLoginPwd = CommonalityEntity.EncryptDES(txtpwd2.Text.Trim()); }; Expression <Func <UserInfo, bool> > funuser = n => n.UserId == CommonalityEntity.USERID; if (UserInfoDAL.Update(funuser, action) == true)//角色是否修改失败 { MessageBox.Show("密码修改成功!"); txtOlePwd.Text = ""; txtPwd1.Text = ""; txtpwd2.Text = ""; CommonalityEntity.WriteLogData("修改", "用户" + CommonalityEntity.USERNAME + "修改密码", CommonalityEntity.USERNAME);//添加日志 } }
private void btnAdd_Click() { try { if (cmbUserState.SelectedItem == null) { MessageBox.Show("请选择状态!"); return; } int j = 0; int rint = 0; if (!btnCheck()) { return; } var useradd = new UserInfo { UserLoginId = txtUserLoginID.Text.Trim(), //登陆ID UserLoginPwd = CommonalityEntity.EncryptDES(txtPassword.Text.Trim()), //登陆密码 加密 UserName = txtName.Text.Trim(), //姓名 UserPhone = txtPhone.Text.Trim(), //电话 UserAddress = txtAddress.Text.Trim(), //地址 UserCreateTime = DateTime.Now, //创建时间 UserCreateName = CommonalityEntity.USERNAME, //创建人 UserRemark = txtRemark.Text.Trim(), //备注信息 UserSate = cmbUserState.SelectedItem.ToString(), UserRoleID = Convert.ToInt32(cmbRoleUser.SelectedValue), }; if (UserInfoDAL.InsertOneQCRecord(useradd, out rint)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } string Log_Content = String.Format("用户名称:{0} ", txtUserLoginID.Text.Trim()); CommonalityEntity.WriteLogData("新增", "新增" + Log_Content + "的权限", CommonalityEntity.USERNAME);//添加日志 } catch { CommonalityEntity.WriteTextLog("用户管理 btnAdd_Click()" + "".ToString()); MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { page = new PageControl(); //page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); } }
private void ModifyUser_Click() { try { Expression <Func <UserInfo, bool> > p = n => n.UserLoginId == txtUserLoginID.Text.Trim(); Action <UserInfo> ap = n => { n.UserLoginId = txtUserLoginID.Text.Trim(); //登陆ID n.UserLoginPwd = CommonalityEntity.EncryptDES(txtPassword.Text.Trim()); //登陆密码 n.UserName = txtName.Text.Trim(); //姓名 n.UserPhone = txtPhone.Text.Trim(); //电话 n.UserAddress = txtAddress.Text.Trim(); //地址 n.UserCreateTime = DateTime.Now; //创建时间 n.UserCreateName = CommonalityEntity.USERNAME; //创建人 n.UserRemark = txtRemark.Text.Trim(); //备注信息 n.UserSate = cmbUserState.SelectedItem.ToString(); if (txtUserLoginID.Text.Trim() != "emewe") { n.UserRoleID = Convert.ToInt32(cmbRoleUser.SelectedValue); } }; if (!UserInfoDAL.Update(p, ap))//用户是否修改失败 { MessageBox.Show(" 修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } string Log_Content = String.Format("用户名称:{0} ", txtUserLoginID.Text.Trim()); //common.WriteLogData("修改", Log_Content, common.USERNAME);//添加日志 } catch { CommonalityEntity.WriteTextLog("用户管理 bntUpUser_Click()"); } finally { page = new PageControl(); //page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); ShowAddButton(); } }
/// <summary> /// 车辆管理系统登录的的方法 /// </summary> /// <returns></returns> private bool UserLogin() { bool rbool = false; try { //if (!Find()) //{ // MessageBox.Show("请插入正确的加密锁!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); // return false; //} common.ISService = Internet.PingIpOrDomainName(common.SQLIP); //得到用户名、密码、门岗值 string loginName = txtLoginName.Text.Trim(); string loginPwd = CommonalityEntity.EncryptDES(txtLoginPwd.Text.Trim()); if (string.IsNullOrEmpty(txtLoginName.Text.Trim())) { MessageBox.Show("用户名不能为空", "提示"); txtLoginName.Focus(); return(false); } if (string.IsNullOrEmpty(txtLoginPwd.Text.Trim())) { MessageBox.Show("用户密码不能为空", "提示"); txtLoginPwd.Focus(); return(false); } if (loginName == "不能连接数据库,请检查网络") { MessageBox.Show("请输入用户名", "提示"); txtLoginName.Focus(); return(false); } CommonalityEntity.USERNAME = loginName; if (!common.ISService) { if (MessageBox.Show("无网络是否继续登录!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return(false); } if (mf == null) { mf = new MainForm(); } this.Hide(); this.ShowInTaskbar = false; mf.Show(); rbool = true; txtLoginName.Clear(); txtLoginPwd.Clear(); } else { string str = "select * from UserInfo where UserLoginId='" + loginName + "' and UserLoginPwd='" + loginPwd + "' and UserSate = '启动'"; DataTable dt = LinQBaseDao.Query(str).Tables[0]; if (dt.Rows.Count > 0) { string userid = dt.Rows[0]["UserId"].ToString(); string Name = dt.Rows[0]["UserName"].ToString(); if (!string.IsNullOrEmpty(loginName)) // 登录名 { common.USERNAME = loginName; CommonalityEntity.USERNAME = loginName; } if (!string.IsNullOrEmpty(Name)) // 真实员工姓名 { common.NAME = Name; } string Log_Content = String.Format("用户名:{0}", txtLoginName.Text.Trim()); CommonalityEntity.WriteLogData("用户登录", Log_Content, CommonalityEntity.USERNAME); //添加日志 common.USERID = userid; //用户编号 common.NAME = Name; //真实姓名 common.CurrentGate = SystemClass.PositionName; //当前门岗 common.CurrentGate_ID = SystemClass.PositionID; //门岗编 CommonalityEntity.USERID = Convert.ToInt32(userid); // 用户编号 CommonalityEntity.USERNAME = loginName; //真实姓名 CommonalityEntity.LoginTime = CommonalityEntity.GetServersTime(); string roid = dt.Rows[0]["USERRoleID"].ToString(); if (!string.IsNullOrEmpty(roid)) { CommonalityEntity.USERRoleID = Convert.ToInt32(dt.Rows[0]["USERRoleID"].ToString()); } CommonalityEntity.PositionLED_ID = SystemClass.PositionLED_ID;//LED显示指定门岗 //UserRoleInfo(); // 查出登录用户的权限号 if (mf == null) { mf = new MainForm(); } this.Hide(); this.ShowInTaskbar = false; mf.Show(); // 串口配置 Com串口 if (SystemClass.ISLED == "显示") { if (SystemClass.PositionName == "停车场") { LEDTingForm led = new LEDTingForm(); led.Show(); } else { LEDPreviewForm led = new LEDPreviewForm(); led.Show(); } } rbool = true; txtLoginName.Clear(); txtLoginPwd.Clear(); } else { MessageBox.Show("用户名或密码不可用,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } } catch (Exception ex) { this.Show(); MessageBox.Show("未能加载系统组件,请注册组件" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(rbool); }