public ActionResult ViewCommissionLogDetail() { string type = string.Empty; if (Request["type"] != null) { type = Request["type"].ToString(); } List <int> sysnoList = new List <int>(); if (Request["Data"] != null && Request["Data"].ToString() != "") { foreach (var item in Request["Data"].ToString().Split(',')) { sysnoList.Add(int.Parse(item)); } } string brandCategory = string.Empty; if (Request["brandCategory"] != null) { brandCategory = Request["brandCategory"].ToString(); } List <CommissionItemLogDetailInfo> data = SettleService.QueryCommissionLogDetail(UserAuthHelper.GetCurrentUser().SellerSysNo, type, sysnoList); if (string.IsNullOrEmpty(type) || data == null) { return(View()); } int soCount = (from x in data where x.ReferenceType.Trim().ToUpper() == OrdersType.SO group x by x.ReferenceSysNo into g select g).Count(); int rmaCount = (from x in data where x.ReferenceType.Trim().ToUpper() == OrdersType.RMA group x by x.ReferenceSysNo into g select g).Count(); FillDataSource(data); switch ((CommissionType)Enum.Parse(typeof(CommissionType), type.ToUpper())) { case CommissionType.SAC: { ViewBag.SACData = data; var totalAmtSO = data.FindAll(x => { return(x.ReferenceType.Trim().ToUpper() == OrdersType.SO); }).Sum(x => { return(x.Qty * x.Price); }); var totalAmtRMA = data.FindAll(x => { return(x.ReferenceType.Trim().ToUpper() == OrdersType.RMA); }).Sum(x => { return(x.Qty * x.Price); }); decimal totalPromotionDiscount = data.Where(x => x.PromotionDiscount.HasValue).Sum(x => x.PromotionDiscount.Value * x.Qty); totalPromotionDiscount = Math.Round(totalPromotionDiscount, 2); ViewBag.StatisticalInformation = string.Format("代理品类:{0},销售金额总计:{1}元", brandCategory, (totalAmtSO + totalAmtRMA + totalPromotionDiscount).ToString("f2")); break; } case CommissionType.SOC: { ViewBag.SOCData = data; ViewBag.StatisticalInformation = string.Format("代理品类:{0},销售订单数:{1};退货单数:{2}", brandCategory, soCount, rmaCount); break; } case CommissionType.DEF: { ViewBag.DEFData = data; ViewBag.StatisticalInformation = string.Format("代理品类:{0},销售订单数:{1};", brandCategory, soCount); break; } default: break; } return(View()); }