private void btnCreateReport_Click(object sender, EventArgs e) { SaleStatisticsQuery productSale = new SaleStatisticsQuery(); productSale.StartDate = this.dateStart; productSale.EndDate = this.dateEnd; productSale.PageSize = this.pager.PageSize; productSale.SortBy = "ProductSaleCounts"; productSale.SortOrder = SortAction.Desc; int totalProductSales = 0; DataTable distributionProductSalesNoPage = DistributorHelper.GetDistributionProductSalesNoPage(productSale, out totalProductSales); string s = ((string.Empty + "排行" + ",商品名称") + ",商家编码" + ",销售量") + ",销售额" + ",利润\r\n"; foreach (DataRow row in distributionProductSalesNoPage.Rows) { s = s + row["IDOfSaleTotals"].ToString(); s = s + "," + row["ProductName"].ToString(); s = s + "," + row["SKU"].ToString(); s = s + "," + row["ProductSaleCounts"].ToString(); s = s + "," + row["ProductSaleTotals"].ToString(); s = s + "," + row["ProductProfitsTotals"].ToString() + "\r\n"; } this.Page.Response.Clear(); this.Page.Response.Buffer = false; this.Page.Response.Charset = "GB2312"; this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=ProductSaleRanking.csv"); this.Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312"); this.Page.Response.ContentType = "application/octet-stream"; this.Page.EnableViewState = false; this.Page.Response.Write(s); this.Page.Response.End(); }
private void btnCreateReport_Click(object sender, System.EventArgs e) { SaleStatisticsQuery saleStatisticsQuery = new SaleStatisticsQuery(); saleStatisticsQuery.StartDate = this.dateStart; saleStatisticsQuery.EndDate = this.dateEnd; saleStatisticsQuery.PageSize = this.pager.PageSize; saleStatisticsQuery.SortBy = "ProductSaleCounts"; saleStatisticsQuery.SortOrder = SortAction.Desc; int num = 0; System.Data.DataTable distributionProductSalesNoPage = DistributorHelper.GetDistributionProductSalesNoPage(saleStatisticsQuery, out num); string text = string.Empty; text += "排行"; text += ",商品名称"; text += ",商家编码"; text += ",销售量"; text += ",销售额"; text += ",利润\r\n"; foreach (System.Data.DataRow dataRow in distributionProductSalesNoPage.Rows) { text += dataRow["IDOfSaleTotals"].ToString(); text = text + "," + dataRow["ProductName"].ToString(); text = text + "," + dataRow["SKU"].ToString(); text = text + "," + dataRow["ProductSaleCounts"].ToString(); text = text + "," + dataRow["ProductSaleTotals"].ToString(); text = text + "," + dataRow["ProductProfitsTotals"].ToString() + "\r\n"; } this.Page.Response.Clear(); this.Page.Response.Buffer = false; this.Page.Response.Charset = "GB2312"; this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=ProductSaleRanking.csv"); this.Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); this.Page.Response.ContentType = "application/octet-stream"; this.Page.EnableViewState = false; this.Page.Response.Write(text); this.Page.Response.End(); }