public JsonResult UserRegister(string loginname, string pwd) { var result = !string.IsNullOrEmpty(PCDDBusiness.M_UsersBusiness.CreateM_UserBase(loginname, pwd)); if (result) { var outresult = 0; PCDDEntity.Manage.M_Users model = PCDDBusiness.M_UsersBusiness.GetM_UserByProUserName(loginname, pwd, OperateIP, out outresult); if (model != null) { Session["PartManage"] = model; } else { result = false; } } JsonDictionary.Add("result", result); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult UserRegister2(string entity) { M_Users users = JsonConvert.DeserializeObject <M_Users>(entity); users.OfficePhone = ""; users.Avatar = ""; users.CreateUserID = ""; users.IsAdmin = 0; users.RoleID = ""; users.Description = ""; users.UserID = ((M_Users)Session["PartManage"]).UserID; var result = PCDDBusiness.M_UsersBusiness.UpdateM_UserBase(users); if (result) { var outresult = 0; PCDDEntity.Manage.M_Users model = PCDDBusiness.M_UsersBusiness.GetUserDetail(((M_Users)Session["PartManage"]).UserID); if (model != null) { CurrentUser = model; Session["Manager"] = model; } } JsonDictionary.Add("result", result); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// 是否有权限 /// </summary> public static string IsLimits(HttpContext httpContext, string menucode) { if (httpContext.Session["Manager"] != null) { PCDDEntity.Manage.M_Users model = (PCDDEntity.Manage.M_Users)httpContext.Session["Manager"]; if (model.Menus.Where(m => m.MenuCode == menucode).Count() > 0) { return(""); } } return("nolimits"); }
/// <summary> /// 用户登录 /// </summary> /// <param name="userName"></param> /// <param name="pwd"></param> /// <returns></returns> public JsonResult UserLogin(string userName, string pwd, string remember = "") { bool bl = false; string operateip = OperateIP; int result = 0; string msg = ""; PCDDEntity.Manage.M_Users model = PCDDBusiness.M_UsersBusiness.GetM_UserByProUserName(userName, pwd, operateip, out result); if (model != null) { if (model.Status == 0) { result = 0; Session["PartManage"] = model; msg = "还没有注册完成,请继续注册"; } else if (model.Status == 1) { HttpCookie cook = new HttpCookie("zpy"); cook["username"] = userName; cook["pwd"] = pwd; if (remember == "1") { cook["status"] = remember; } cook.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(cook); CurrentUser = model; Session["Manager"] = model; result = 1; } else { msg = result == 3 ? "用户已被禁闭,请联系管理员" : "用户名或密码错误!"; } } else { msg = result == 3 ? "用户已被禁闭,请联系管理员" : result == 2?"用户名不存在":"用户名或密码错误!"; } JsonDictionary.Add("result", result); JsonDictionary.Add("errorMsg", msg); return(new JsonResult { Data = JsonDictionary, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }