예제 #1
0
 public ActionResult AddUser([ModelBinder(typeof(JsonBinder<AdminEntity>))] AdminEntity entity)
 {
     AdminProvider provider = new AdminProvider();
     entity.UpdateTime = DateTime.Now;
     int line = 0;
     if (entity.UserCode.IsEmpty())
     {
         bool isExist = provider.IsExist(entity.UserName);
         if (isExist)
         {
             this.ReturnJson.AddProperty("d", "该用户名已经存在!");
             return Content(this.ReturnJson.ToString());
         }
         entity.UserCode = SequenceProvider.GetSequence(typeof(AdminEntity));
         line = provider.AddAdmin(entity);
     }
     else
     {
         line = provider.Update(entity);
     }
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
예제 #2
0
 public ActionResult AccountSetting()
 {
     AdminProvider provider = new AdminProvider();
     AdminEntity entity = provider.GetAdmin(this.LoginUser.UserCode);
     ViewBag.RoleList = BaseHelper.GetRoleList(this.LoginUser.RoleNum);
     ViewBag.DepartList = BaseHelper.GetDepartList(this.LoginUser.DepartNum);
     ViewBag.Admin = entity;
     return View();
 }
 /// <summary>
 /// 查询产品类别分页
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="pageInfo"></param>
 /// <returns></returns>
 public List<ProductCategoryEntity> GetList(ProductCategoryEntity entity, ref PageInfo pageInfo)
 {
     entity.IncludeAll();
     entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
     entity.OrderBy(a => a.ID, EOrderBy.DESC);
     int rowCount = 0;
     List<ProductCategoryEntity> list = this.ProductCategory.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);
     pageInfo.RowCount = rowCount;
     if (!list.IsNullOrEmpty())
     {
         AdminProvider adminProvider = new AdminProvider();
         foreach (ProductCategoryEntity item in list)
         {
             if (!item.CreateUser.IsEmpty())
             {
                 AdminEntity admin = adminProvider.GetAdmin(item.CreateUser);
                 item.CreateUser = admin.IsNotNull() ? admin.UserName : item.CreateUser;
             }
         }
     }
     return list;
 }
예제 #4
0
 public ActionResult AddUser()
 {
     string userCode = WebUtil.GetQueryStringValue<string>("userCode");
     if (userCode.IsEmpty())
     {
         ViewBag.RoleList = BaseHelper.GetRoleList(string.Empty);
         ViewBag.DepartList = BaseHelper.GetDepartList(string.Empty);
         ViewBag.Admin = new AdminEntity();
         return View();
     }
     else
     {
         AdminProvider provider = new AdminProvider();
         AdminEntity entity = provider.GetAdmin(userCode);
         entity = entity == null ? new AdminEntity() : entity;
         ViewBag.RoleList = BaseHelper.GetRoleList(entity.RoleNum);
         ViewBag.DepartList = BaseHelper.GetDepartList(entity.DepartNum);
         entity.RoleName = this.LoginUser.RoleName;
         ViewBag.Admin = entity;
         return View();
     }
 }
