public IActionResult ChangePwd(string oldpwd, string newpwd, string newlypwd) { if (string.IsNullOrEmpty(oldpwd)) { throw new MessageBox("旧密码不能为空"); } if (string.IsNullOrEmpty(newpwd)) { throw new MessageBox("新密码不能为空"); } if (string.IsNullOrEmpty(newlypwd)) { throw new MessageBox("确认新密码不能为空"); } if (!newpwd.Equals(newlypwd)) { throw new MessageBox("两次密码不一致"); } _Sys_UserM = db.Find <Sys_UserM>(w => w.User_ID == Account.UserID); if (!_Sys_UserM.User_Pwd.Equals(oldpwd.Trim()))//Tools.MD5Encrypt(oldpwd.Trim()))) { throw new MessageBox("旧密码不正确"); } if (!db.Edit <Sys_UserM>(() => new Sys_UserM() { User_Pwd = newlypwd.Trim() }, w => w.User_ID == Account.UserID, li)) { throw new MessageBox(db.ErrorMessge); } if (!db.Commit(li)) { throw new MessageBox(db.ErrorMessge); } return(Json(new { status = 1 })); }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Save(Sys_UserM model, string Role_ID) { if (model.User_ID.ToGuid().Equals(Guid.Empty)) { if (string.IsNullOrEmpty(model.User_Pwd)) { model.User_Pwd = "123"; //Tools.MD5Encrypt("123456"); } else { model.User_Pwd = model.User_Pwd;//Tools.MD5Encrypt(model.cUsers_LoginPwd); } model.User_ID = db.Add(model, li).ToGuid(); if (model.User_ID.ToGuid().Equals(Guid.Empty)) { throw new MessageBox(db.ErrorMessge); } //用户角色 userroleM.UserRole_UserID = model.User_ID; userroleM.UserRole_RoleID = Role_ID.ToGuid(); if (db.Add(userroleM, li).ToGuid().Equals(Guid.Empty)) { throw new MessageBox(db.ErrorMessge); } } else { //如果 密码字段为空,则不修改该密码 if (string.IsNullOrEmpty(model.User_Pwd)) { db.EditById <Sys_UserM>(() => new Sys_UserM { User_ID = model.User_ID, User_Email = model.User_Email, User_IsDelete = model.User_IsDelete, User_LoginName = model.User_LoginName, User_Name = model.User_Name }); } else { if (!db.EditById <Sys_UserM>(model, li)) { throw new MessageBox(db.ErrorMessge); } } //用户角色 if (!db.Delete <Sys_UserRoleM>(w => w.UserRole_UserID == model.User_ID, li)) { throw new MessageBox(db.ErrorMessge); } if (db.Add <Sys_UserRoleM>(new Sys_UserRoleM() { UserRole_UserID = model.User_ID, UserRole_RoleID = Role_ID.ToGuid() }, li).ToGuid().Equals(Guid.Empty)) { throw new MessageBox(db.ErrorMessge); } } if (!db.Commit(li)) { throw new MessageBox(db.ErrorMessge); } return(model.User_ID.ToGuidStr()); }
public override IActionResult Index() { _Sys_UserM = db.Find <Sys_UserM>(w => w.User_ID == Account.UserID); ViewData["userName"] = _Sys_UserM.User_Name; return(View()); }
public IActionResult Save(Sys_UserM model, string Role_ID) { this.KeyID = _Sys_UserBL.Save(model, Role_ID); return(Json(new { status = 1, ID = KeyID })); }