MetroTestResult.cs
9.9 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dal;
using Comm;
using log4net;
using System.Reflection;
namespace App
{
public partial class MetroTestResult : FrmBase
{
FrmTestResult newForm;
FrmTestManage newForm2;
private LoginManager _loginManager;
private string FileName;
public bool isOpen = true;//判断该窗口是否打开状态
public MetroTestResult(LoginManager loginManager,string fileName)
{
InitializeComponent();
this.WindowState = FormWindowState.Maximized;
this.SetLanguage(this);
this._loginManager = loginManager;
Init();
this.FileName = fileName;
OpenTest();
}
private void Init()
{
this.Text = getMsg("FrmTestResult");
this.btnGoBack.Text = getMsg("back");
this.checkBoxEC1.Text = fuction.GetParameterByParaName(Const.PARA_ECName1,"currency");
this.checkBoxEC2.Text = fuction.GetParameterByParaName(Const.PARA_ECName2, "currency");
}
/**
*
* 鼠标放在三个按钮上做出相应提示
*/
private void openFileBtn_MouseHover(object sender, EventArgs e)
{
ToolTip tt = new ToolTip();
tt.SetToolTip(this.openFileBtn, getMsg("FrmMDIrb_Open.InfoTitle"));
}
private void printFileBtn_MouseHover(object sender, EventArgs e)
{
ToolTip tt = new ToolTip();
tt.SetToolTip(this.printFileBtn, getMsg("FrmMDIrb_Print"));
}
private void printViewBtn_MouseHover(object sender, EventArgs e)
{
//ToolTip tt = new ToolTip();
//tt.SetToolTip(this.printViewBtn, getMsg("FrmMDIrb_PrintPreview"));
}
/**
* 打开文件
*/
private void openFileBtn_Click(object sender, EventArgs e)
{
OpenTest();
}
private void OpenTest()
{
string directory = Fuction.m_CurrentDirectory + Const.TestDataDataRoot;
openFileDialog1.InitialDirectory = directory;
if (this.FileName != "")//测试结束跳转
{
this.resultShowPanel.Controls.Clear();
openFile(this.FileName);
this.FileName = "";
}
else
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)//自行打开测试结果
{
this.resultShowPanel.Controls.Clear();
openFile(openFileDialog1.FileName);
}
else
{
int count = this.resultShowPanel.Controls.Count;
if (count == 2 || count == 0)
{
this.Close();
this.isOpen = false;
MetroMDI mm = new MetroMDI(_loginManager);
mm.Show();
}
}
}
}
private void openFile(string fileName)
{
try
{
string XMLFile = fileName;
newForm = new FrmTestResult(XMLFile);
if (newForm is FrmTestResult)
{
try
{
newForm.Movable = false;
newForm.ControlBox = false;
newForm.MdiParent = this;
newForm.ShowInTaskbar = true;
newForm.StartPosition = FormStartPosition.CenterScreen;
newForm.Parent = this.resultShowPanel;
newForm.Text = "";
newForm.FormBorderStyle = FormBorderStyle.None;
newForm.Dock = System.Windows.Forms.DockStyle.Fill;
this.resultShowPanel.Controls.Add(newForm);
newForm.Show();
newForm.Activate();//激活
//readEndData();
endData = newForm.ReadEndData;
}
catch (Exception ex)
{
newForm.Close();
}
}
}
catch (Exception ex)
{
LOGGER.Debug(ex.StackTrace);
}
}
/**
* 打印预览
*/
private void printViewBtn_Click(object sender, EventArgs e)
{
//if (newForm2.GetType().FullName == "App.FrmTestManage")
//{
// string directory = Fuction.m_CurrentDirectory + Const.TestDataRoot + Const.TEMPWORD;
// int if_Export = ((FrmTestManage)newForm2).SaveAsWord(directory, Const.OPERATION_PRINTPREVIEW);
// return;
//}else
if (newForm is FrmTestResult)
{
try
{
string directory = Fuction.m_CurrentDirectory + Const.TestDataRoot + Const.TEMPWORD;
int if_Export = ((FrmTestResult)newForm).SaveAsWord(directory, Const.OPERATION_PRINTPREVIEW);
return;
}
catch (Exception ex)
{
LOGGER.Info("打印预览" + ex.StackTrace);
}
}
}
/**
* 打印
*/
private void printFileBtn_Click(object sender, EventArgs e)
{
//if (newForm2.GetType().FullName == "App.FrmTestManage")
//{
// string directory = Fuction.m_CurrentDirectory + Const.TestDataRoot + Const.TEMPWORD;
// int if_Export = ((FrmTestManage)newForm2).SaveAsWord(directory, Const.OPERATION_PRINT);
// return;
//}
LOGGER.Debug("Start Into Export Report" + DateTime.Now);
if (newForm is FrmTestResult)
{
string directory = Fuction.m_CurrentDirectory + Const.TestDataRoot + Const.TEMPWORD;
try
{
int if_Export = ((FrmTestResult)newForm).SaveAsWord(directory, Const.OPERATION_PRINT);
}
catch (Exception ex)
{
LOGGER.Info("导出PDF:"+ex.StackTrace);
}
return;
}
}
private void MetroTestResult_FormClosed(object sender, EventArgs e)
{
//this.Close();
//MetroMDI mm = new MetroMDI(_loginManager);
//mm.Show();
}
bool isCheck1 = false;
/**
* 等效系数1
*/
private void checkBoxEC_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxEC1.Checked)
{
DataColumnCollection columns = ((FrmTestResult)newForm).table2.Columns;
columns.Add(fuction.GetParameterByParaName(Const.PARA_ECName1, "currency"), typeof(System.Double));
((FrmTestResult)newForm).table2.Rows[0][fuction.GetParameterByParaName(Const.PARA_ECName1, "currency")] = fuction.GetParameterByParaName(Const.PARA_EC1, "currency");
((FrmTestResult)newForm).GetDataGrideValue(((FrmTestResult)newForm).dgvTestResult, ((FrmTestResult)newForm).table2);
}
else
{
DataColumnCollection columns = ((FrmTestResult)newForm).table2.Columns;
columns.Remove(fuction.GetParameterByParaName(Const.PARA_ECName1, "currency"));
}
}
private double endData = 0;
/**
*
* removeEC
*/
private void removeEC()
{
((FrmTestResult)newForm).removeEC();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
double EC = 0;
string ECKind = "";
//if (this.comboBox1.Text.Equals(getMsg("EC1")))
//{
// EC = double.Parse(fuction.GetParameterByParaName(Const.PARA_EC1));
// ECKind = getMsg("EC1");
//}
//else if (this.comboBox1.Text.Equals(getMsg("EC2")))
//{
// EC = double.Parse(fuction.GetParameterByParaName(Const.PARA_EC2));
// ECKind = getMsg("EC2");
//}
EC *= endData;
((FrmTestResult)newForm).AddEC(EC, ECKind);
}
/**
* 等效系数2
*/
private void checkBoxEC2_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxEC2.Checked)
{
DataColumnCollection columns = ((FrmTestResult)newForm).table2.Columns;
columns.Add(fuction.GetParameterByParaName(Const.PARA_ECName2, "currency"), typeof(System.Double));
((FrmTestResult)newForm).table2.Rows[0][fuction.GetParameterByParaName(Const.PARA_ECName2, "currency")] = fuction.GetParameterByParaName(Const.PARA_EC2, "currency");
((FrmTestResult)newForm).GetDataGrideValue(((FrmTestResult)newForm).dgvTestResult, ((FrmTestResult)newForm).table2);
}
else
{
DataColumnCollection columns = ((FrmTestResult)newForm).table2.Columns;
columns.Remove(fuction.GetParameterByParaName(Const.PARA_ECName2, "currency"));
}
}
/**
* 返回上一步菜单
*/
private void button1_Click(object sender, EventArgs e)
{
this.Close();
MetroMDI mm = new MetroMDI(_loginManager);
mm.ShowInTaskbar = true;
mm.Show();
}
private void MetroTestResult_Load(object sender, EventArgs e)
{
this.testResultPanel.Height = this.Height - 59;
}
}
}