Example #1
0
 public void Testasd()
 {
     DataTable dt = new DataTable();
     dt.Columns.Add("Id");
     dt.Rows.Add(1);
     ReportGenerator root = new ReportGenerator(dt, new Option<string>() { GroupName = "RefId",Value="RefId" },"Father");
     var son = root.AddSubReport(new Option<string>() { GroupName = "Son", Value = "Son" }, "Son");
     var grandson = root.AddSubReport(new Option<string>() { GroupName = "Grandson", Value = "Grandson" }, "Grandson");
     root.GenerateReport();
     son.DropReport();
 }
Example #2
0
 public void Dispose()
 {
     CutEventOff();
     this.CurrentReport     = null;
     this._dataSource       = null;
     this._groupName        = null;
     this._preReport        = null;
     this.SelectedDataRange = null;
     this.SubReport         = null;
     GC.Collect();
 }
Example #3
0
        public ReportGenerator(DataTable dataSource, Option <string> groupName, string reportName = null) : this(reportName)
        {
            if (dataSource == null || dataSource.Rows.Count == 0)
            {
                throw new ArgumentNullException("dataSource");
            }

            this._preReport    = null;
            this._dataSource   = dataSource;
            this._groupName    = groupName;
            this._isRootReport = true;

            GenerateReport();
        }
Example #4
0
 public void  ChangePreReport(ReportGenerator preReport, DataTable dataSource)
 {
     if (preReport == null)
     {
         throw new ArgumentNullException("preReport");
     }
     if (this._preReport != null)
     {
         this.CurrentReportDestroying -= _preReport.DropSubReport;
     }
     this._preReport = preReport;
     this.CurrentReportDestroying += _preReport.DropSubReport;
     this._dataSource              = dataSource;
     GenerateReport();
 }
Example #5
0
        public ReportGenerator(DataTable dataSource, Option<string> groupName, string reportName = null)
            : this(reportName)
        {
            if (dataSource == null || dataSource.Rows.Count == 0)
            {
                throw new ArgumentNullException("dataSource");
            }

            this._preReport = null;
            this._dataSource = dataSource;
            this._groupName = groupName;
            this._isRootReport = true;

            GenerateReport();
        }
Example #6
0
 public void ChangeSubReport(ReportGenerator subReport)
 {
     if (this.SubReport != null)
     {
         this.SelectedDataRangeChanged -= this.SubReport.DataSourceChanged;
     }
     if (subReport == null)
     {
         this.SubReport = null;
     }
     else
     {
         this.SubReport = subReport;
         this.SelectedDataRangeChanged += this.SubReport.DataSourceChanged;
     }
 }
Example #7
0
        private void BindDataToGridView()
        {
            //List<Student> list = new List<Student>();
            //list = GetDataSource().Where(a => { return a.Age == 24; }).ToList();
            //gvMain.DataSource = list;

            //IEnumerable<Student> list;
            //List<Student> list2;
            //list = GetDataSource().Where(a => a.Age == 24);
            //list2 = list.ToList();

            //gvMain.DataSource = GetDataSource().Where(a => a.Age == 24).ToList();

            List<Student> list = new List<Student>();
            //List<Student> list2;

            list.Add(new Student() { StuId = 2008011217, StuName = "陈义", Age = 24 });
            list.Add(new Student() { StuId = 2008011218, StuName = "陈林", Age = 26 });

            string json = JsonHelper.SerializeObject(list);

            IEnumerable<Student> studentInfo = JsonHelper.DeserializeJsonToCollection<Student>(json);

            gvMain.DataSource = studentInfo;

            DataTable dt = new DataTable();

            DataColumn dc = new DataColumn();
            dc.ColumnName = "Name";
            dt.Columns.Add(dc);
            DataRow dr = dt.NewRow();
            dr["Name"] = "陈义";
            dt.Rows.Add(dr);

            Option<string> o =  new Option<string>();
            ReportGenerator r = new ReportGenerator(dt, o);

            var r2 = r.AddSubReport(o);
            r2.ChangePreReport(r,dt);

            var r3 = r.AddSubReport(o);

            r2.DropReport();
            r2.DropReport();
            //list2 = list.Where(c => c.Age == 24).ToList();
        }
Example #8
0
        public ReportGenerator AddSubReport(Option <string> groupName, string reportName = null)
        {
            ReportGenerator sub = new ReportGenerator(reportName);

            if (SubReport != null)
            {
                var grandson = SubReport;
                this.ChangeSubReport(sub);
                sub.ChangePreReport(this, this.SelectedDataRange);
                sub.ChangeSubReport(grandson);
                grandson.ChangePreReport(sub, sub.SelectedDataRange);
            }
            else
            {
                this.ChangeSubReport(sub);
                sub.ChangePreReport(this, this.SelectedDataRange);
            }

            return(sub);
        }
Example #9
0
        public ReportGenerator AddSubReport(Option<string> groupName, string reportName = null)
        {
            ReportGenerator sub = new ReportGenerator(reportName);
            if (SubReport != null)
            {
                var grandson = SubReport;
                this.ChangeSubReport(sub);
                sub.ChangePreReport(this, this.SelectedDataRange);
                sub.ChangeSubReport(grandson);
                grandson.ChangePreReport(sub, sub.SelectedDataRange);
            }
            else
            {
                this.ChangeSubReport(sub);
                sub.ChangePreReport(this, this.SelectedDataRange);
            }

            return sub;
        }
Example #10
0
        /// <summary>
        /// drop the sub report link, and then link to the grandson report if it existed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DropSubReport(object sender, EventArgs e)
        {
            if (SubReport.SubReport != null)
            {
                var grandsonReport = SubReport.SubReport;

                this.ChangeSubReport(grandsonReport);
                grandsonReport.ChangePreReport(this, this.SelectedDataRange);

                this.SubReport = grandsonReport;
            }
            else
            {
                this.SubReport = null;
            }
        }
Example #11
0
 public void Dispose()
 {
     CutEventOff();
     this.CurrentReport = null;
     this._dataSource = null;
     this._groupName = null;
     this._preReport = null;
     this.SelectedDataRange = null;
     this.SubReport = null;
     GC.Collect();
 }
Example #12
0
 public void ChangeSubReport(ReportGenerator subReport)
 {
     if (this.SubReport != null)
     {
         this.SelectedDataRangeChanged -= this.SubReport.DataSourceChanged;
     }
     if (subReport == null)
     {
         this.SubReport = null;
     }
     else
     {
         this.SubReport = subReport;
         this.SelectedDataRangeChanged += this.SubReport.DataSourceChanged;
     }
 }
Example #13
0
 public void ChangePreReport(ReportGenerator preReport, DataTable dataSource)
 {
     if (preReport == null)
     {
         throw new ArgumentNullException("preReport");
     }
     if (this._preReport != null)
     {
         this.CurrentReportDestroying -= _preReport.DropSubReport;
     }
     this._preReport = preReport;
     this.CurrentReportDestroying += _preReport.DropSubReport;
     this._dataSource = dataSource;
     GenerateReport();
 }