private void btnOK_Click(object sender, EventArgs e) { //1.验证旧密码是否正确,重新登录一次 //登录判断 if (_employeeBLL.Login(CardNo, txtOldPwd.Text)) { //2.继续改密码 if (txtNewPwd.Text.Length >= 3 && txtNewPwd.Text == txtConfirmPwd.Text) { //3.修改密码 Employee = _employeeBLL.GetByCardNo(CardNo); Employee.PassWord = new Encrypt().SHA1(txtNewPwd.Text); if (_employeeBLL.Edit(Employee)) { MessageBox.Show("密码修改成功!"); txtConfirmPwd.Text = txtNewPwd.Text = txtOldPwd.Text = string.Empty; txtOldPwd.Focus(); } } else { lblMsg.Text = "密码格式不正确,不能小于3位!"; txtOldPwd.Focus(); } } else { lblMsg.Text = "旧密码不正确!"; txtOldPwd.Focus(); } }
private void btnOK_Click(object sender, EventArgs e) { int result1 = ComputeAuthority(c1); int result2 = ComputeAuthority(c2); int result3 = ComputeAuthority(c3); if (_employee == null) { MessageBox.Show("请先选择一各员工!"); return; } else { //保存到数据库 _employee.BaseFunction = result1; _employee.PurchaseFunction = result2; _employee.EmployeeFunction = result3; if (_employeeBLL.Edit(_employee)) { MessageBox.Show("权限修改成功!"); } else { MessageBox.Show("权限修改失败,请重试!"); } } }
/// <summary> /// 编辑 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result BaseEdit([FromBody] Employee entity) { IBLL.IEmployeeBLL m_BLL = new EmployeeBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); #region 验证 if (entity.CertificateType == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择证件类型"; return(result); //提示输入的数据的格式不对 } if (entity.Sex == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择性别"; return(result); //提示输入的数据的格式不对 } if (entity.AccountType == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择户口类型"; return(result); //提示输入的数据的格式不对 } if (entity.CertificateType == "居民身份证") { string number = entity.CertificateNumber; if (Common.CardCommon.CheckCardID18(number) == false) { result.Code = Common.ClientCode.FindNull; result.Message = "证件号不正确请重新输入"; return(result); //提示输入的数据的格式不对 } } #endregion //数据校验 if (entity != null && ModelState.IsValid) { Employee item = m_BLL.GetById(entity.Id); item.Name = entity.Name; item.CertificateNumber = entity.CertificateNumber; item.CertificateType = entity.CertificateType; item.Sex = entity.Sex; item.AccountType = entity.AccountType; item.UpdateTime = DateTime.Now; item.UpdatePerson = LoginInfo.RealName; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",员工信息的Id为" + entity.Id, "员工" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",员工信息的Id为" + entity.Id + "," + returnValue, "员工" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
private void btnSave_Click(object sender, EventArgs e) { string ppEmployeeId = ""; try { Entities.Employees1 emp = new Entities.Employees1(); emp = SetEmployee(); if (string.IsNullOrEmpty(emp.EmployeeCode)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM94"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } if (!Common.Validation.ValidateNumber(emp.EmployeeCode)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM519"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } if (string.IsNullOrEmpty(emp.EmployeeName)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM312"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } //if (!Common.Validation.ValidateBirthDate(emp.BirthDate)) //{ // CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM310"), // Common.clsLanguages.GetResource("CRM11"), // Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, // Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); // return; //} if (!string.IsNullOrEmpty(emp.Email)) { if (!Common.Validation.ValidateEmail(emp.Email)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM311"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } } if (!string.IsNullOrEmpty(emp.PhoneNumber)) { if (!Common.Validation.ValidatePhoneNumber(emp.PhoneNumber)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM47"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } } if (cbBCountry.SelectedIndex == 0) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM373"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } if (cbBEmployeeType.SelectedIndex == 0) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM514"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } if (pStatusAdd) { //Linh 29-12-2014 if (txtUserName.Text != "" && txtPassword.Text != "") { if (txtConfirm.Text == String.Empty) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM646"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } else { if (string.Compare(txtPassword.Text, txtConfirm.Text) != 0) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM647"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } } } if (employeeBLL.CheckEmployeeIsExist(emp.EmployeeCode, null)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM513"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } ppEmployeeId = employeeBLL.AddReturnId(emp); } else { if (employeeBLL.CheckEmployeeIsExist(emp.EmployeeCode, emp.EmployeeId)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM513"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } //Check mã đã tồn tại chưa DialogResult r = CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM227"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO); if (r == DialogResult.Yes) { employeeBLL.Edit(emp); this.Close(); } } if (!string.IsNullOrEmpty(employeeBLL.ErrorString)) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM219"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); return; } if (!string.IsNullOrEmpty(imagePath)) { employeeBLL.SaveImage(emp, imagePath); } if (!string.IsNullOrEmpty(employeeBLL.ErrorString)) { MessageBox.Show(employeeBLL.ErrorString, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.IsNullOrEmpty(imagePath)) { emp.Image = Image.FromFile(imagePath); } else { emp.Image = employee.Image; } #region Phân quyền DataTable roleTable = new DataTable(); roleTable.Columns.Add("EmployeeId", typeof(String)); roleTable.Columns.Add("RoleId", typeof(String)); if (pStatusAdd) { if (rdManager.Checked == true)//if (chkBManager.Checked == true) { DataRow row = roleTable.NewRow(); row["EmployeeId"] = ppEmployeeId; //for insert and update row["RoleId"] = "admin"; roleTable.Rows.Add(row); } if (rdEmployee.Checked == true)// if (chkBReception.Checked == true) { DataRow row = roleTable.NewRow(); row["EmployeeId"] = ppEmployeeId; //for insert and update row["RoleId"] = "letan"; roleTable.Rows.Add(row); } //if (chkBTablet.Checked == true) //{ // DataRow row = roleTable.NewRow(); // row["EmployeeId"] = ppEmployeeId; //for insert and update // row["RoleId"] = "tablet"; // roleTable.Rows.Add(row); //} roleBLL.UpdateRoleByUserId(ppEmployeeId, roleTable); } else { if (rdManager.Checked == true) //if (chkBManager.Checked == true) { DataRow row = roleTable.NewRow(); row["EmployeeId"] = emp.EmployeeId; row["RoleId"] = "admin"; roleTable.Rows.Add(row); } if (rdEmployee.Checked == true) //if (chkBReception.Checked == true) { DataRow row = roleTable.NewRow(); row["EmployeeId"] = emp.EmployeeId; row["RoleId"] = "letan"; roleTable.Rows.Add(row); } //if (chkBTablet.Checked == true) //{ // DataRow row = roleTable.NewRow(); // row["EmployeeId"] = emp.EmployeeId; // row["RoleId"] = "tablet"; // roleTable.Rows.Add(row); //} roleBLL.UpdateRoleByUserId(emp.EmployeeId, roleTable); } #endregion if (pStatusAdd) { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM308"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); this.Close(); //btnAdd_Click(sender, e); } else { employee = emp; IsBeginLoad(false); Display(this.employee); } } catch (Exception) { string code = System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(); if (code == "-532462766") { CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CRM292"), Common.clsLanguages.GetResource("CRM11"), Common.Config.CUSTOM_MESSAGEBOX_ICON.Information, Common.Config.CUSTOM_MESSAGEBOX_BUTTON.OK); } return; } }