1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using System;
using System.Collections.Generic;
using System.Text;
using gregn6Lib;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Runtime.Serialization;
 
namespace BLL
{
    /// <summary>
    /// Ë«Íø¸ñ´òÓ¡
    /// </summary>
    [Serializable()]
    public class ReportBase : IReport
    {
        private GridppReport GRReport = new GridppReport();
        private IDataReader Dr;
        private DataTable Dt;
        private Hashtable t = new Hashtable();
        private IList<subRpt> array = null;
        private subRpt _subRpt = null;
        private int subRptIndex = 0;
 
 
        public class subRpt
        {
 
            public subRpt(GridppReport Report, IDataReader Dr, Hashtable t)
            {
                this.Report = Report;
                this.Dr = Dr;
                this.t = t;
            }
 
           
 
            private GridppReport report;
 
            public GridppReport Report
            {
                get { return Report; }
                set { Report = value; }
            }
 
            private IDataReader dr;
 
            public IDataReader Dr
            {
                get { return dr; }
                set { dr = value; }
            }
 
            private Hashtable t1;
 
            public Hashtable t
            {
                get { return t1; }
                set { t1 = value; }
            }
        }
 
        #region IReport ³ÉÔ±
 
        public void MainReport(GridppReport Report, string FileName)
        {
            this.array = new List<subRpt>();
            this.GRReport = Report;
            this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf");
        }
 
        public void SubReport(String Name, IDataReader Dr, Hashtable t)
        {
            GridppReport rptSub = this.GRReport.ControlByName(Name).AsSubReport.Report;
            array.Add(new subRpt(rptSub, Dr, t));
            rptSub.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(rpt_BeforePostRecord);
            rptSub.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(rpt_FetchRecord);
        }
 
        public void rpt_BeforePostRecord()
        {
            if (_subRpt.t != null)
            {
                foreach (DictionaryEntry obj in _subRpt.t)
                {
                    _subRpt.Report.FieldByName(obj.Key.ToString()).AsString = obj.Value.ToString();
                }
            }
        }
 
        public void rpt_FetchRecord()
        {
            this._subRpt = array[subRptIndex];
            Utility.FillRecordToReport(this._subRpt.Report, this._subRpt.Dr);
            subRptIndex++;
        }
        //³õʼ»¯±¨±í
        public object InitReport(GridppReport Report, IDataReader Dr, string FileName, Hashtable t)
        {
            try
            {
                this.GRReport = Report;
                this.Dr = Dr;
                this.t = t;
                this.GRReport.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(BeforePostRecord);
                this.GRReport.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(FetchRecord);
                this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf");
                return this.GRReport;
            }
            catch
            {
                return null;
            }
        }
 
        #region IReport ³ÉÔ±
 
 
        public object InitReport(GridppReport Report, DataTable Dt, string FileName, Hashtable t)
        {
            try
            {
 
                this.GRReport = Report;
                this.Dt = Dt;
                this.t = t;
                this.GRReport.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(BeforePostRecord);
                this.GRReport.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(FetchRecordDataTable);
                this.GRReport.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "report\\" + FileName + ".grf");
                return this.GRReport;
            }
            catch
            {
                return null;
            }
        }
 
        #endregion
 
        public void BeforePostRecord()
        {
            if (t != null)
            {
                foreach (DictionaryEntry obj in t)
                {
                    this.GRReport.FieldByName(obj.Key.ToString()).AsString = obj.Value.ToString();
                }
            }
        }
 
        public void FetchRecord()
        {
            Utility.FillRecordToReport(this.GRReport, this.Dr);
        }
 
        public void FetchRecordDataTable()
        {
            Utility.FillRecordToReport(this.GRReport, this.Dt);
        }
 
        public void Print(bool ShowPrintDialg)
        {
            this.GRReport.Print(ShowPrintDialg);
        }
 
        public void PrintPreview(bool ShowModal)
        {
            this.GRReport.PrintPreview(ShowModal);
        }
 
        public void Export(GRExportType type, bool ShowOptionDlg, bool DoneOpen)
        {
            this.GRReport.ExportDirect(type, this.GRReport.Title, ShowOptionDlg, DoneOpen);
        }
 
        public string GetPath()
        {
            return System.Environment.CurrentDirectory + "\\" + this.GRReport.Title + ".xls";
        }
 
        public object GetReport()
        {
            return this.GRReport;
        }
 
        #endregion
 
    }
}