public ActionResult ModifyPassword() { SysChain.Model.SysUser user = (SysChain.Model.SysUser)Session["UserInfo"]; Model.VM_SysModifyPassword model = new Model.VM_SysModifyPassword(); model.LoginName = user.LoginName; return(View(model)); }
public JsonResult Login(SysChain.Model.VM_SysLogin model) { Helper.ResultInfo <bool> rs = new Helper.ResultInfo <bool>(); if (ModelState.IsValid) { BLL.SysUser Operation = new BLL.SysUser(); SysChain.Model.SysUser user = Operation.GetEntity(model); if (user != null) { if (user.State != true) { rs.Data = false; rs.Msg = "账号已冻结,请联系管理员."; rs.Result = false; rs.Url = ""; } else { Session["UserInfo"] = user; rs.Data = true; rs.Msg = "登录成功,正在进入系统"; rs.Result = true; rs.Url = Url.Action("Index", "Home", new { area = "Admin" }); } } else { rs.Data = false; rs.Msg = "账号或密码错误."; rs.Result = false; rs.Url = ""; } JsonResult jr = new JsonResult(); jr.Data = rs; return(jr); } else { System.Text.StringBuilder sbErrors = new System.Text.StringBuilder(); foreach (var item in ModelState.Values) { if (item.Errors.Count > 0) { for (int i = item.Errors.Count - 1; i >= 0; i--) { sbErrors.Append(item.Errors[i].ErrorMessage); sbErrors.Append("<br/>"); } } } rs.Data = false; rs.Msg = sbErrors.ToString(); rs.Result = false; rs.Url = ""; JsonResult jr = new JsonResult(); jr.Data = rs; return(jr); } }
public ActionResult Index() { SysChain.Model.SysUser user = (SysChain.Model.SysUser)Session["UserInfo"]; if (!Opr.ExistsByUserID(user.UserID)) { return(RedirectToAction("Setting")); } else { return(View()); } }
public ActionResult Setting(int?id) { int StoreID = id == null ? 0 : (int)id; Model.SysStore model = new Model.SysStore(); if (StoreID > 0) { model = Opr.GetEntity(StoreID); } else { SysChain.Model.SysUser user = (SysChain.Model.SysUser)Session["UserInfo"]; model.UserID = user.UserID; model.StoreID = 0; } return(View(model)); }
public JsonResult UploadImg(string type, HttpPostedFileBase[] uploadfile) { Helper.ResultInfo <bool> rs = new Helper.ResultInfo <bool>(); if (Session["UserInfo"] != null) { SysChain.Model.SysUser user = (SysChain.Model.SysUser)Session["UserInfo"]; const string fileTypes = "gif,jpg,jpeg,png,bmp"; const int maxSize = 205000; string imgPath = "/Content/Public/Images/store/"; for (int fileId = 0; fileId < uploadfile.Count(); fileId++) { HttpPostedFileBase curFile = uploadfile[fileId]; if (curFile.ContentLength < 1) { continue; } else if (curFile.ContentLength > maxSize) { rs.Msg = "上传文件中有图片大小超出200KB!"; rs.Result = false; break; } string fileExt = Path.GetExtension(curFile.FileName); if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1) { rs.Msg = "上传文件中包含不支持文件格式!!"; rs.Result = false; break; } string fullFileName = type + "_" + user.UserID.ToString() + fileExt; //CreateRandomCode(8) try { string filePhysicalPath = Server.MapPath(imgPath + fullFileName); if (!System.IO.Directory.Exists(Server.MapPath(imgPath))) { System.IO.Directory.CreateDirectory(Server.MapPath(imgPath)); } if (System.IO.File.Exists(filePhysicalPath)) { System.IO.File.Delete(filePhysicalPath); } curFile.SaveAs(filePhysicalPath); rs.Data = true; rs.Result = true; rs.Url = imgPath + fullFileName; } catch (Exception exception) { rs.Msg = exception.Message; rs.Result = false; break; } } } else { rs.Msg = "上传文件中包含不支持文件格式!!"; rs.Result = false; } JsonResult jr = new JsonResult(); jr.Data = rs; return(jr); }