//添加保存 public ActionResult SaveAdd(ITC_Userinfo_M model) { model.User_Createdtime = DateTime.Now; model.User_Pwd = uifo.pwEcncrystr("123456");//加密 model.User_Account = model.User_ID.Trim(); model.User_Oprt = UserContext.UserName; if (!uifo.Exists(model.User_ID)) { if (uifo.Add(model)) { EventContext.Add(MenuID, string.Format("添加:{0}", model.User_ID)); return(Content("保存成功!")); } else { return(Content("保存失败!")); } } else { return(Content("保存失败! 编码[" + model.User_ID + "]已存在!")); } }
/// <summary> /// 登录验证 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult DL(ITC_Userinfo_M model) { if (!string.IsNullOrEmpty(model.User_ID) && !string.IsNullOrEmpty(model.User_Pwd)) { ITC_Userinfo bll = new ITC_Userinfo(); model.User_Pwd = bll.pwEcncrystr(model.User_Pwd); if (bll.Exists(model.User_ID, model.User_Pwd)) { UserContext.Init(model.User_ID); //设置登录cookie,名称为:SdlCookie HttpCookie SdlCookie = new HttpCookie("SdlCookie"); //EmpNo:登录工号 SdlCookie["EmpNo"] = UserContext.UserID; //EmpName:姓名 SdlCookie["EmpName"] = System.Web.HttpContext.Current.Server.UrlEncode(UserContext.UserName); //LastLoginTime:上次登录日期 //LastLoginIP:上次登录IP if (false) { //SdlCookie["LastLoginTime"] = model_log_last.Entry.ToString(); //SdlCookie["LastLoginIP"] = model_log_last.IP; } else { SdlCookie["LastLoginTime"] = ""; SdlCookie["LastLoginIP"] = ""; } System.Web.HttpContext.Current.Response.Cookies.Add(SdlCookie); return(RedirectToAction("Index", "Home")); } else { ViewBag.message = "帐号和密码不正确!请重新输入!"; ViewBag.SysName = "盒子系统"; return(View("Index")); } } else { ViewBag.message = "请输入帐号和密码!"; ViewBag.SysName = "盒子系统"; return(View("Index")); } }