hank
2015-08-18 2d4b747b3ac277babbd8eddfd88f378953f497bd
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
 
using System.Data.OracleClient;
 
namespace CCSTrace.CCS.Object
{
    public class CCSRecord
    {
        private String Meter;
        private String CustomerName;
        private String CustomerTel;
        private String ADDR_City;
        private String ADDR_Town;
        private String ADDR_Road;
        private String ADDR_Other;
        private String RecallName;
        private String RecallTel;
        private int EventBrief;
        private String AcceptTime;
        private String CCSID;
        private int ImportCase;
        private String Dept;
        private int PartHicustomer;
        private String Note;
 
        public CCSRecord(String _CCSID, String _METER, String _CUSTOMERNAME, String _CUSTOMERTEL, String _ADDR_CITY, String _ADDR_TOWN, String _ADDR_ROAD,
                         String _ADDR_OTHER, String _RECALLNAME, String _RECALLTEL, int _EVENTBRIEF, String _ACCEPTTIME, int _IMPORTCASE, String _DEPT,
                         int _PartHicustomer,String _NOTE)
        {
            this.Meter = _METER;
            this.CustomerName = _CUSTOMERNAME;
            this.CustomerTel = _CUSTOMERTEL;
            this.ADDR_City = _ADDR_CITY;
            this.ADDR_Town = _ADDR_TOWN;
            this.ADDR_Road = _ADDR_ROAD;
            this.ADDR_Other = _ADDR_OTHER;
            this.RecallName = _RECALLNAME;
            this.RecallTel = _RECALLTEL;
            this.EventBrief = _EVENTBRIEF; ;
            this.CCSID = _CCSID;
            this.ImportCase = _IMPORTCASE;
            this.Dept = _DEPT;
            this.Note = _NOTE;
            this.PartHicustomer = _PartHicustomer;
            this.AcceptTime = _ACCEPTTIME;
        }
 
        public CCSRecord(String _CCSID, OracleConnection _ConnectionTPC, SEventLog _PLog)
        {
            String SqlStmt;
 
            SqlStmt = "SELECT METER,CUSTOMERNAME,CUSTOMERTEL,ADDR_CITY,ADDR_TOWN,ADDR_ROAD,ADDR_OTHER,RECALLNAME,RECALLTEL,EVENTBRIEF,"
                    + "TO_CHAR(ACCEPTTIME,'YYYY/MM/DD HH24:MI:SS') as ACCEPTTIME,CCSID,IMPORTCASE,DEPT,PARTHICUSTOMER,NOTE FROM CCS.EVENTRECORD "
                    + "WHERE CCSID = '" + _CCSID + "'";
 
            OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
            OracleDataReader reader = Command.ExecuteReader();
            
            try
            {
                while (reader.Read())
                {
                    Meter = reader["METER"].ToString();
                    CustomerName = reader["CUSTOMERNAME"].ToString();
                    CustomerTel = reader["CUSTOMERTEL"].ToString();
                    ADDR_City = reader["ADDR_CITY"].ToString();
                    ADDR_Town = reader["ADDR_TOWN"].ToString();
                    ADDR_Road = reader["ADDR_ROAD"].ToString();
                    ADDR_Other = reader["ADDR_OTHER"].ToString();
                    RecallName = reader["RECALLNAME"].ToString();
                    RecallTel = reader["RECALLTEL"].ToString();
                    EventBrief = Int32.Parse(reader["EVENTBRIEF"].ToString());
                    AcceptTime = reader["ACCEPTTIME"].ToString();
                    CCSID = reader["CCSID"].ToString();
                    ImportCase = Int32.Parse(reader["IMPORTCASE"].ToString());
                    Dept = reader["DEPT"].ToString();
                    PartHicustomer = Int32.Parse(reader["PARTHICUSTOMER"].ToString());
                    Note = reader["NOTE"].ToString();
                }
            }
            catch (Exception e)
            {
                _PLog.Error("無法取得CCS報案資訊!" + e.Message);
                Console.WriteLine(e.StackTrace);
 
                if (LocalVariable.ShowError)
                    _PLog.Error(e.StackTrace);
 
                throw e;
            }
            finally
            { 
                reader.Close();
                Command.Dispose();
            }
        }
 
        public bool InsertDB(OracleConnection _ConnectionTPC, System.Data.OracleClient.OracleTransaction _Transaction, SEventLog _PLog)
        {
            String SqlStmt;
 
            SqlStmt = "INSERT INTO CCS.EVENTRECORD VALUES ('" + this.Meter + "','" + CustomerName + "','" + CustomerTel + "','" + ADDR_City + "','"
                    + ADDR_Town + "','" + ADDR_Road + "','" + ADDR_Other + "','" + RecallName + "','" + RecallTel + "',"
                    + EventBrief + ",TO_DATE('" + AcceptTime + "','YYYY/MM/DD HH24:MI:SS'),'" + CCSID + "'," + ImportCase + ",'" + Dept + "',"
                    + PartHicustomer + ",'" + Note + "')";
 
            OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
 
            try
            {
                if (Command.ExecuteNonQuery() != 1)
                {
                    _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
 
                    throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
 
                if (LocalVariable.ShowError)
                    _PLog.Error(e.StackTrace);
 
                _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!" + e.Message);
                //throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中");
                throw e;
            }
            finally
            {
                Command.Dispose();
            }
            return true;
        }
 
        public String getMeter()
        {
            return this.Meter;
        }
 
        public String getCustomerName()
        {
            return this.CustomerName;
        }
 
        public String getCustomerTel()
        {
            return this.CustomerTel;
        }
 
        public String getADDR_City()
        {
            return this.ADDR_City;
        }
 
        public String getADDR_Town()
        {
            return this.ADDR_Town;
        }
 
        public String getADDR_Road()
        {
            return this.ADDR_Road;
        }
 
        public String getADDR_Other()
        {
            return this.ADDR_Other;
        }
 
        public String getRecallName()
        {
            return this.RecallName;
        }
 
        public String getRecallTel()
        {
            return this.RecallTel;
        }
 
        public int getEventBrief()
        {
            return this.EventBrief;
        }
 
        public String getAcceptTime()
        {
            return this.AcceptTime;
        }
 
        public String getCCSID()
        {
            return this.CCSID;
        }
 
        public int getImportCase()
        {
            return this.ImportCase;
        }
 
        public String getDetp()
        {
            return this.Dept;
        }
 
        public int getPartHicustomer()
        {
            return PartHicustomer;
        }
 
        public String getNote()
        {
            return this.Note;
        }
    }
}