Exemplo n.º 1
0
        public ActionResult Edit(string id, string UserName, string TrueName, string Role, string Password, string Pic)
        {
            T_UserInfo model = userbll.GetById(id);

            model.PassWord   = BaseSecurity.Md5Hash(Password);
            model.UserName   = UserName;
            model.TrueName   = TrueName;
            model.CreateDate = DateTime.Now;
            model.Role       = Role;
            model.pic        = Pic;
            try
            {
                if (userbll.Update(model))
                {
                    return(Json(new { success = true, msg = "操作成功" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "操作失败" }));
                }
            }
            catch
            {
                return(Json(new { success = false, msg = "操作失败" }));
            }
        }
Exemplo n.º 2
0
        public ActionResult Add(string UserName, string TrueName, string Role, string Password, string Pic)
        {
            T_UserInfo model = new T_UserInfo();

            model.id         = StringHelper.GetGuid();
            model.PassWord   = BaseSecurity.Md5Hash("111111");
            model.UserName   = UserName;
            model.TrueName   = TrueName;
            model.pic        = Pic;
            model.CreateDate = DateTime.Now;
            model.Role       = Role;
            try
            {
                userbll.Add(model);
                return(Json(new { success = true, msg = "操作成功" }));
            }
            catch
            {
                return(Json(new { success = false, msg = "操作失败" }));
            }
        }
Exemplo n.º 3
0
        public ActionResult Index(string username, string password)
        {
            var        passwordnew = BaseSecurity.Md5Hash(password);
            T_UserInfo model       = userService.GetAllList().Where(m => m.UserName == username).Where(m => m.PassWord == passwordnew).SingleOrDefault();

            if (model != null)
            {
                Session["UserId"]   = model.id;
                Session["UserName"] = model.UserName;
                Session["password"] = model.PassWord;
                HttpCookie _cookie = new HttpCookie("User");
                _cookie.Values.Add("UserId", model.id);
                _cookie.Values.Add("UserName", model.UserName);
                //_cookie.Values.Add("Password", BaseSecurity.Base64Encode(model.PassWord));
                _cookie.Values.Add("Password", passwordnew);
                Response.Cookies.Add(_cookie);
                return(RedirectToAction("Index", "AdminIndex"));
            }
            else
            {
                return(View());
            }
        }