public ActionResult Login(LoginViewModel model) { //if (ModelState.IsValid) //{ if (string.IsNullOrEmpty(model.Account)) { model.ErrorMsg[0] = "请输入账号"; } if (string.IsNullOrEmpty(model.Password)) { model.ErrorMsg[1] = "请输入密码"; } if (model.ErrorMsg.Count(_ => !string.IsNullOrEmpty(_)) > 0) { return(View(model)); } var loginUser = usrOp.GetSingleData(_ => _.Account == model.Account && _.Password == MD5Helper.MD5Encrypt16(model.Password)); if (loginUser == null) { ModelState.AddModelError("LoginPwd", "账号或密码不正确,请重新输入!"); model.ErrorMsg[2] = "账号或密码不正确,请重新输入!"; return(View(model)); } // 当前登录用户信息存入Session Session.Add("CurrenyUser", loginUser); // 设置ticket票据的名称为用户的id,设置有效时间为60分钟 FormsAuthHelp.AddFormsAuthCookie(loginUser.Account, loginUser, 1); //} return(Redirect("~/Home/Main")); }
/// <summary> /// 编辑页 /// </summary> /// <param name="Id"></param> /// <param name="type"></param> /// <returns></returns> public ActionResult Edit(long Id = 0, string type = "") { var model = new SurveyViewModel(); if (Id > 0) { var qs = qsOp.GetSingleData(_ => _.SurveyId == Id); model.SurveyId = qs.SurveyId; model.SurveyNo = qs.SurveyNo; model.SurveyDate = qs.SurveyDate.ToString("yyyy-MM-dd HH:mm:ss"); model.SurveyDesc = qs.SurveyDesc == null ? "" : qs.SurveyDesc; model.SurveyImages = qs.SurveyImages; } if (type == "read") { model.ReadOnly = "readonly"; } return(View(model)); }