Пример #1
0
        public ActionResult Index(string userName, string userPwd)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(userPwd))
            {
                ViewBag.Success = false;
                ViewBag.Message = "账号或密码不能为空!";
                return(View());
            }
            userPwd = userPwd.ToSHA1();
            UrUsersBll bll  = new UrUsersBll();
            UR_USERS   user = bll.Query(t => t.USER_LOGIN_NAME == userName && t.USER_LOGIN_PASSWD == userPwd).FirstOrDefault();

            if (user == null)
            {
                ViewBag.Success = false;
                ViewBag.Message = "账号或密码错误!";
                return(View());
            }

            user.USER_LOGIN_DATE = DateTime.Now;
            user.USER_UNUSED1    = Guid.NewGuid().ToString("n");
            bll.Update(user);
            //写入cookie
            HttpCookie cookies = new HttpCookie("UserToken");

            cookies["token"]    = user.USER_UNUSED1;
            cookies["userName"] = HttpUtility.UrlEncode(user.USER_NAME, System.Text.Encoding.UTF8);
            cookies.Expires     = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookies);

            return(Redirect("~/Home/"));
        }
Пример #2
0
        public ActionResult AdminPwd(int userId, string oldPwd, string newPwd)
        {
            UrUsersBll bll  = new UrUsersBll();
            UR_USERS   user = bll.Query(t => t.USER_ID == userId).FirstOrDefault();

            if (user.USER_LOGIN_PASSWD != oldPwd.ToSHA1() && !string.IsNullOrEmpty(user.USER_LOGIN_PASSWD))
            {
                ViewBag.Success = false;
                ViewBag.Message = "当前密码不正确!";
                return(View(user));
            }
            user.USER_LOGIN_PASSWD = newPwd.ToSHA1();

            bll.Update(user);

            ViewBag.Success = true;
            ViewBag.Message = "修改成功!";

            return(View(user));
        }
Пример #3
0
        public ActionResult AdminEdit(UR_USERS model)
        {
            UrUsersBll bll  = new UrUsersBll();
            UR_USERS   user = bll.Query(t => t.USER_ID == model.USER_ID).FirstOrDefault();

            ViewBag.Organization = new SysOrganizationBll().Query(t => true).ToDictionary(x => x.ORG_ID, x => x.ORG_NAME);
            ViewBag.Part         = new UrPartBll().Query(t => true).ToDictionary(x => x.PART_ID, x => x.PART_NAME);

            if (user == null)
            {
                user = model;
                user.USER_CREATE_DATE = DateTime.Now;
                bll.Add(user);
            }
            else
            {
                user.USER_NAME       = model.USER_NAME;
                user.USER_ORG_ID     = model.USER_ORG_ID;
                user.USER_LOGIN_NAME = model.USER_LOGIN_NAME;
                user.USER_PHONE      = model.USER_PHONE;
                user.USER_MOBILE     = model.USER_MOBILE;
                user.USER_EMAIL      = model.USER_EMAIL;
                user.USER_WORK_NO    = model.USER_WORK_NO;
                user.USER_SEX        = model.USER_SEX;
                user.USER_TITLE      = model.USER_TITLE;
                user.USER_ACTIVE     = model.USER_ACTIVE;
                user.USER_ADMIN      = model.USER_ADMIN;

                user.USER_UPDATE_DATE = DateTime.Now;
                bll.Update(user);
            }

            ViewBag.Success = true;
            ViewBag.Message = "修改成功!";

            return(View(user));
        }