示例#1
0
        /// <summary>
        /// 复杂查询
        /// </summary>
        /// <param name="model">查询对象</param>
        /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param>
        /// <param name="PageSize">每页行数,默认15</param>
        /// <param name="PageIndex">当前页码,默认100</param>
        /// <returns></returns>
        public DataGrid <T_AgreeListModel> Search(T_AgreeListModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100)
        {
            Expression <Func <T_AgreeList, bool> > where = null;                   //最终查询条件
            var lambdaList = new List <Expression <Func <T_AgreeList, bool> > >(); //lambda查询条件集合
            int total      = 0;                                                    //总行数

            if (model.ProjectId != null && model.ProjectId > 0)
            {
                lambdaList.Add(c => c.ProjectId == model.ProjectId);
            }
            if (model.AgreeId != null && model.AgreeId > 0)
            {
                lambdaList.Add(c => c.AgreeId == model.AgreeId);
            }
            if (model.CategoryId != null && model.CategoryId > 0)
            {
                T_SysListBLL syslist = new T_SysListBLL();
                List <int>   childer = syslist.GetChildren(1, (int)model.CategoryId);
                lambdaList.Add(c => childer.Contains((int)c.CategoryId));
            }
            //将集合表达式树转换成Expression表达式树
            MyVisitor <T_AgreeList, T_AgreeList> visitor = new MyVisitor <T_AgreeList, T_AgreeList>();

            where = visitor.Modify(lambdaList);
            var list   = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList();
            var result = new DataGrid <T_AgreeListModel>()
            {
                rows  = list,
                total = total
            };

            return(result);
        }
示例#2
0
        public static T_AgreeListModel DTO(this T_AgreeList node)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new T_AgreeListModel()
            {
                Id          = node.Id,
                AgreeId     = node.AgreeId,
                CategoryId  = node.CategoryId,
                Category    = node.Category,
                Cost        = node.Cost,
                CostId      = node.CostId,
                Description = node.Description,
                Price       = node.Price,
                ProjectId   = node.ProjectId,
                Qty         = node.Qty,
                Uom         = node.Uom,
                Profit      = node.Profit,
            };

            if (model.Price > 0)
            {
                model.CostMarkup = Math.Round((decimal)((model.Price - model.Cost) / model.Price) * 100, 2);
            }
            else
            {
                model.CostMarkup = 0;
            }
            model.TotalPrice = Math.Round((decimal)(model.Qty * model.Price), 2);
            model.TotalCost  = Math.Round((decimal)(model.Qty * model.Cost), 2);
            return(model);
        }
示例#3
0
 public static T_AgreeList ToModel(this  T_AgreeListModel node)
 {
     return(new T_AgreeList()
     {
         Id = node.Id,
         AgreeId = node.AgreeId,
         CategoryId = node.CategoryId,
         Category = node.Category,
         Cost = node.Cost,
         CostId = node.CostId,
         Description = node.Description,
         Price = node.Price,
         ProjectId = node.ProjectId,
         Qty = node.Qty,
         Uom = node.Uom,
         Profit = node.Profit,
     });
 }
示例#4
0
 public int DeleteData(T_AgreeListModel model)
 {
     return(this.Delete(model.Id));
 }
示例#5
0
 public int EditData(T_AgreeListModel model)
 {
     return(this.Edit(model.ToModel()));
 }
示例#6
0
 public int AddData(T_AgreeListModel model)
 {
     return(this.Add(model.ToModel()));
 }