Exemple #1
0
        /// <summary>
        /// 查询用户管理员分页
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo)
        {
            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete);
            entity.And(a => a.CompanyID == entity.CompanyID);
            entity.And(item => item.UserCode != "DA_0000");

            if (!entity.UserName.IsEmpty())
            {
                entity.And("UserName", ECondition.Like, "%" + entity.UserName + "%");
            }
            if (!entity.UserCode.IsEmpty())
            {
                entity.And("UserCode", ECondition.Like, "%" + entity.UserCode + "%");
            }

            if (!entity.RoleNum.IsEmpty())
            {
                entity.And(a => a.RoleNum == entity.RoleNum);
            }

            if (!entity.DepartNum.IsEmpty())
            {
                DepartProvider         provider   = new DepartProvider(this.CompanyID);
                List <SysDepartEntity> listDepart = provider.GetChildList(entity.DepartNum);
                string[] items = null;
                if (!listDepart.IsNullOrEmpty())
                {
                    items = listDepart.Select(item => item.SnNum).ToArray();
                    entity.And("DepartNum", ECondition.In, items);
                }
            }

            int rowCount = 0;
            List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount);

            pageInfo.RowCount = rowCount;

            if (!listResult.IsNullOrEmpty())
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);
                foreach (AdminEntity item in listResult)
                {
                    if (item.RoleNum.IsNotEmpty())
                    {
                        SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(item.RoleNum);
                        item.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                    }
                    if (item.DepartNum.IsNotEmpty())
                    {
                        SysDepartEntity DepartEntity = DepartProvider.GetSingle(item.DepartNum);
                        item.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                    }
                }
            }
            return(listResult);
        }
 public ActionResult AddDepart([ModelBinder(typeof(JsonBinder<SysDepartEntity>))] SysDepartEntity entity)
 {
     DepartProvider provider = new DepartProvider();
     int line = 0;
     if (entity.DepartNum.IsEmpty())
     {
         entity.DepartNum = SequenceProvider.GetSequence(typeof(SysDepartEntity));
         entity.IsDelete = (int)EIsDelete.NotDelete;
         entity.CreateTime = DateTime.Now;
         line = provider.Add(entity);
     }
     else
     {
         line = provider.UpdateDepart(entity);
     }
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
Exemple #3
0
        /// <summary>
        /// 使用工号扫描
        /// </summary>
        /// <param name="UserCode"></param>
        /// <returns></returns>
        public AdminEntity Scan(string UserCode)
        {
            AdminEntity entity = new AdminEntity();

            entity.IncludeAll();
            entity.Exclude(a => a.PassWord);
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And <AdminEntity>(a => a.CompanyID == CompanyID)
            .And(item => item.UserCode == UserCode)
            ;
            entity = this.Admin.GetSingle(entity);
            if (entity != null)
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);

                if (entity.RoleNum.IsNotEmpty())
                {
                    SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum);
                    entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                }
                if (entity.DepartNum.IsNotEmpty())
                {
                    SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum);
                    entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                }
            }
            return(entity);
        }
 public ActionResult AddDepart()
 {
     string departNum = WebUtil.GetQueryStringValue<string>("departNum");
     if (departNum.IsEmpty())
     {
         ViewBag.SysDepart = new SysDepartEntity();
         return View();
     }
     else
     {
         DepartProvider provider = new DepartProvider();
         SysDepartEntity entity = provider.GetDepartEntity(departNum);
         entity = entity == null ? new SysDepartEntity() : entity;
         ViewBag.SysDepart = entity;
         return View();
     }
 }
 public ActionResult BatchDel(string id)
 {
     DepartProvider provider = new DepartProvider();
     string[] list = id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     List<string> ls = new List<string>();
     int line = 0;
     foreach (string t in list)
     {
         line += provider.DeleteDepart(Convert.ToInt32(t));
     }
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     else
     {
         this.ReturnJson.AddProperty("d", "");
     }
     return Content(this.ReturnJson.ToString());
 }
