Пример #1
0
        private void BindData()
        {
            DataTable tb = SPDayReportWrapper.GetClientGroupDayReport(StartDate.Date, EndDate.Date, ClientGroupID);

            DataTable rtp = tb.Clone();

            foreach (DataRow row in tb.Rows)
            {
                if (row["ClientGroupID"] != System.DBNull.Value)
                {
                    int clientGroupID = (int)row["ClientGroupID"];

                    if (clientGroupID == ClientGroupID)
                    {
                        rtp.ImportRow(row);
                    }
                }
            }
            rtp.AcceptChanges();

            rtp.Columns.Add("CodeName");
            rtp.Columns.Add("Price", typeof(decimal));
            rtp.Columns.Add("Amount", typeof(decimal));

            rtp.AcceptChanges();

            foreach (DataRow row in rtp.Rows)
            {
                int channleClientID = (int)row["ChannleClientID"];
                int recordCount     = (int)row["RecordCount"];

                SPClientChannelSettingWrapper clientChannelSetting =
                    SPClientChannelSettingWrapper.FindById(channleClientID);

                row.BeginEdit();
                row["CodeName"] = clientChannelSetting.ClinetID.Alias;
                row["Price"]    = clientChannelSetting.ClinetID.Price;
                row["Amount"]   = clientChannelSetting.ClinetID.Price * recordCount;
                row.EndEdit();
            }

            rtp.AcceptChanges();

            SPClientGroupWrapper clientGroup = SPClientGroupWrapper.FindById(ClientGroupID);

            string reportName = string.Format("下家组【{2}】 【{0}】-【{1}】结算报表", StartDate.ToString("yyyy-MM-dd"), EndDate.ToString("yyyy-MM-dd"), clientGroup.Name);


            ReportDataSource rds = new ReportDataSource("DataSet1", rtp);

            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);

            SPClientGroupWrapper clientGroupWrapper = SPClientGroupWrapper.FindById(ClientGroupID);


            ReportParameter rpName = new ReportParameter();

            rpName.Name = "ReportName";
            rpName.Values.Add(reportName);



            ReportViewer1.LocalReport.SetParameters(
                new ReportParameter[] { rpName });



            ReportViewer1.LocalReport.Refresh();
        }