示例#1
0
文件: Sorce.cs 项目: x4646/Evaluation
        /// <summary>
        /// 根据条件获取部门列表
        /// </summary>
        /// <param name="query">条件查询对象</param>
        /// <param name="pageSize">每页条数</param>
        /// <param name="currentIndex">当前页数</param>
        /// <param name="AllCount">所有记录数</param>
        /// <returns>部门列表</returns>
        public List<Model.DeptSorce> GetList(QueryDept query, int pageSize, int currentIndex, out int AllCount)
        {
            AllCount = 0;
            var list =
               from item in
                   (
                       from sorce in db.T_Sorce
                       join dept in db.T_Department on sorce.DeptID equals dept.Id
                       select new
                       {
                           sorce.Sorce,
                           sorce.Id,
                           sorce.DeptID,
                           dept.DeptName,
                           dept.TypeId
                       }
                   )
               group item by item.DeptID into sorceGroup
               select new Model.DeptSorce
               {
                   Sorce = sorceGroup.Sum(each => each.Sorce) / sorceGroup.Count(),
                   DeptName = sorceGroup.Max(o => o.DeptName),
                   TypeId = sorceGroup.Max(o => o.TypeId)
               };

            if (pageSize == 0)
            {
                return list.ToList();
            }
            AllCount = list.Count();
            return list.ToList().Skip((currentIndex - 1) * pageSize).Take(pageSize).ToList();
        }
示例#2
0
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="model">部门对象</param>
        /// <returns>结果对象</returns>
        public Model.ResultModel Add(Model.T_Department dept)
        {
            ResultModel rm = new ResultModel();
            Model.QueryDept qd = new QueryDept()
            {
                DeptName = dept.DeptName
            };
            var list = dal.Get(qd);

            if (list.Count > 0)
            {
                rm.Result = false;
                rm.Message = "部门名称重复";
            }
            else
            {
                if (dal.Add(dept))
                {
                    rm.Result = true;
                    rm.Message = "部门添加成功";
                }
                else
                {
                    rm.Result = false;
                    rm.Message = "部门添加失败";
                }
            }
            return rm;
        }
示例#3
0
 void BindrepList()
 {
     int allCount;
     Model.QueryDept query = new Model.QueryDept();
     this.repList.DataSource = BLL.Sorce.bll.GetList(query, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, out allCount);
     this.repList.DataBind();
     this.AspNetPager1.RecordCount = allCount;
 }
示例#4
0
 private void BindCtl()
 {
     int n ;
     var QueryDept = new Model.QueryDept();
     QueryDept.ID = Id;
     Model.Department model = BLL.Department.bll.GetList(QueryDept, 0, 0, out n).FirstOrDefault();
     this.txtDeptName.Text = model.DeptName;
     this.txtSort.Text = model.Sort.ToString();
     this.ddDetpType.SelectedValue = model.TypeId.ToString();
 }
示例#5
0
 /// <summary>
 /// 根据条件获取部门列表
 /// </summary>
 /// <param name="query">条件查询对象</param>
 /// <returns>部门列表</returns>
 public List<Model.Department> Get(QueryDept query)
 {
     var queryTable = (from dept in db.T_Department
                       join dic in db.T_Dictionary on dept.TypeId equals dic.Id
                       into deptDic
                       from dd in deptDic
                       where
                       (
                       (dept.IsDel.Equals(null) || dept.IsDel == false)
                       && (string.IsNullOrEmpty(query.DeptName) || dept.DeptName == query.DeptName)
                       && ((query.DicId == null) || dept.TypeId == query.DicId)
                       && ((query.ID == null) || dept.Id == query.ID)
                    )
                       orderby dept.Sort
                       select new Model.Department
                       {
                           DeptName = dept.DeptName,
                           TypeId = dd.Id,
                           DeptTypeName = dd.DisplayText,
                           Id = dept.Id,
                           Sort = dept.Sort
                       });
     return queryTable.ToList();
 }
示例#6
0
 /// <summary>
 /// 根据条件获取部门列表
 /// </summary>
 /// <param name="query">条件查询对象</param>
 /// <param name="pageSize">每页条数</param>
 /// <param name="currentIndex">当前页数</param>
 /// <param name="AllCount">所有记录数</param>
 /// <returns>部门列表</returns>
 public List<Model.DeptSorce> GetList(QueryDept query, int pageSize, int currentIndex, out int AllCount)
 {
     return dal.GetList(query, pageSize, currentIndex, out AllCount);
 }
示例#7
0
        /// <summary>
        /// 根据条件获取部门列表
        /// </summary>
        /// <param name="query">条件查询对象</param>
        /// <param name="pageSize">每页条数</param>
        /// <param name="currentIndex">当前页数</param>
        /// <param name="AllCount">所有记录数</param>
        /// <returns>部门列表</returns>
        public List<Model.Department> GetList(QueryDept query, int pageSize, int currentIndex, out int AllCount)
        {
            AllCount = 0;

            var list = Get(query);

            if (pageSize == 0)
            {
                return list;
            }

            AllCount = list.Count();
            return list.Skip((currentIndex - 1) * pageSize).Take(pageSize).ToList();
        }
示例#8
0
        /// <summary>
        /// 更新部门
        /// </summary>
        /// <param name="model">部门对象</param>
        /// <returns>结果对象</returns>
        public Model.ResultModel Update(Model.T_Department dept)
        {
            ResultModel rm = new ResultModel();

            Model.QueryDept qd = new QueryDept()
            {
                DeptName = dept.DeptName
            };
            var list = dal.Get(qd);

            if (list.Count > 0 && !list.Exists(l => l.Id == dept.Id))
            {
                rm.Result = false;
                rm.Message = "部门名称重复";
            }
            else
            {
                if (dal.Update(dept))
                {
                    rm.Result = true;
                    rm.Message = "部门更新成功";
                }
                else
                {
                    rm.Result = false;
                    rm.Message = "部门更新失败";
                }
            }
            return rm;
        }