Exemple #6
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public AdminEntity Login(string userName, string passWord)
        {
            AdminEntity entity = new AdminEntity();

            entity.IncludeAll();
            entity.Exclude(a => a.ParentName);
            entity.Where(a => a.UserName == userName)
            .And(a => a.PassWord == passWord)
            .And <AdminEntity>(a => a.CompanyID == CompanyID)
            .And(a => a.IsDelete == (int)EIsDelete.NotDelete)
            ;

            entity = this.Admin.GetSingle(entity);
            if (entity != null)
            {
                SysRoleProvider RoleProvider   = new SysRoleProvider(this.CompanyID);
                DepartProvider  DepartProvider = new DepartProvider(this.CompanyID);

                if (entity.RoleNum.IsNotEmpty())
                {
                    SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum);
                    entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty;
                }
                if (entity.DepartNum.IsNotEmpty())
                {
                    SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum);
                    entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty;
                }
                Task.Factory.StartNew(() =>
                {
                    AdminEntity admin = new AdminEntity();
                    admin.LoginCount  = entity.LoginCount + 1;
                    admin.IncludeLoginCount(true);
                    admin.Where(a => a.UserNum == entity.UserNum).And(item => item.CompanyID == this.CompanyID);
                    this.Admin.Update(admin);
                });
            }
            return(entity);
        }
 public ActionResult Delete(int id)
 {
     DepartProvider provider = new DepartProvider();
     int line = provider.DeleteDepart(id);
     if (line > 0)
     {
         this.ReturnJson.AddProperty("d", "success");
     }
     return Content(this.ReturnJson.ToString());
 }
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            string departName = WebUtil.GetFormValue<string>("departName", string.Empty);
            DepartProvider provider = new DepartProvider();
            SysDepartEntity entity = new SysDepartEntity();
            List<SysDepartEntity> list = provider.GetList();
            List<SysDepartEntity> listResult = new List<SysDepartEntity>();
            if (!list.IsNullOrEmpty())
            {
                listResult = list.Where(a => a.DepartName.Contains(departName) || a.DepartNum.Contains(departName)).OrderByDescending(a => a.ID).ToList();
            }

            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("创建时间"));
                int count = 1;
                foreach (SysDepartEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.DepartNum;
                    row[2] = t.DepartName;
                    row[3] = t.CreateTime;
                    count++;
                    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());
        }
 public ActionResult DepartList(int pageIndex, int pageSize, string departName)
 {
     DepartProvider provider = new DepartProvider();
     List<SysDepartEntity> list = provider.GetList();
     List<SysDepartEntity> listResult = new List<SysDepartEntity>();
     List<SysDepartEntity> returnList = new List<SysDepartEntity>();
     if (!list.IsNullOrEmpty())
     {
         listResult = list.Where(a => a.DepartName.Contains(departName) || a.DepartNum.Contains(departName)).ToList();
         returnList = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).OrderByDescending(a => a.ID).ToList();
     }
     this.ReturnJson.AddProperty("Data", ConvertJson.ListToJson<SysDepartEntity>(returnList, "List"));
     this.ReturnJson.AddProperty("RowCount", listResult.Count);
     return Content(this.ReturnJson.ToString());
 }
Exemple #10
0
 /// <summary>
 /// 获得部门的下来列表
 /// </summary>
 /// <param name="departNum"></param>
 /// <returns></returns>
 public static string GetDepartList(string departNum)
 {
     DepartProvider provider = new DepartProvider();
     List<SysDepartEntity> list = provider.GetList();
     StringBuilder sb = new StringBuilder();
     string departTemplate = "<option value='{0}' {1}>{2}</option>";
     sb.AppendFormat(departTemplate, "", "", "请选择部门");
     if (!list.IsNullOrEmpty())
     {
         foreach (SysDepartEntity depart in list)
         {
             sb.AppendFormat(departTemplate, depart.DepartNum, depart.DepartNum == departNum ? "selected='selected'" : string.Empty, depart.DepartName);
         }
     }
     return sb.ToString();
 }