예제 #5
0
 public ActionResult BatchDel(string userCode)
 {
     AdminProvider provider = new AdminProvider();
     string[] list = userCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     List<string> ls = new List<string>();
     int line = 0;
     foreach (string t in list)
     {
         line += provider.Delete(t);
     }
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
예제 #6
0
 public ActionResult ToExcel()
 {
     PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
     string userCode = WebUtil.GetFormValue<string>("userCode", string.Empty);
     string userName = WebUtil.GetFormValue<string>("userName", string.Empty);
     string roleNum = WebUtil.GetFormValue<string>("roleNum", string.Empty);
     string departNum = WebUtil.GetFormValue<string>("departNum", string.Empty);
     AdminProvider provider = new AdminProvider();
     AdminEntity entity = new AdminEntity();
     if (!userCode.IsEmpty())
     {
         entity.Where("UserCode", ECondition.Like, userCode + "%");
     }
     if (!userName.IsEmpty())
     {
         entity.Where("UserName", ECondition.Like, userName + "%");
     }
     if (!roleNum.IsEmpty())
     {
         entity.And(a => a.RoleNum == roleNum);
     }
     if (!departNum.IsEmpty())
     {
         entity.And(a => a.DepartNum == departNum);
     }
     List<AdminEntity> listResult = provider.GetList(entity, ref pageInfo);
     if (!listResult.IsNullOrEmpty())
     {
         DataTable dt = new DataTable();
         dt.Columns.Add(new DataColumn("用户名"));
         dt.Columns.Add(new DataColumn("编号"));
         dt.Columns.Add(new DataColumn("真名"));
         dt.Columns.Add(new DataColumn("Email"));
         dt.Columns.Add(new DataColumn("联系方式"));
         dt.Columns.Add(new DataColumn("登录次数"));
         dt.Columns.Add(new DataColumn("部门"));
         dt.Columns.Add(new DataColumn("角色"));
         foreach (AdminEntity t in listResult)
         {
             DataRow row = dt.NewRow();
             row[0] = t.UserName;
             row[1] = t.UserCode;
             row[2] = t.RealName;
             row[3] = t.Email;
             row[4] = t.Mobile;
             row[5] = t.LoginCount;
             row[6] = t.DepartName;
             row[7] = t.RoleName;
             dt.Rows.Add(row);
         }
         string filePath = Server.MapPath("~/UploadFiles/");
         if (!System.IO.Directory.Exists(filePath))
         {
             System.IO.Directory.CreateDirectory(filePath);
         }
         string filename = string.Format("员工管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
         NPOIExcel excel = new NPOIExcel("员工管理", "员工", System.IO.Path.Combine(filePath, filename));
         excel.ToExcel(dt);
         this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
     }
     else
     {
         this.ReturnJson.AddProperty("d", "无数据导出!");
     }
     return Content(this.ReturnJson.ToString());
 }
예제 #7
0
 /// <summary>
 /// 登录
 /// 1000: 登录成功
 /// 1001: 登录失败
 /// 1002: 验证码过期
 /// 1003:验证码错误
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="passWord"></param>
 /// <returns></returns>
 public ActionResult Login(string userName, string passWord, string code)
 {
     //string valCode=SessionHelper.Get("ValCode");
     //if (valCode.IsEmpty())
     //{
     //    return Content("1002");
     //}
     //if (valCode.ToLower()!=code.ToLower())
     //{
     //    return Content("1003");
     //}
     AdminProvider provider = new AdminProvider();
     AdminEntity entity = provider.Login(userName, passWord);
     if (entity != null)
     {
         this.LoginUser = entity;
         provider.UpdateLoginCount(entity.UserName, entity.PassWord, entity.LoginCount);
         return Content("1000");
     }
     return Content("1001");
 }
예제 #8
0
        public ActionResult GetAdminList()
        {
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 1);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 15);
            string userCode = WebUtil.GetFormValue<string>("userCode", string.Empty);
            string userName = WebUtil.GetFormValue<string>("userName", string.Empty);
            string roleNum = WebUtil.GetFormValue<string>("roleNum", string.Empty);
            string departNum = WebUtil.GetFormValue<string>("departNum", string.Empty);
            string search = WebUtil.GetFormValue<string>("search", string.Empty);

            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            AdminProvider provider = new AdminProvider();
            AdminEntity entity = new AdminEntity();
            if (!search.IsEmpty())
            {
                entity.Where("UserCode", ECondition.Like, "%" + search + "%");
                entity.Or("RealName", ECondition.Like, "%" + search + "%");
                entity.Or("UserName", ECondition.Like, "%" + search + "%");
            }
            else
            {
                if (!userCode.IsEmpty())
                {
                    entity.Where("UserCode", ECondition.Like, "%" + userCode + "%");
                    entity.Or("RealName", ECondition.Like, "%" + userCode + "%");
                }
                if (!userName.IsEmpty())
                {
                    entity.Where("UserName", ECondition.Like, "%" + userName + "%");
                }
                if (!roleNum.IsEmpty())
                {
                    entity.And(a => a.RoleNum == roleNum);
                }
                if (!departNum.IsEmpty())
                {
                    entity.And(a => a.DepartNum == departNum);
                }
            }
            List<AdminEntity> listResult = provider.GetList(entity, ref pageInfo);
            string json = ConvertJson.ListToJson<AdminEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return Content(this.ReturnJson.ToString());
        }
예제 #9
0
 public ActionResult Delete(string userCode)
 {
     AdminProvider provider = new AdminProvider();
     int line = provider.Delete(userCode);
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
예제 #10
0
 public ActionResult ChangePwd(string currentPassword, string passWord)
 {
     AdminProvider provider = new AdminProvider();
     AdminEntity entity = provider.Login(this.LoginUser.UserName, currentPassword);
     int line = 0;
     if (entity.IsNotNull())
     {
         entity.PassWord = passWord;
         line = provider.UpdatePwd(entity);
     }
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }