FrmCrystalReprotCH.cs
13.0 KB
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using System;
using System.Data;
using Comm;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using Dal;
using Common.Logging;
using System.Reflection;
namespace App
{
public partial class FrmCrystalReprotCH : App.FrmBase
{
string _ProductImageRoot;
string _TestImageRoot;
string _TestDate;
string _TestTime;
string _ProductName;
string _ProductSize;
string _Standard;
string _Temperature;
string _Operator;
string _Department;
string _Company;
string _Solvent;
string _TestMode;
string _TestResult;
string _MIL;
string _DEF;
string _UserDefine;
string _startTime;
string _endTime;
string _UserLimitValue;
string _IPCValue;
string _Unit;
string _MILValue;
string _DEFValue;
string _IPC;
string _ECName1;
string _ECValue1;
string _ECName2;
string _ECValue2;
string _WashUpperLimit;
string _MachineModel;
string _ECResult1;
string _ECResult2;
string _SerialNumber;
string _CalibrationDate;
string _Notes;
string _dataFirst;
string _dataLast;
public FrmCrystalReprotCH(string productImageRoot,
string testImageRoot, string testDate, string testTime, string productName,
string productSize, string standard, string temperature, string Operator,
string department, string company, string solvent, string testMode,
string testResult, string mIL, string dEF, string userDefine, string startTime, string endTime,
string ParUserLimit, string ParaIPC, string Unit, string MIL, string DEF, string IPCReport,
string ecValue1, string ecValue2, string ecName1, string ecName2, string WashUpperLimit, string MachineModel
, string ecResult1, string ecResult2, string SerialNumber, string CalibrationDate, string Notes,
string dataFirst, string dataLast)
{
InitializeComponent();
_ProductImageRoot = productImageRoot;
_TestImageRoot = testImageRoot;
_TestDate = testDate;
_TestTime = testTime;
_ProductName = productName;
_ProductSize = productSize;
_Standard = standard;
_Temperature = temperature;
_Operator = Operator;
_Department = department;
_Company = company;
_Solvent = solvent;
_TestMode = testMode;
_TestResult = testResult;
_MIL = mIL;
_DEF = dEF;
_UserDefine = userDefine;
_startTime = startTime;
_endTime = endTime;
_UserLimitValue = ParUserLimit;
_IPCValue = ParaIPC;
_Unit = Unit;
_MILValue = MIL;
_DEFValue = DEF;
_IPC = IPCReport;
_ECName1 = ecName1;
_ECValue1 = ecValue1;
_ECName2 = ecName2;
_ECValue2 = ecValue2;
_WashUpperLimit = WashUpperLimit;
_MachineModel = MachineModel;
_ECResult1 = ecResult1;
_ECResult2 = ecResult2;
_SerialNumber = SerialNumber;
_CalibrationDate = CalibrationDate;
_Notes = Notes;
//Asa, 2020/7/16
_dataFirst = dataFirst;
_dataLast = dataLast;
}
public void CreateReport()
{
//DBConnection DBConn = new DBConnection();
//OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB();
////DataSet dataReport = new DataSet();
////myDataAdapter.Fill(dataReport,"myPersonalInfoTable");
////myDataReport myDataReport = new myDataReport();
////myDataReport.SetDataSource(dataReport);
////crystalReportViewer1.ReportSource = myDataReport;
//// here i have define a simple datatable inwhich image will recide
CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
crystalReportViewer1.ActiveViewIndex = 0;
crystalReportViewer1.ShowLogo = false;
crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
crystalReportViewer1.DisplayGroupTree = false;
crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
crystalReportViewer1.Name = "crystalReportViewer1";
crystalReportViewer1.ShowGroupTreeButton = false;
crystalReportViewer1.Size = new System.Drawing.Size(767, 477);
crystalReportViewer1.TabIndex = 0;
ReportDocument rep = new ReportDocument();
rep.Load(Fuction.m_CurrentDirectory + @"\CrystalReport\CrystalReportCH.rpt");
DataTable data = new DataTable("DataTable1");
data.Columns.Add(Const.CR_PRODUCTIMAGE, System.Type.GetType("System.Byte[]"));
data.Columns.Add(Const.CR_TESTIMAGE, System.Type.GetType("System.Byte[]"));
data.Columns.Add(Const.CR_TESTDATE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_TESTTIME, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_PRODCTNAME, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_PRODUCTSIZE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_STANDARD, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_TEMPRATURE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_OPERATOR, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_DEPARTMENT, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_COMPANY, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_SOLVENT, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_TESTMODE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_TESTRESULT, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_MIL, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_DEF, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_USERDEFINE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_StartTime, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_EndTime, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_USERLIMITVALUE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_IPCVALUE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_UNIT, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_MILVALUE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_DEFVALUE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_IPC, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECNAME1, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECVALUE1, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECNAME2, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECVALUE2, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_MACHINEMODEL, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_WASHUPPERLIMIT, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECRESULT1, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_ECRESULT2, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_SERIALNUMBER, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_CALIBRATIONDDATE, System.Type.GetType("System.String"));
data.Columns.Add(Const.CR_NOTES, System.Type.GetType("System.String"));
//Asa, 2020/7/16
data.Columns.Add("DataFirst", System.Type.GetType("System.String"));
data.Columns.Add("DataLast", System.Type.GetType("System.String"));
DataRow row = data.NewRow();
// define the filestream object to read the image
FileStream fs = null;
// define te binary reader to read the bytes of image
BinaryReader br = null;
// check the existance of image
//if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg"))
byte[] imgbyte = new byte[0];
if (File.Exists(@_ProductImageRoot))
{
// open image in file stream
fs = new FileStream(@_ProductImageRoot, FileMode.Open);
// initialise the binary reader from file streamobject
br = new BinaryReader(fs);
// define the byte array of filelength
imgbyte = new byte[fs.Length + 1];
// read the bytes from the binary reader
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
}
//else
//{
// // if phot does not exist show the nophoto.jpg file
// fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoPhoto.jpg", FileMode.Open);
//}
row[Const.CR_PRODUCTIMAGE] = imgbyte;
imgbyte = new byte[0];
fs = null;
br = null;
if (File.Exists(@_TestImageRoot))
{
// open image in file stream
fs = new FileStream(@_TestImageRoot, FileMode.Open);
// initialise the binary reader from file streamobject
br = new BinaryReader(fs);
// define the byte array of filelength
imgbyte = new byte[fs.Length + 1];
// read the bytes from the binary reader
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
}
//else
//{
// // if phot does not exist show the nophoto.jpg file
// fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoPhoto.jpg", FileMode.Open);
//}
row[Const.CR_TESTIMAGE] = imgbyte;
row[Const.CR_TESTDATE] = _TestDate;
row[Const.CR_TESTTIME] = _TestTime;
row[Const.CR_PRODCTNAME] = _ProductName;
row[Const.CR_PRODUCTSIZE] = _ProductSize;
row[Const.CR_STANDARD] = _Standard;
row[Const.CR_TEMPRATURE] = _Temperature;
row[Const.CR_OPERATOR] = _Operator;
row[Const.CR_DEPARTMENT] = _Department;
row[Const.CR_COMPANY] = _Company;
row[Const.CR_SOLVENT] = _Solvent;
row[Const.CR_TESTMODE] = _TestMode;
row[Const.CR_TESTRESULT] = _TestResult;
row[Const.CR_MIL] = _MIL;
row[Const.CR_DEF] = _DEF;
row[Const.CR_USERDEFINE] = _UserDefine;
row[Const.CR_USERLIMITVALUE] = _UserLimitValue;
row[Const.CR_IPCVALUE] = _IPCValue;
row[Const.CR_UNIT] = _Unit;
row[Const.CR_MILVALUE] = _MILValue;
row[Const.CR_DEFVALUE] = _DEFValue;
row[Const.CR_IPC] = _IPC;
row[Const.CR_ECNAME1] = _ECName1;
row[Const.CR_ECVALUE1] = _ECValue1;
row[Const.CR_ECNAME2] = _ECName2;
row[Const.CR_ECVALUE2] = _ECValue2;
row[Const.CR_MACHINEMODEL] = _MachineModel;
row[Const.CR_WASHUPPERLIMIT] = _WashUpperLimit;
row[Const.CR_ECRESULT1] = _ECResult1;
row[Const.CR_ECRESULT2] = _ECResult2;
row[Const.CR_SERIALNUMBER] = _SerialNumber;
row[Const.CR_CALIBRATIONDDATE] = _CalibrationDate;
row[Const.CR_NOTES] = _Notes;
//Asa, 2020/7/16
row["DataFirst"] = _dataFirst;
row["DataLast"] = _dataLast;
// add the image in bytearray
data.Rows.Add(row);
if (br != null)
{
// add row into the datatable
br.Close();
// close the binary reader
fs.Close();
}
// close the file stream
//CrystalReport.CrystalReportCH rptobj = new CrystalReport.CrystalReportCH();
// object of crystal report
rep.SetDataSource(data);
// set the datasource of crystalreport object
crystalReportViewer1.ReportSource = rep;
//set the report source
crystalReportViewer1.Refresh();
this.Controls.Add(crystalReportViewer1);
}
private void FrmCrystalReprotCH_Load(object sender, EventArgs e)
{
LOGGER.Debug("Fifth:start load Crystal Report " + DateTime.Now);
this.Text = "";
this.ControlBox = true;
CreateReport();
}
}
}