public IActionResult AddUser(Tsys_User user)
        {
            if (string.IsNullOrWhiteSpace(user.Workid))
            {
                return(FailMessage("用户工号不能为空!"));
            }
            if (string.IsNullOrWhiteSpace(user.Name))
            {
                return(FailMessage("用户姓名不能为空!"));
            }
            if (string.IsNullOrWhiteSpace(user.Pwd))
            {
                return(FailMessage("用户密码不能为空!"));
            }

            user.Pwd        = Md5.Encrypt32(user.Pwd);
            user.Createtime = DateTime.Now;

            Tsys_User_Da da = new Tsys_User_Da();

            if (da.Select.Where(i => i.Workid == user.Workid).Count() > 0)
            {
                return(FailMessage("用户工号重复!"));
            }

            da.Insert(user);

            return(SuccessResult("添加用户成功!"));
        }
        public IActionResult UpdateUser(Tsys_User user)
        {
            if (string.IsNullOrWhiteSpace(user.Workid))
            {
                return(FailMessage("用户工号不能为空!"));
            }
            if (string.IsNullOrWhiteSpace(user.Name))
            {
                return(FailMessage("用户姓名不能为空!"));
            }
            if (string.IsNullOrWhiteSpace(user.Pwd))
            {
                return(FailMessage("用户密码不能为空!"));
            }

            Tsys_User_Da da = new Tsys_User_Da();

            Tsys_User old = da.Select.Where(o => o.Id == user.Id).First();

            if (old.Pwd != user.Pwd)
            {
                user.Pwd = Md5.Encrypt32(user.Pwd);
            }

            if (da.Update(user) <= 0)
            {
                return(FailMessage("修改用户信息失败!"));
            }

            return(SuccessResult("修改用户信息成功!"));
        }
        public IActionResult QueryPeople(string keyword)
        {
            Tsys_User_Da da   = new Tsys_User_Da();
            var          list = da.ListByWhere(keyword);

            return(SuccessResult(list));
        }
        public IActionResult List(string keyword, int pageIndex, int pageSize)
        {
            PageModel page = new PageModel
            {
                PageIndex = pageIndex,
                PageSize  = pageSize
            };

            Tsys_User_Da da   = new Tsys_User_Da();
            var          list = da.ListByWhere(keyword, ref page);

            return(SuccessResultList(list, page));
        }
        public IActionResult BatchDeleteUser(int[] ids)
        {
            Tsys_User_Da da = new Tsys_User_Da();

            if (da.Delete(u => ids.Contains(u.Id)) <= 0)
            {
                return(FailMessage("批量删除用户失败!"));
            }
            else
            {
                return(SuccessResult("批量删除用户成功!"));
            }
        }
        public IActionResult DeleteUser(int id)
        {
            Tsys_User_Da da = new Tsys_User_Da();

            if (da.Delete(u => u.Id == id) <= 0)
            {
                return(FailMessage("删除用户失败!"));
            }
            else
            {
                return(SuccessResult("删除用户成功!"));
            }
        }
Exemplo n.º 7
0
        public bool Login(string workId, string pwd, ref Tsys_User user)
        {
            Tsys_User_Da da = new Tsys_User_Da();

            if (da.Where(s => s.Workid == workId).ToOne() == null)
            {
                this.Message = "用户工号不存在";

                return(false);
            }

            user = da.Where(s => s.Workid == workId && s.Pwd == pwd).ToOne();

            if (user == null)
            {
                this.Message = "密码错误";

                return(false);
            }

            return(true);
        }