protected void RGFundsPaymentDays_OnNeedDataSource(object source, GridNeedDataSourceEventArgs e) { var listResult = (from filialeInfo in _filiales let list = _wasteBookDao.GetFundPaymentDaysInfos(GlobalConfig.KeepYear, Year, filialeInfo.ID, string.Empty) where list != null && list.Count > 0 select new FundPaymentDaysInfo { SaleFilialeId = filialeInfo.ID, SaleFilialeName = filialeInfo.Name, Jan = list.Sum(s => s.Jan), Feb = list.Sum(s => s.Feb), Mar = list.Sum(s => s.Mar), Apr = list.Sum(s => s.Apr), May = list.Sum(s => s.May), Jun = list.Sum(s => s.Jun), July = list.Sum(s => s.July), Aug = list.Sum(s => s.Aug), Sept = list.Sum(s => s.Sept), Oct = list.Sum(s => s.Oct), Nov = list.Sum(s => s.Nov), December = list.Sum(s => s.December), MaxJan = list.Sum(s => s.MaxJan), MaxFeb = list.Sum(s => s.MaxFeb), MaxMar = list.Sum(s => s.MaxMar), MaxApr = list.Sum(s => s.MaxApr), MaxMay = list.Sum(s => s.MaxMay), MaxJun = list.Sum(s => s.MaxJun), MaxJuly = list.Sum(s => s.MaxJuly), MaxAug = list.Sum(s => s.MaxAug), MaxSept = list.Sum(s => s.MaxSept), MaxOct = list.Sum(s => s.MaxOct), MaxNov = list.Sum(s => s.MaxNov), MaxDecember = list.Sum(s => s.MaxDecember), Year = Year }).ToList(); //list = // list.Where( // w => // w.Jan != 0 || w.Feb != 0 || w.Mar != 0 || w.Apr != 0 || w.May != 0 || w.Jun != 0 || w.July != 0 || // w.Aug != 0 || w.Sept != 0 || w.Oct != 0 || w.Nov != 0 || w.December != 0).ToList(); ShowFooterTotalText(listResult); var month = DateTime.Now.Month; switch (month) { case 1: listResult = listResult.OrderByDescending(o => o.Jan).ToList(); break; case 2: listResult = listResult.OrderByDescending(o => o.Feb).ToList(); break; case 3: listResult = listResult.OrderByDescending(o => o.Mar).ToList(); break; case 4: listResult = listResult.OrderByDescending(o => o.Apr).ToList(); break; case 5: listResult = listResult.OrderByDescending(o => o.May).ToList(); break; case 6: listResult = listResult.OrderByDescending(o => o.Jun).ToList(); break; case 7: listResult = listResult.OrderByDescending(o => o.July).ToList(); break; case 8: listResult = listResult.OrderByDescending(o => o.Aug).ToList(); break; case 9: listResult = listResult.OrderByDescending(o => o.Sept).ToList(); break; case 10: listResult = listResult.OrderByDescending(o => o.Oct).ToList(); break; case 11: listResult = listResult.OrderByDescending(o => o.Nov).ToList(); break; case 12: listResult = listResult.OrderByDescending(o => o.December).ToList(); break; } RGFundsPaymentDays.DataSource = listResult; }
/// <summary> /// 获取公司资金数据列表 /// </summary> /// <param name="keepyear"></param> /// <param name="year"></param> /// <param name="saleFilialeId"></param> /// <param name="bankName"></param> /// <returns></returns> public IList <FundPaymentDaysInfo> GetFundPaymentDaysInfos(int keepyear, int year, Guid saleFilialeId, string bankName) { var fundPaymentDaysInfoList = new List <FundPaymentDaysInfo>(); var lastFundInfoList = _wasteBookDao.GetFundPaymentDaysBankInfos(keepyear, saleFilialeId, year, bankName); //期末余额 var inFundInfoList = _wasteBookDao.GetFundPaymentDaysInfos(keepyear, year, saleFilialeId, bankName); //收款情况list if ((lastFundInfoList == null || lastFundInfoList.Count == 0) && (inFundInfoList == null || inFundInfoList.Count == 0)) { return(fundPaymentDaysInfoList); //都没有结果 } if ((lastFundInfoList != null && lastFundInfoList.Count > 0) && (inFundInfoList == null || inFundInfoList.Count == 0))//期末余额有 { fundPaymentDaysInfoList.AddRange( lastFundInfoList.Select(fundPaymentDaysInfo => new FundPaymentDaysInfo { BankName = fundPaymentDaysInfo.BankName, BankAccountsId = fundPaymentDaysInfo.BankAccountsId, MaxJan = fundPaymentDaysInfo.MaxJan, MaxFeb = fundPaymentDaysInfo.MaxFeb, MaxMar = fundPaymentDaysInfo.MaxMar, MaxApr = fundPaymentDaysInfo.MaxApr, MaxMay = fundPaymentDaysInfo.MaxMay, MaxJun = fundPaymentDaysInfo.MaxJun, MaxJuly = fundPaymentDaysInfo.MaxJuly, MaxAug = fundPaymentDaysInfo.MaxAug, MaxSept = fundPaymentDaysInfo.MaxSept, MaxOct = fundPaymentDaysInfo.MaxOct, MaxNov = fundPaymentDaysInfo.MaxNov, MaxDecember = fundPaymentDaysInfo.MaxDecember })); return(fundPaymentDaysInfoList); } if ((lastFundInfoList == null || lastFundInfoList.Count == 0) && (inFundInfoList != null && inFundInfoList.Count > 0))//有收款 { fundPaymentDaysInfoList.AddRange( inFundInfoList.Select(fundPaymentDaysInfo => new FundPaymentDaysInfo { BankName = fundPaymentDaysInfo.BankName, BankAccountsId = fundPaymentDaysInfo.BankAccountsId, Jan = fundPaymentDaysInfo.Jan, Feb = fundPaymentDaysInfo.Feb, Mar = fundPaymentDaysInfo.Mar, Apr = fundPaymentDaysInfo.Apr, May = fundPaymentDaysInfo.May, Jun = fundPaymentDaysInfo.Jun, July = fundPaymentDaysInfo.July, Aug = fundPaymentDaysInfo.Aug, Sept = fundPaymentDaysInfo.Sept, Oct = fundPaymentDaysInfo.Oct, Nov = fundPaymentDaysInfo.Nov, December = fundPaymentDaysInfo.December })); return(fundPaymentDaysInfoList); } if (lastFundInfoList != null && lastFundInfoList.Count > 0 && inFundInfoList != null)//都有 { var newFundPaymentDaysInfoList = new List <FundPaymentDaysInfo>(); newFundPaymentDaysInfoList.AddRange( lastFundInfoList.Select(fundPaymentDaysInfo => new FundPaymentDaysInfo { BankName = fundPaymentDaysInfo.BankName, BankAccountsId = fundPaymentDaysInfo.BankAccountsId, MaxJan = fundPaymentDaysInfo.MaxJan, MaxFeb = fundPaymentDaysInfo.MaxFeb, MaxMar = fundPaymentDaysInfo.MaxMar, MaxApr = fundPaymentDaysInfo.MaxApr, MaxMay = fundPaymentDaysInfo.MaxMay, MaxJun = fundPaymentDaysInfo.MaxJun, MaxJuly = fundPaymentDaysInfo.MaxJuly, MaxAug = fundPaymentDaysInfo.MaxAug, MaxSept = fundPaymentDaysInfo.MaxSept, MaxOct = fundPaymentDaysInfo.MaxOct, MaxNov = fundPaymentDaysInfo.MaxNov, MaxDecember = fundPaymentDaysInfo.MaxDecember })); fundPaymentDaysInfoList = newFundPaymentDaysInfoList; foreach (var fundPaymentDaysInfo in inFundInfoList) { var bankId = newFundPaymentDaysInfoList.FirstOrDefault(f => f.BankAccountsId == fundPaymentDaysInfo.BankAccountsId); if (bankId != null) { bankId.Jan = fundPaymentDaysInfo.Jan; bankId.Feb = fundPaymentDaysInfo.Feb; bankId.Mar = fundPaymentDaysInfo.Mar; bankId.Apr = fundPaymentDaysInfo.Apr; bankId.May = fundPaymentDaysInfo.May; bankId.Jun = fundPaymentDaysInfo.Jun; bankId.July = fundPaymentDaysInfo.July; bankId.Aug = fundPaymentDaysInfo.Aug; bankId.Sept = fundPaymentDaysInfo.Sept; bankId.Oct = fundPaymentDaysInfo.Oct; bankId.Nov = fundPaymentDaysInfo.Nov; bankId.December = fundPaymentDaysInfo.December; } else { bankId = new FundPaymentDaysInfo { BankName = fundPaymentDaysInfo.BankName, BankAccountsId = fundPaymentDaysInfo.BankAccountsId, Jan = fundPaymentDaysInfo.Jan, Feb = fundPaymentDaysInfo.Feb, Mar = fundPaymentDaysInfo.Mar, Apr = fundPaymentDaysInfo.Apr, May = fundPaymentDaysInfo.May, Jun = fundPaymentDaysInfo.Jun, July = fundPaymentDaysInfo.July, Aug = fundPaymentDaysInfo.Aug, Sept = fundPaymentDaysInfo.Sept, Oct = fundPaymentDaysInfo.Oct, Nov = fundPaymentDaysInfo.Nov, December = fundPaymentDaysInfo.December }; } var fundInfo = fundPaymentDaysInfoList.FirstOrDefault(f => f.BankAccountsId == bankId.BankAccountsId); if (fundInfo != null) { fundPaymentDaysInfoList.Remove(fundInfo); } fundPaymentDaysInfoList.Add(bankId); } } return(fundPaymentDaysInfoList); }