public SettlementInfoList SettlementInfoDataBind(SettlementInfoParam param)
        {
            if (param.StartTime == null)
            {
                param.StartTime = DateTime.Parse(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + " " + "00:00");
            }
            if (param.EndTime == null)
            {
                param.EndTime = DateTime.Parse(DateTime.Now.AddDays(+1).ToString("yyyy-MM-dd") + " " + "00:00");
            }

            var model = new SettlementInfoList()
            {
                FilterModel = new SettlementInfoParam
                {
                    Page             = param.Page,
                    PageSize         = param.PageSize,
                    CustomerCode     = param.CustomerCode,
                    StartTime        = param.StartTime,
                    EndTime          = param.EndTime,
                    CreatedBy        = param.CreatedBy,
                    Status           = param.Status,
                    SettlementBy     = param.SettlementBy,
                    SettlementNumber = param.SettlementNumber
                },
                PagedList = _settlementService.GetSettlementInfoList(param)
            };


            //结清状态
            model.PagedList.InnerList.ForEach(a => a.StatusDesc = Settlement.GetStatusDescription(a.Status));



            //状态下拉框
            var statusList = new List <SelectListItem> {
                new SelectListItem {
                    Value = "", Text = "全部", Selected = !model.FilterModel.Status.HasValue
                }
            };

            Settlement.GetStatusList().ForEach(a => statusList.Add(
                                                   new SelectListItem {
                Text = a.TextField, Value = a.ValueField, Selected = param.Status.HasValue && a.ValueField == param.Status.Value.ToString()
            }
                                                   ));

            model.StatusList = statusList;


            return(model);
        }
Ejemplo n.º 2
0
        public IPagedList <SettlementInfoExt> GetSettlementInfoList(SettlementInfoParam param)
        {
            var ctx = new LMS_DbContext();

            //query only
            ctx.Configuration.AutoDetectChangesEnabled = false;
            ctx.Configuration.LazyLoadingEnabled       = false;
            Check.Argument.IsNotNull(ctx, "数据库对象");

            var numberList = new List <string>();

            if (!string.IsNullOrEmpty(param.SettlementNumber))
            {
                numberList =
                    param.SettlementNumber.Split(Environment.NewLine.ToCharArray(),
                                                 StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            Expression <Func <SettlementInfo, bool> > filter = o => true;

            if (numberList.Any())
            {
                filter = filter.And(a => numberList.Contains(a.SettlementNumber));
            }
            else
            {
                //取当天记录
                if (param.StartTime.HasValue && param.EndTime.HasValue)
                {
                    if (param.StartTime == param.EndTime)
                    {
                        param.EndTime = param.EndTime.Value.AddHours(23).AddMinutes(59);
                    }
                }

                filter = filter.AndIf(a => a.CustomerCode.Contains(param.CustomerCode),
                                      !string.IsNullOrEmpty(param.CustomerCode))
                         .AndIf(a => param.StartTime <= a.CreatedOn && a.CreatedOn <= param.EndTime,
                                param.StartTime.HasValue && param.EndTime.HasValue)
                         .AndIf(a => a.Status == param.Status, param.Status.HasValue)
                         .AndIf(a => a.CreatedBy.Contains(param.CreatedBy), !string.IsNullOrEmpty(param.CreatedBy))
                         .AndIf(a => a.SettlementBy.Contains(param.SettlementBy),
                                !string.IsNullOrEmpty(param.SettlementBy));
            }



            var result = from a in ctx.SettlementInfos.Where(filter)
                         join b in ctx.Customers on a.CustomerCode equals b.CustomerCode into g
                         from c in g.DefaultIfEmpty()
                         orderby a.CreatedOn descending
                         select new SettlementInfoExt
            {
                SettlementNumber  = a.SettlementNumber,
                CustomerName      = c.Name,
                CustomerCode      = a.CustomerCode,
                TotalNumber       = a.TotalNumber,
                TotalSettleWeight = a.TotalSettleWeight,
                TotalFee          = a.TotalFee,
                CreatedBy         = a.CreatedBy,
                CreatedOn         = a.CreatedOn,
                Status            = a.Status,
                SettlementBy      = a.SettlementBy,
                SettlementOn      = a.SettlementOn
            };

            return(result.ToPagedList(param.Page, param.PageSize));
        }
Ejemplo n.º 3
0
 public IPagedList <SettlementInfoExt> GetSettlementInfoList(SettlementInfoParam param)
 {
     return(_settlementInfoRepository.GetSettlementInfoList(param));
 }
 /// <summary>
 /// 查看结算清单
 /// add bu yungchu
 /// </summary>
 /// <returns></returns>
 public ActionResult SettlementInfoList(SettlementInfoParam param)
 {
     return(View(SettlementInfoDataBind(param)));
 }