private void btnCreateReport_Click(object sender, System.EventArgs e)
        {
            OrderStatisticsInfo distributorStatisticsNoPage = DistributorHelper.GetDistributorStatisticsNoPage(new SaleStatisticsQuery
            {
                StartDate = this.dateStart,
                EndDate   = this.dateEnd,
                PageSize  = this.pager.PageSize,
                SortBy    = "SaleTotals",
                SortOrder = SortAction.Desc
            });

            System.Data.DataTable orderTbl = distributorStatisticsNoPage.OrderTbl;
            string text = string.Empty;

            text += "排行,分销商名称,交易量,交易金额,利润\r\n";
            foreach (System.Data.DataRow dataRow in orderTbl.Rows)
            {
                if (System.Convert.ToDecimal(dataRow["SaleTotals"]) > 0m)
                {
                    text += dataRow["IndexId"].ToString();
                }
                else
                {
                    text = (text ?? "");
                }
                text  = text + "," + dataRow["UserName"].ToString();
                text  = text + "," + dataRow["PurchaseOrderCount"].ToString();
                text  = text + "," + dataRow["SaleTotals"].ToString();
                text  = text + "," + dataRow["Profits"].ToString();
                text += "\r\n";
            }
            this.Page.Response.Clear();
            this.Page.Response.Buffer  = false;
            this.Page.Response.Charset = "GB2312";
            this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=DistributorRanking.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();
        }
        private void btnCreateReport_Click(object sender, EventArgs e)
        {
            SaleStatisticsQuery query = new SaleStatisticsQuery();

            query.StartDate = this.dateStart;
            query.EndDate   = this.dateEnd;
            query.PageSize  = this.pager.PageSize;
            query.SortBy    = "SaleTotals";
            query.SortOrder = SortAction.Desc;
            DataTable orderTbl = DistributorHelper.GetDistributorStatisticsNoPage(query).OrderTbl;
            string    s        = string.Empty + "排行,分销商名称,交易量,交易金额,利润\r\n";

            foreach (DataRow row in orderTbl.Rows)
            {
                if (Convert.ToDecimal(row["SaleTotals"]) > 0M)
                {
                    s = s + row["IndexId"].ToString();
                }
                else
                {
                    s = s ?? "";
                }
                s = s + "," + row["UserName"].ToString();
                s = s + "," + row["PurchaseOrderCount"].ToString();
                s = s + "," + row["SaleTotals"].ToString();
                s = s + "," + row["Profits"].ToString();
                s = s + "\r\n";
            }
            this.Page.Response.Clear();
            this.Page.Response.Buffer  = false;
            this.Page.Response.Charset = "GB2312";
            this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=DistributorRanking.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();
        }