コード例 #1
0
ファイル: Report.aspx.cs プロジェクト: dhiren-rsmart/SY-WC
        /// <summary>
        /// This is the mainfunction which used to load the report to the report viewer.
        /// </summary>
        /// <param name="param">Contains perameter key value collectionfor perameterized report. It's default value is null.</param>
        public void GenerateReport()
        {
            smARTRptViewer.LocalReport.ReportPath = MapPath("/Content/Reports/GeneralReports/" + _reportFilter.ReportName);

            conRCM.SelectCommand = _reportFilter.SP_Name;

            List <String> strParameters = new List <String>(_reportFilter.Parameters.Split(','));

            //conRCM.SelectParameters.Add("FromDate", _reportFilter.FromDate.ToString());
            //conRCM.SelectParameters.Add("ToDate", _reportFilter.ToDate.ToString());
            //conRCM.SelectParameters.Add("PartyID", _reportFilter.PartyID.ToString());

            ReportDataSource reportDataSource = new ReportDataSource(_reportFilter.DataSet_Name, conRCM);

            smARTRptViewer.LocalReport.DataSources.Clear();
            smARTRptViewer.LocalReport.EnableExternalImages = true;

            if (strParameters.Count > 0)
            {
                List <ReportParameter> parameters = new List <ReportParameter>();

                foreach (string param in strParameters)
                {
                    string paramValue = Convert.ToString(ReportFilter.GetPropValue(_reportFilter, param)).Trim();
                    if (string.IsNullOrEmpty(paramValue))
                    {
                        paramValue = " ";
                    }
                    conRCM.SelectParameters.Add(param, paramValue);
                    ReportParameter rptParam = new ReportParameter(param, paramValue);
                    parameters.Add(rptParam);
                }
                smARTRptViewer.LocalReport.SetParameters(parameters);
            }

            if (!string.IsNullOrEmpty(_reportFilter.SubReportInfo))
            {
                smARTRptViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
            }

            smARTRptViewer.LocalReport.DataSources.Add(reportDataSource);
            //ReportDataSource subReportDataSource = new ReportDataSource(_reportFilter.DataSet_Name, conRCM1);
            //conRCM1.SelectCommand = "TestSubReport";
        }