沈泽
2021-08-20 d111e4321dcc4baa63f63597694f80d94e67ca11
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
using System;
using System.Collections.Generic;
using System.Text;
using gregn6Lib;
//using AxgrproLib;
using System.Data;
 
namespace BLL
{
    class ReportCls
    {
        //public static string spName = string.Empty;
        //public static object[] parameterValues;
        //public static string ExecuteStr = string.Empty;
        //public static bool IsDate = false;
        //public static DateTime FirstDate = DateTime.Today;
        //public static DateTime LastDate = DateTime.Today;
 
        private string _spName = string.Empty;
        private object[] _parameterValues;
        private bool _IsDate = false;
        private DateTime _FirstDate = DateTime.Today;
        private DateTime _LastDate = DateTime.Today;
        private DataTable _Dt;
 
        public DataTable Dt
        {
            get { return _Dt; }
            set { _Dt = value; }
        }
 
        public String spName
        {
            get { return _spName; }
            set { _spName = value; }
        }
 
        public object[] parameterValues
        {
            get { return _parameterValues; }
            set { _parameterValues = value; }
        }
 
        public bool IsDate
        {
            get { return _IsDate; }
            set { _IsDate = value; }
        }
 
        public DateTime FirstDate
        {
            get { return _FirstDate; }
            set { _FirstDate = value; }
        }
 
        public DateTime LastDate
        {
            get { return _LastDate; }
            set { _LastDate = value; }
        }
 
        private GridppReport Report = new GridppReport();
 
        public void LoadReport(String sFileName)
        {
            Report.LoadFromFile(sFileName+ ".grf");
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord);
        }
 
        //public void LoadReport(AxGRDisplayViewer sGR, String sFileName)
        //{
 
        //    //Report.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + (@"Report\") + sFileName + ".grf");
        //    Report.LoadFromFile(sFileName);
        //    Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
        //    Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
        //    sGR.Report = Report;
        //    sGR.Start();
        //}
 
        public void ReportBeforePostRecord()
        {
            if (_IsDate == true)
            {
                Report.FieldByName("FirstDate").AsDateTime = _FirstDate;
                Report.FieldByName("LastDate").AsDateTime = _LastDate;
            }
        }
 
        public void ReportFetchRecord()
        {
            //SqlDataReader Dr = SqlHelper.ExecuteReader(Configs.GetConnectionString(), CommandType.Text, ExecuteStr);
            // Dr = SqlHelper.ExecuteReader(Configs.GetConnectionString(), _spName, _parameterValues);
            //GridppReportCls.Utility.FillRecordToReport(Report, Dr);
            //Dr.Close();
            //Dr.Dispose();
        }
 
        public void ReportFetchRecordByDataTable()
        {
 
            Utility.FillRecordToReport(Report, Dt);
            Dt.Dispose();
        }
 
        public void ReportPreview()
        {
            Report.PrintPreview(true);
        }
 
        public void ReportPrint()
        {
            Report.Print(true);
        }
 
        public void ReportExport()
        {
            Report.ExportDirect(GRExportType.gretXLS, Report.Title, false, true);
        }
    }
}