protected override void OnActionExecuting(ActionExecutingContext filterContext) { ////控制器基类验证,是否登录 if (Session["member"] == null && !System.Web.HttpContext.Current.Request.Path.Contains("login") && !System.Web.HttpContext.Current.Request.Path.Equals("/KSOAWeb/")) { HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["keeplogin"]; if (cookie == null) { filterContext.Result = Redirect(String.Format("~/admin/login.html", Request.Url.PathAndQuery));//跳转到登录页 } else { Admin_KSCustomer aks = new Admin_KSCustomerLogic().GetCusbyCusName(cookie.Value); Session["member"] = aks; } } base.OnActionExecuting(filterContext); }
/// <summary> /// 检查用户名是否存在 /// </summary> /// <param name="CusName"></param> /// <returns></returns> public JsonResult CheckCusName() { String CusName = Request["cusName"]; var aks = new Admin_KSCustomerLogic().GetCusbyCusName(CusName); if (aks == null) { return Json(new { result = 0 }, JsonRequestBehavior.AllowGet);//不存在 } else { return Json(new { result = 1 }, JsonRequestBehavior.AllowGet);//存在 } }
public ActionResult PopList() { this.pageSize = GetPageSize(15); //每页数量 this.page = DTRequest.GetQueryInt("page", 1); ViewBag.txtKeywords = this.keywords; List<Admin_KSCustomer> acplist = new Admin_KSCustomerLogic().GetPopList(this.pageSize, this.page, out this.totalCount); //绑定页码 ViewBag.txtPageNum = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("../admin/PopList", "group_id={0}&keywords={1}&page={2}", this.group_id.ToString(), this.keywords, "__id__"); ViewBag.PageContent = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); return View(acplist); }
public ActionResult PopEdit(int id) { Admin_KSCustomer aks = new Admin_KSCustomerLogic().GetCusbyID(id); ViewBag.msg = Session["peMsg"] ?? ""; Session.Remove("peMsg"); return View(aks); }
public JsonResult PopDel() { String[] strids = Request["ids"].Split(','); int[] arr2 = new int[strids.Length]; //用来存放将字符串转换成int[] for (int i = 0; i < strids.Length; i++) { arr2[i] = int.Parse(strids[i]); } bool result = new Admin_KSCustomerLogic().DelCusByID(arr2); return Json(new { result = 1 }, JsonRequestBehavior.AllowGet); }
public ActionResult Managerpwd(FormCollection form) { Admin_KSCustomer cus = new Admin_KSCustomer(); cus.CusName = form["txtUserName"]; cus.CusPwd = form["txtUserPwd"]; cus.Oldcuspwd = form["txtoldpwd"]; cus.RealName = form["txtRealName"] ?? ""; cus.CusPhoneNum = form["txtTelephone"]; cus.CusEmail = form["txtEmail"]; //验证旧密码是否正确 Admin_KSCustomer result = new Admin_KSCustomerLogic().CheckLogin(cus.CusName, cus.Oldcuspwd); if (result != null) { if (new Admin_KSCustomerLogic().UpdateCusInfo(cus)) { Session["mpdMsg"] = "更新成功"; return RedirectToAction("Managerpwd"); } else { Session["mpdMsg"] = "更新失败"; return RedirectToAction("Managerpwd"); } } Session["mpdMsg"] = "旧登录密码错误"; return RedirectToAction("Managerpwd"); }
public ActionResult Login(FormCollection from) { string userName = from["txtUserName"] ?? ""; string userPwd = from["txtUserPwd"] ?? ""; if (userName.Equals("") || userPwd.Equals("")) { ViewBag.MsgTip = "请输入用户名或密码"; return View(); } Admin_KSCustomer result = new Admin_KSCustomerLogic().CheckLogin(userName, userPwd); if (result == null) { ViewBag.MsgTip = "用户名或密码错误"; return View(); } else { //保存登陆信息到Session Session["member"] = result; HttpCookie cookie = new HttpCookie("keeplogin"); cookie.Expires = DateTime.Now.AddHours(4); //保存到Cookie cookie.Value = userName; Response.Cookies.Add(cookie); return RedirectToAction("Index"); } }