public void BindGrid(int paramPageIndex, int paramPageSize) { string Begin = this.txtBegin.Value; string End = this.txtEnd.Value; string ProjectId = Request.Form["SelProjectId"]; string NickId = Request.Form["SelNickList"]; int WarehouseID = int.Parse(Request.Form["SelWarehouse"]); int ProvinceNameID = int.Parse(Request.Form["SelProvinceName"]); List <ProductSalesData> modifylist = new List <ProductSalesData>(); List <ProductSalesData> List = new List <ProductSalesData>(); List <int?> NickIdList = new List <int?>(); DateTime a = DateTime.Now; int no = 0; int? total = 0; if (!DateTime.TryParse(Begin, out a) || !DateTime.TryParse(End, out a)) { base.ShowMessage("开始时间或结束时间格式错误!"); return; } DateTime BeginDate = DateTime.Parse(Begin); DateTime EndDate = DateTime.Parse(End).AddDays(1).AddSeconds(-1); if (BeginDate > EndDate) { base.ShowMessage("开始时间不能大于结束时间!"); return; } if (NickId == "-1") { var nickList = base.XMOrderInfoAPIService.GetXMNickList("", 1, Convert.ToInt32(ProjectId)); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else if (NickId == "99") { var nickList = base.XMOrderInfoAPIService.GetXMNickListSS("", 1, Convert.ToInt32(ProjectId), HozestERPContext.Current.User.CustomerID, 0); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else { NickIdList.Add(int.Parse(NickId)); } var list = base.XMOrderInfoProductDetailsService.GetProductSales(BeginDate, EndDate, int.Parse(ProjectId), NickIdList, null, WarehouseID, ProvinceNameID); if (list != null) { foreach (var info in list) { if (info.ProductNum > 1) { int ProductNum = (int)info.ProductNum; info.ProductNum = 1; info.FactoryPrice = info.FactoryPrice / ProductNum; for (int i = 0; i < ProductNum; i++) { modifylist.Add(info); } } else if (info.ProductNum == 1) { modifylist.Add(info); } } Session["ProductSalesDataList"] = modifylist; total = modifylist.Sum(x => x.ProductNum == null ? 0 : x.ProductNum); TotalCount = total.ToString(); } var ProductSalesList = base.XMOrderInfoProductDetailsService.GetProductSales(BeginDate, EndDate, int.Parse(ProjectId), NickIdList, modifylist, WarehouseID, ProvinceNameID); var Group = ProductSalesList.GroupBy(x => new { x.ProductName }).ToList(); foreach (var Info in Group) { no++; decimal Cost = 0; StringBuilder table = new StringBuilder(); var InfoList = Info.OrderByDescending(x => x.ProductNum).ToList <ProductSalesData>(); int InfoCount = (int)InfoList.Sum(x => x.ProductNum); foreach (var info in InfoList) { string Proportion = Math.Round((decimal.Parse(info.ProductNum.ToString()) * 100 / decimal.Parse(InfoCount.ToString())), 2).ToString() + " %"; decimal cost = (decimal)info.ProductNum * decimal.Parse(info.FactoryPrice.ToString()); cost = Math.Round(cost, 2); table.Append("<tr>"); table.Append("<td style='text-align:center;'>").Append(info.Manufacturers).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.Specifications).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(Math.Round((decimal)info.FactoryPrice, 2)).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.ProductNum).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(cost).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(Proportion).Append("</td>"); table.Append("</tr>"); Cost += cost; } ProductSalesData one = new ProductSalesData(); one.ID = no; one.ProductName = InfoList[0].ProductName; one.Count = InfoCount; one.Cost = Cost.ToString(); one.CountProportion = Math.Round((decimal.Parse(one.Count.ToString()) * 100 / decimal.Parse(total.ToString())), 2).ToString() + " %"; one.Table = table.ToString(); List.Add(one); TotalCost = (decimal.Parse(TotalCost) + Cost).ToString(); TotalPercentage = (decimal.Parse(TotalPercentage.Replace(" %", "")) + decimal.Parse(one.CountProportion.Replace(" %", ""))).ToString() + " %"; } if (List != null && List.Count > 0) { List = List.OrderByDescending(x => x.Count).ToList(); } //分页 var PageList = new PagedList <ProductSalesData>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvContent, PageList, paramPageSize + 1); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ProductSales", "dataBind('" + ProjectId + "','" + NickId + "','" + WarehouseID + "','" + ProvinceNameID + "')", true);//ajax }
public void BindGrid(int paramPageIndex, int paramPageSize) { string Begin = this.txtBegin.Value; string End = this.txtEnd.Value; string PayBegin = this.txtPayBegin.Value; string PayEnd = this.txtPayEnd.Value; string ProjectId = Request.Form["SelProjectId"]; string NickId = Request.Form["SelNickList"]; int WaitNotice = this.chkWaitNotice.Checked == true ? 1 : 0; //等通知 int Urgent = this.chkUrgent.Checked == true ? 1 : 0; //加急 int CanDeliver = this.chkCanDeliver.Checked == true ? 1 : 0; //能发就发 int AppointDeliveryTime = this.chkAppointDeliveryTime.Checked == true ? 1 : 0; //预约发货时间 int Remarks = this.chkRemarks.Checked == true ? 1 : 0; //异常备注 List <ProductSalesData> modifylist = new List <ProductSalesData>(); List <ProductSalesData> List = new List <ProductSalesData>(); List <int?> NickIdList = new List <int?>(); int no = 0; int?total = 0; if (PayBegin == "" || PayEnd == "") { base.ShowMessage("付款开始时间和结束时间不能为空!"); Session["ProductSalesDataList"] = null; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "NotShippedSales", "dataBind('" + ProjectId + "','" + NickId + "')", true);//ajax this.gvContent.DataSource = null; this.gvContent.DataBind(); return; } DateTime PayBeginDate = DateTime.Parse(PayBegin); DateTime PayEndDate = DateTime.Parse(PayEnd).AddDays(1).AddSeconds(-1); if (AppointDeliveryTime == 1 && (Begin == "" || End == "")) { base.ShowMessage("预约发货开始时间和结束时间不能为空!"); Session["ProductSalesDataList"] = null; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "NotShippedSales", "dataBind('" + ProjectId + "','" + NickId + "')", true);//ajax this.gvContent.DataSource = null; this.gvContent.DataBind(); return; } if (NickId == "-1") { var nickList = base.XMOrderInfoAPIService.GetXMNickList("", 1, Convert.ToInt32(ProjectId)); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else if (NickId == "99") { var nickList = base.XMOrderInfoAPIService.GetXMNickListSS("", 1, Convert.ToInt32(ProjectId), HozestERPContext.Current.User.CustomerID, 0); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else { NickIdList.Add(int.Parse(NickId)); } var list = base.XMOrderInfoProductDetailsService.GetNotShippedSales(Begin, End, int.Parse(ProjectId), NickIdList, null, WaitNotice, Urgent, CanDeliver, AppointDeliveryTime, Remarks, PayBeginDate, PayEndDate); if (list != null) { foreach (var info in list) { if (info.ProductNum > 1) { int ProductNum = (int)info.ProductNum; info.ProductNum = 1; info.FactoryPrice = info.FactoryPrice / ProductNum; for (int i = 0; i < ProductNum; i++) { modifylist.Add(info); } } else if (info.ProductNum == 1) { modifylist.Add(info); } } Session["ProductSalesDataList"] = modifylist; total = modifylist.Sum(x => x.ProductNum == null ? 0 : x.ProductNum); TotalCount = total.ToString(); } var ProductSalesList = base.XMOrderInfoProductDetailsService.GetNotShippedSales(Begin, End, int.Parse(ProjectId), NickIdList, modifylist, WaitNotice, Urgent, CanDeliver, AppointDeliveryTime, Remarks, PayBeginDate, PayEndDate); var Group = ProductSalesList.GroupBy(x => new { x.ProductName }).ToList(); foreach (var Info in Group) { no++; decimal Cost = 0; StringBuilder table = new StringBuilder(); var InfoList = Info.OrderByDescending(x => x.ProductNum).ToList <ProductSalesData>(); int InfoCount = (int)InfoList.Sum(x => x.ProductNum); foreach (var info in InfoList) { string Proportion = Math.Round((decimal.Parse(info.ProductNum.ToString()) * 100 / decimal.Parse(InfoCount.ToString())), 2).ToString() + " %"; decimal cost = (decimal)info.ProductNum * decimal.Parse(info.FactoryPrice.ToString()); cost = Math.Round(cost, 2); table.Append("<tr>"); table.Append("<td style='text-align:center;'>").Append(info.Manufacturers).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.Specifications).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.FactoryPrice).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.ProductNum).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(cost).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(Proportion).Append("</td>"); table.Append("</tr>"); Cost += cost; } ProductSalesData one = new ProductSalesData(); one.ID = no; one.ProductName = InfoList[0].ProductName; one.Count = InfoCount; one.Cost = Cost.ToString(); one.CountProportion = Math.Round((decimal.Parse(one.Count.ToString()) * 100 / decimal.Parse(total.ToString())), 2).ToString() + " %"; one.Table = table.ToString(); List.Add(one); TotalCost = (decimal.Parse(TotalCost) + Cost).ToString(); TotalPercentage = (decimal.Parse(TotalPercentage.Replace(" %", "")) + decimal.Parse(one.CountProportion.Replace(" %", ""))).ToString() + " %"; } if (List != null && List.Count > 0) { List = List.OrderByDescending(x => x.Count).ToList(); } //分页 var PageList = new PagedList <ProductSalesData>(List, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvContent, PageList, paramPageSize + 1); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "NotShippedSales", "dataBind('" + ProjectId + "','" + NickId + "')", true);//ajax }
public void BindGrid(int paramPageIndex, int paramPageSize) { string ProjectId = Request.Form["SelProjectId"]; string NickId = Request.Form["SelNickList"]; string Begin = this.txtBegin.Value; string End = this.txtEnd.Value; int ApplicaType = int.Parse(this.ddlApplicaType.SelectedValue); bool GoodsNotConfirmSendOut = this.chkGoodsNotConfirmSendOut.Checked; bool GoodsConfirmSendOut = this.chkGoodsConfirmSendOut.Checked; bool GoodsConfirmReturn = this.chkGoodsConfirmReturn.Checked; Session["ApplicationSalesDataList"] = null; List <XMApplicationExchange> DataList = new List <XMApplicationExchange>(); List <ProductSalesData> ApplicationList = new List <ProductSalesData>(); List <int?> NickIdList = new List <int?>(); DateTime a = DateTime.Now; int no = 0; int? total = 0; if (!DateTime.TryParse(Begin, out a) || !DateTime.TryParse(End, out a)) { base.ShowMessage("开始时间或结束时间格式错误!"); return; } DateTime BeginDate = DateTime.Parse(Begin); DateTime EndDate = DateTime.Parse(End).AddDays(1).AddSeconds(-1); if (BeginDate > EndDate) { base.ShowMessage("开始时间不能大于结束时间!"); return; } if (NickId == "-1") { var nickList = base.XMOrderInfoAPIService.GetXMNickList("", 1, Convert.ToInt32(ProjectId)); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else if (NickId == "99") { var nickList = base.XMOrderInfoAPIService.GetXMNickListSS("", 1, Convert.ToInt32(ProjectId), HozestERPContext.Current.User.CustomerID, 0); foreach (XMNick info in nickList) { NickIdList.Add(info.nick_id); } } else { NickIdList.Add(int.Parse(NickId)); } var ApplicationExchangeList = base.XMApplicationExchangeService.GetApplicationExchangeSales(BeginDate, EndDate, ApplicaType, GoodsNotConfirmSendOut, GoodsConfirmSendOut, GoodsConfirmReturn, NickIdList); if (ApplicationExchangeList != null && ApplicationExchangeList.Count > 0) { foreach (var Info in ApplicationExchangeList) { if (Info.ProductNum > 1) { int ProductNum = (int)Info.ProductNum; Info.ProductNum = 1; Info.FactoryPrice = Info.FactoryPrice / ProductNum; for (int i = 0; i < ProductNum; i++) { DataList.Add(Info); } } else if (Info.ProductNum == 1) { DataList.Add(Info); } } Session["ApplicationSalesDataList"] = DataList; total = DataList.Sum(x => x.ProductNum == null ? 0 : x.ProductNum); TotalCount = total.ToString(); } var ArrangeDataList = base.XMApplicationExchangeService.GetApplicationExchangeSalesArrange(DataList); var Group = ArrangeDataList.GroupBy(x => new { x.ApplicaType, x.GoodsStatus, x.ProductName }).ToList(); foreach (var Info in Group) { no++; decimal Cost = 0; StringBuilder table = new StringBuilder(); var InfoList = Info.OrderByDescending(x => x.ProductNum).ToList <ProductSalesData>(); int InfoCount = (int)InfoList.Sum(x => x.ProductNum); foreach (var info in InfoList) { string Proportion = Math.Round((decimal.Parse(info.ProductNum.ToString()) * 100 / decimal.Parse(InfoCount.ToString())), 2).ToString() + " %"; decimal cost = (decimal)info.ProductNum * decimal.Parse(info.FactoryPrice.ToString()); cost = Math.Round(cost, 2); table.Append("<tr>"); table.Append("<td style='text-align:center;'>").Append(info.Manufacturers).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.Specifications).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(info.ProductNum).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(Math.Round((decimal)info.FactoryPrice, 2)).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(cost).Append("</td>"); table.Append("<td style='text-align:center;'>").Append(Proportion).Append("</td>"); table.Append("</tr>"); Cost += cost; } ProductSalesData one = new ProductSalesData(); one.ID = no; one.ProductName = InfoList[0].ProductName; one.Count = InfoCount; one.Cost = Cost.ToString(); one.CountProportion = Math.Round((decimal.Parse(one.Count.ToString()) * 100 / decimal.Parse(total.ToString())), 2).ToString() + " %"; one.Table = table.ToString(); one.ApplicaType = InfoList[0].ApplicaType; one.GoodsStatus = InfoList[0].GoodsStatus; ApplicationList.Add(one); TotalCost = (decimal.Parse(TotalCost) + Cost).ToString(); TotalPercentage = (decimal.Parse(TotalPercentage.Replace(" %", "")) + decimal.Parse(one.CountProportion.Replace(" %", ""))).ToString() + " %"; } if (ApplicationList != null && ApplicationList.Count > 0) { ApplicationList = ApplicationList.OrderByDescending(x => x.Count).ToList(); } //分页 var PageList = new PagedList <ProductSalesData>(ApplicationList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString()); this.Master.BindData(this.gvContent, PageList, paramPageSize + 1); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ApplicationSales", "dataBind('" + ProjectId + "','" + NickId + "')", true);//ajax }