Exemplo n.º 1
0
        /// <summary>
        /// 修改的界面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(string id)
        {
            T_Sys_Users one = _bll.FindSingleData(Guid.Parse(id));

            //角色的设置界面
            ViewBag.roles = new SelectList(SysDataHelper <sys_role> .GetData(), "id", "rowname");
            return(View(one));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加用户的界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            T_Sys_Users user = new T_Sys_Users();

            user.CreateDate = DateTime.Now;
            //角色的设置界面
            ViewBag.roles = new SelectList(SysDataHelper <sys_role> .GetData(), "id", "rowname");
            return(View(user));
        }
Exemplo n.º 3
0
        public JsonResult Delete(string id)
        {
            Guid        idg = Guid.Parse(id);
            T_Sys_Users one = _bll.GetData(g => g.UserId == idg).FirstOrDefault();
            bool        add = _bll.Delete(one);
            CRUDModel   cm  = CRUDModelHelper.GetRes(CRUD.DELETE, add);

            return(Json(cm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public JsonResult Edit(T_Sys_Users one)
        {
            bool edit = _bll.UpdateSubFields(one, new List <string>()
            {
                "UserName", "RealName", "Tel", "Email", "roleid", "CreateDate"
            });
            CRUDModel cm = CRUDModelHelper.GetRes(CRUD.EDIT, edit);

            return(Json(cm));
        }
Exemplo n.º 5
0
        public JsonResult Add(T_Sys_Users one)
        {
            one.UserId      = Guid.NewGuid();
            one.PassWord    = MD5Helper.EncryptString(one.PassWord);
            one.CreateDate  = DateTime.Now;
            one.IsStatus    = 0;
            one.Sex         = 1;
            one.ExamineStep = 2;
            bool      add = _bll.Insert(one);
            CRUDModel cm  = CRUDModelHelper.GetRes(CRUD.ADD, add);

            return(Json(cm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        // GET: Admin
        public ActionResult Login(UserLoginModel user)
        {
            bool isLogin = false;

            if (User.Identity.IsAuthenticated)
            {
                return(Redirect(Url.Action("Index", "Home")));
            }
            else
            {
                string validateCookie = BaseHelper.GetCookie("ValidationCode").ToLower();
                if (user.UserAuthCode != null)
                {
                    if (string.Equals(validateCookie, user.UserAuthCode.ToLower()))
                    {
                        if (!string.IsNullOrEmpty(user.UserName) && !string.IsNullOrEmpty(user.Password))
                        {
                            AccountModel amodel   = new AccountModel();
                            T_Sys_Users  usercurr = amodel.ValidateUserLogin(user.UserName, user.Password);
                            if (usercurr != null)
                            {
                                //创建用户ticket信息
                                amodel.CreateLoginUserTicket(user.UserName, user.Password);
                                //读取用户权限数据
                                List <rel_rolemenus> rolemenus = relma.GetControllerAndActions(usercurr.roleid);
                                //设置用户的权限
                                amodel.GetUserAuthorities(usercurr.roleid, rolemenus);
                                return(Redirect(Url.Action("Index", "Home")));
                            }
                            else
                            {
                                user.ErrorMsg = SysCommonResource.LoginErrorUserNameOrPassword;
                            }
                        }
                    }
                    else
                    {
                        user.ErrorMsg = SysCommonResource.LoginOther;
                    }
                }
            }
            if (!isLogin)
            {
                return(View(user));
            }
            else
            {
                return(Redirect(Url.Action("Index", "Home")));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 读取数据库用户表数据,判断用户密码是否匹配
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        internal T_Sys_Users ValidateUserLogin(string name, string password)
        {
            string encpawd = MD5Helper.EncryptString(password);
            IList <T_Sys_Users> sysUsers = SysDataHelper <T_Sys_Users> .GetData(m => m.UserName == name && m.PassWord == encpawd).ToList();

            if (sysUsers.ToList().Count > 0)
            {
                T_Sys_Users sysUser = sysUsers.ToList().FirstOrDefault();
                HttpContext.Current.Session["userinfo"] = JsonConvert.SerializeObject(sysUser);
                return(sysUser);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
 public bool Delete(T_Sys_Users p)
 {
     return(_repository.Delete(p));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 修改指定的字段
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="fileds"></param>
 /// <returns></returns>
 public bool UpdateSubFields(T_Sys_Users entity, List <string> fileds)
 {
     return(_repository.UpdateSubFields(entity, fileds));
 }
Exemplo n.º 10
0
 public bool Update(T_Sys_Users p)
 {
     return(_repository.Update(p));
 }
Exemplo n.º 11
0
 public bool Insert(T_Sys_Users p)
 {
     return(_repository.Insert(p));
 }