public JsonResult SaveUser(string entity) { JavaScriptSerializer serializer = new JavaScriptSerializer(); M_Users model = serializer.Deserialize <M_Users>(entity); string mes = "执行成功"; JsonDictionary.Add("errmeg", "执行成功"); if (model.Uid < 1) { if (M_UsersBusiness.GetM_UserCountByLoginName(model.UserName) == 0) { model.Salt = OWZXTool.Encrypt.CreateRandomValue(6, true); model.Password = OWZXTool.Encrypt.MD5(model.Salt); model.IsAdmin = 0; model.AdminGid = 2; model.IsFreeZe = 0; model.Uid = M_UsersBusiness.CreateM_User(model); } else { JsonDictionary["errmeg"] = "登录名已存在,操作失败"; } } else { bool bl = M_UsersBusiness.UpdateM_User(model); M_UsersBusiness.UpdatePartUser(model); if (!bl) { model.Uid = 0; } } if (model.Uid < 1) { JsonDictionary["errmeg"] = "操作失败"; } JsonDictionary.Add("model", model); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult SaveUser(string entity) { JavaScriptSerializer serializer = new JavaScriptSerializer(); M_Users model = serializer.Deserialize <M_Users>(entity); JsonDictionary.Add("errmeg", "执行成功"); if (string.IsNullOrEmpty(model.UserID)) { if (M_UsersBusiness.GetM_UserCountByLoginName(model.LoginName) == 0) { model.CreateUserID = CurrentUser.UserID; model.Avatar = ""; model.IsAdmin = 0; model.SourceType = 1; model.UserID = M_UsersBusiness.CreateM_User(model); } else { JsonDictionary["errmeg"] = "登录名已存在,操作失败"; } } else { bool bl = M_UsersBusiness.UpdateM_User(model.UserID, model.Name, model.RoleID, model.Email, model.MobilePhone, model.OfficePhone, model.Jobs, model.Description); if (!bl) { model.UserID = ""; } } if (string.IsNullOrEmpty(model.UserID)) { JsonDictionary["errmeg"] = "操作失败"; } JsonDictionary.Add("model", model); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult UserAvatarUpload(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file) { string pic = "", error = ""; if (file != null) { if (ValidateImg(name)) { try { pic = SaveImg(file, name, "UserAvatar/"); if (M_UsersBusiness.UpdateM_User(CurrentUser.UserID, pic)) { CurrentUser.Avatar = pic; Session["Manage"] = CurrentUser; } } catch (Exception ex) { error = ex.Message; } } else { error = "图片格式不正确"; } } else { error = "暂未获取到图片信息"; } JsonDictionary.Add("msgError", error); JsonDictionary.Add("imgUrl", pic); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }