Esempio n. 1
0
 private void FillDataSet(Dictionary <string, IEnumerable> data)
 {
     foreach (System.Data.DataTable dt in this.TemplateDataSet.Tables)
     {
         GenerateReportData.Generate(dt, data[dt.TableName], dt.TableName);
     }
 }
        void smMaster_DataLoading(object sender, DataLoadingEventArgs e)
        {
            e.Cancel = true;

            ISearchExpression    searchExpression = e.SearchExpression;
            IList <ISearchOrder> searchOrders     = e.SearchOrders;

            if (this.SearchManager != null)
            {
                for (int i = 0; i < m_reportDataInfos.Count; ++i)
                {
                    m_sms[i].EnablePage       = this.SearchManager.EnablePage;
                    m_sms[i].FirstResult      = this.SearchManager.FirstResult;
                    m_sms[i].MaxResult        = this.SearchManager.MaxResult;
                    m_sms[i].IsResultDistinct = this.SearchManager.IsResultDistinct;
                }
            }

            bool haveSetMasterSearchManager = false;

            for (int i = 0; i < m_reportDataInfos.Count; ++i)
            {
                object data = m_sms[i].GetData(searchExpression, searchOrders);
                System.Collections.IEnumerable dataList = data as System.Collections.IEnumerable;
                if (dataList == null)
                {
                    dataList = (data as System.Data.DataTable).DefaultView;
                }

                System.Data.DataTable dt = this.ReportViewer.TemplateDataSet.Tables[m_reportDataInfos[i].DatasetTableName];
                dt.Rows.Clear();
                GenerateReportData.Generate(dt, dataList, m_reportDataInfos[i].GridName);

                if (!haveSetMasterSearchManager)
                {
                    this.SearchManager.Count   = m_sms[i].GetCount(searchExpression);
                    haveSetMasterSearchManager = true;
                    this.SearchManager.OnDataLoaded(new DataLoadedEventArgs(m_sms[i].Result, m_sms[i].Count));
                }
            }

            // Set Parameter
            ReportGenerator.SetParameter(this.ReportViewer.CrystalHelper, searchExpression);

            if (m_reportInfo.AfterProcess != null)
            {
                ProcessInfoHelper.ExecuteProcess(ADInfoBll.Instance.GetProcessInfo(m_reportInfo.AfterProcess.Name),
                                                 new Dictionary <string, object> {
                    { "masterForm", this }
                });
            }

            this.ReportViewer.OpenReport();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportIdx"></param>
        /// <param name="data"></param>
        public void FillDataSet(int reportIdx, IEnumerable dataList)
        {
            if (reportIdx < 0 || reportIdx >= m_reportDataInfos.Count)
            {
                throw new ArgumentException("reportIdx");
            }
            string s = m_reportDataInfos[reportIdx].DatasetTableName;

            if (!m_dataSet.Tables.Contains(s))
            {
                throw new ArgumentException("报表DataSet中未包含名为" + s + "的DataTable!");
            }
            System.Data.DataTable dt = m_dataSet.Tables[s];
            dt.Rows.Clear();
            GenerateReportData.Generate(dt, dataList, m_reportDataInfos[reportIdx].GridName);
        }