public ActionResult btnEdit_Click([Bind(Include = "ID,FCompanyNumber,UserName,UserPwd,UserSex,UserBirthday,UserMail,UserEnabledisable,UserRemark,UserPumpGroup,FCustomerID,UserType,IsOther")] Panda_Customer cus) { try { if (ModelState.IsValid) { if (Panda_UserInfoDal.Exist(" and UserName='******' and UserName<>'" + Request["tbxOldName"] + "'").Rows.Count == 0) { Hashtable hasData = new Hashtable(); hasData["ID"] = Request["tbxID"]; hasData["FCompanyNumber"] = Request["ddlCompany"]; hasData["UserName"] = Request["tbxName"]; if (!Request["tbxPassword"].Equals(Request["tbxoldPwd"])) { hasData["UserPwd"] = PasswordUtil.CreateDbPassword(Request["tbxPassword"]); } hasData["UserSex"] = Request["ddlSex"]; hasData["UserBirthday"] = Request["dpBirthday"]; //hasData["UserTel"] = Request["ddlCompany"]; hasData["UserMail"] = Request["tbxEmail"]; hasData["UserEnabledisable"] = Request["ddlEnable"]; hasData["UserRemark"] = Request["tbxRemark"]; hasData["UserPumpGroup"] = Request["tbxPumpGroupID"]; hasData["FCustomerID"] = Request["tbxCustomerID"]; hasData["UserType"] = Request["ddlType"]; hasData["IsOther"] = Request["ddlType"] == "4" ? "1" : "0"; hasData["FUpdUser"] = GetIdentityName(); hasData["FUpdDate"] = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssss")); Panda_UserInfoDal.Update(hasData); ShowNotify("修改成功!"); // 关闭本窗体(触发窗体的关闭事件) PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { ShowNotify("用户名重复,请更换!"); } } } catch { ShowNotify("修改失败!"); } return(UIHelper.Result()); }
public ActionResult btnSave_OnClick() { // 检查当前密码是否正确 string oldPass = Request["tbxOldPassword"]; string newPass = Request["tbxNewPassword"]; string confirmNewPass = Request["tbxConfirmNewPassword"]; if (newPass != confirmNewPass) { UIHelper.TextBox("tbxConfirmNewPassword").MarkInvalid("确认密码和新密码不一致!"); } if (!PasswordUtil.ComparePasswords(Panda_UserInfoDal.Get(GetIdentityName())["UserPwd"].ToString(), oldPass)) { UIHelper.TextBox("tbxOldPassword").MarkInvalid("当前密码不正确!"); } try { //string userGH = GetIdentityName(); //User users = db.users.Where(x => x.Name.Equals(userGH)).FirstOrDefault(); //users.Password = PasswordUtil.CreateDbPassword(newPass); //db.SaveChanges(); Hashtable hasData = new Hashtable(); hasData["ID"] = GetIdentityName(); hasData["UserPwd"] = PasswordUtil.CreateDbPassword(newPass); Panda_UserInfoDal.Update(hasData); ShowNotify("修改密码成功!"); } catch { ShowNotify("修改密码失败,请重新操作!"); } return(UIHelper.Result()); }