/// <summary> /// Change1:新增报表的total列的统计您信息。2014年2月10日10:46:43 /// </summary> /// <param name="model"></param> /// <returns></returns> public ChannelReportWithStatisModel GetSaleReprotByChannelList(ReportsModel model) { using (PermaisuriCMSEntities db = new PermaisuriCMSEntities()) { var adapter = (IObjectContextAdapter)db; var objectContext = adapter.ObjectContext; objectContext.CommandTimeout = 3 * 60; // value in seconds ChannelReportWithStatisModel reportModel = new ChannelReportWithStatisModel(); List <ChannelReportModel> list = new List <ChannelReportModel>(); String OrderType = "asc"; String OrderBy = "UnitsSold"; if (model.OrderType > 0) { OrderType = "desc"; } if (model.OrderBy > 0) { switch (model.OrderBy) { case 1: //order by Channel OrderBy = "ChannelName"; break; case 2: //order by Sales Totals OrderBy = "SalesTotal"; break; case 3: // order by Units Sold OrderBy = "UnitsSold"; break; case 4: // order by Avg. Sale Amount OrderBy = "AvgAmont"; break; default: OrderBy = "UnitsSold"; break; } } var countParam = new System.Data.Entity.Core.Objects.ObjectParameter("count", typeof(int));//注意,第一个参数count名称必须与Store Procedure里面的输出参数的名称一一对应!不区分大小写 var SumSalesTotalParam = new ObjectParameter("SumSalesTotal", typeof(int)); var SumUnitsSoldParam = new ObjectParameter("SumUnitsSold", typeof(int)); var SumAvgAmontParam = new ObjectParameter("SumAvgAmont", typeof(int)); var res = db.Ecom_ReportByChannel_SP(model.page, model.rows, model.Channel, model.Brand, model.StartTime, model.EndTime, OrderBy, OrderType, countParam, SumSalesTotalParam, SumUnitsSoldParam, SumAvgAmontParam).ToList(); //count = Convert.ToInt32(countParam.Value); reportModel.Count = Convert.ToInt32(countParam.Value); reportModel.SumSalesTotal = Convert.ToInt32(SumSalesTotalParam.Value).ToString("C", new CultureInfo("en-US")); reportModel.SumUnitsSold = Convert.ToInt32(SumUnitsSoldParam.Value); reportModel.SumAvgAmont = Convert.ToInt32(SumAvgAmontParam.Value).ToString("C", new CultureInfo("en-US")); foreach (Ecom_ReportByChannel_SP_Result r in res) { list.Add(new ChannelReportModel { Channel = r.ChannelName, ChannelID = r.ChannelID, SalesTotal = r.SalesTotal.ConvertToNotNull().ToString("C", new CultureInfo("en-US")), UnitsSold = r.UnitsSold.ConvertToNotNull(), AvgAmont = r.AvgAmont.ConvertToNotNull().ToString("C", new CultureInfo("en-US")) }); } reportModel.ReportList = list; return(reportModel); } }