-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathSpecialSourceSeriesDialog.cs
353 lines (296 loc) · 10.7 KB
/
SpecialSourceSeriesDialog.cs
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace DigitalPlatform.CommonControl
{
/// <summary>
/// 期刊特殊订购渠道设计器 对话框
///
/// </summary>
public partial class SpecialSourceSeriesDialog : Form
{
/// <summary>
/// 获得值列表
/// </summary>
public event GetValueTableEventHandler GetValueTable = null;
public string DbName = ""; // 用于获得值列表
// 地址XML片段
public string AddressXml = "";
public string Seller = "";
public string Source = "";
public SpecialSourceSeriesDialog()
{
InitializeComponent();
}
private void SpecialSourceSeriesDialog_Load(object sender, EventArgs e)
{
string strError = "";
// 综合各种信息,设置状态
int nRet = SetType(out strError);
if (nRet == -1)
MessageBox.Show(this, strError);
}
private void SpecialSourceSeriesDialog_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void SpecialSourceSeriesDialog_FormClosed(object sender, FormClosedEventArgs e)
{
}
private void button_OK_Click(object sender, EventArgs e)
{
string strError = "";
// 获得用户选择的状态
int nRet = GetType(out strError);
if (nRet == -1)
goto ERROR1;
this.DialogResult = DialogResult.OK;
this.Close();
return;
ERROR1:
MessageBox.Show(this, strError);
}
private void button_Cancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
// 获得用户选择的状态
int GetType(out string strError)
{
strError = "";
if (this.personAddressControl.Changed == true)
{
// 获得编辑后的数据
try
{
this.AddressXml = this.personAddressControl.DataDom.DocumentElement.OuterXml;
}
catch (Exception ex)
{
strError = "获得AddressXml数据时出错: " + ex.Message;
return -1;
}
}
// 普通渠道
if (this.comboBox_specialSource.Text == "普通")
{
if (this.comboBox_seller.Text == "")
{
strError = "普通渠道类型时,渠道名不能为空";
return -1;
}
if (this.comboBox_source.Text == "")
{
strError = "普通渠道类型时,经费来源不能为空";
return -1;
}
///
if (this.comboBox_seller.Text == "直订")
{
strError = "普通渠道类型时,渠道名不能为 '" + this.comboBox_seller.Text + "'";
return -1;
}
if (this.comboBox_seller.Text == "交换")
{
strError = "普通渠道类型时,渠道名不能为 '" + this.comboBox_seller.Text + "'";
return -1;
}
if (this.comboBox_seller.Text == "赠")
{
strError = "普通渠道类型时,渠道名不能为 '" + this.comboBox_seller.Text + "'";
return -1;
}
this.Source = this.comboBox_source.Text;
this.Seller = this.comboBox_seller.Text;
// 地址不变
return 0;
}
// 直订
if (this.comboBox_specialSource.Text == "直订")
{
if (this.comboBox_source.Text == "")
{
strError = "直订时,经费来源不能为空";
return -1;
}
if (this.comboBox_seller.Text == "交换")
{
strError = "直订时,渠道名不能为 '" + this.comboBox_seller.Text + "'";
return -1;
}
if (this.comboBox_seller.Text == "赠")
{
strError = "直订时,渠道名不能为 '" + this.comboBox_seller.Text + "'";
return -1;
}
this.Source = this.comboBox_source.Text;
this.Seller = "直订";
// TODO: 合成地址
return 0;
}
// 交换
if (this.comboBox_specialSource.Text == "交换")
{
this.Seller = "交换";
this.Source = "";
return 0;
}
// 赠
if (this.comboBox_specialSource.Text == "赠")
{
this.Seller = "赠";
this.Source = "";
return 0;
}
strError = "不合法的渠道类型 '" + this.comboBox_specialSource.Text + "'";
return -1;
}
// 综合各种信息,设置状态
int SetType(out string strError)
{
strError = "";
int nRet = 0;
this.comboBox_seller.Text = this.Seller;
this.comboBox_source.Text = this.Source;
// 装入地址信息
if (String.IsNullOrEmpty(this.AddressXml) == false)
{
nRet = this.personAddressControl.SetData(this.AddressXml,
out strError);
if (nRet == -1)
return -1;
}
if (this.Seller == "直订")
{
this.comboBox_specialSource.Text = "直订";
return 0;
}
if (this.Seller == "交换")
{
this.comboBox_specialSource.Text = "交换";
return 0;
}
if (this.Seller == "赠")
{
this.comboBox_specialSource.Text = "赠";
return 0;
}
this.comboBox_specialSource.Text = "普通";
return 0;
}
// 防止重入 2009/7/19
int m_nInDropDown = 0;
private void comboBox_DropDown(object sender, EventArgs e)
{
// 防止重入 2009/7/19
if (this.m_nInDropDown > 0)
return;
Cursor oldCursor = this.Cursor;
this.Cursor = Cursors.WaitCursor;
this.m_nInDropDown++;
try
{
ComboBox combobox = (ComboBox)sender;
if (combobox.Items.Count == 0
&& this.GetValueTable != null)
{
GetValueTableEventArgs e1 = new GetValueTableEventArgs();
e1.DbName = this.DbName;
if (combobox == this.comboBox_source)
e1.TableName = "orderSource";
else if (combobox == this.comboBox_seller)
e1.TableName = "orderSeller";
else
{
Debug.Assert(false, "不支持的sender");
return;
}
this.GetValueTable(this, e1);
if (e1.values != null)
{
for (int i = 0; i < e1.values.Length; i++)
{
combobox.Items.Add(e1.values[i]);
}
}
else
{
combobox.Items.Add("<not found>");
}
}
}
finally
{
this.Cursor = oldCursor;
this.m_nInDropDown--;
}
}
private void comboBox_seller_DropDown(object sender, EventArgs e)
{
comboBox_DropDown(sender, e);
}
private void comboBox_source_DropDown(object sender, EventArgs e)
{
comboBox_DropDown(sender, e);
}
private void comboBox_specialSource_TextChanged(object sender, EventArgs e)
{
if (this.comboBox_specialSource.Text == "直订")
{
this.comboBox_seller.Enabled = false;
this.comboBox_seller.Visible = false;
this.label_seller.Visible = false;
this.comboBox_source.Enabled = true;
this.comboBox_source.Visible = true;
this.label_source.Visible = true;
}
else if (this.comboBox_specialSource.Text == "交换")
{
this.comboBox_seller.Enabled = false;
this.comboBox_seller.Visible = false;
this.label_seller.Visible = false;
this.comboBox_source.Enabled = false;
this.comboBox_source.Visible = false;
this.label_source.Visible = false;
}
else if (this.comboBox_specialSource.Text == "赠")
{
this.comboBox_seller.Enabled = false;
this.comboBox_seller.Visible = false;
this.label_seller.Visible = false;
this.comboBox_source.Enabled = false;
this.comboBox_source.Visible = false;
this.label_source.Visible = false;
}
else if (this.comboBox_specialSource.Text == "普通")
{
this.comboBox_seller.Enabled = true;
this.comboBox_seller.Visible = true;
this.label_seller.Visible = true;
this.comboBox_source.Enabled = true;
this.comboBox_source.Visible = true;
this.label_source.Visible = true;
if (this.comboBox_seller.Text == "直订")
this.comboBox_seller.Text = "";
if (this.comboBox_seller.Text == "交换"
|| this.comboBox_seller.Text == "赠")
this.comboBox_seller.Text = "";
}
else
{
// 其他不合法的渠道名
this.comboBox_seller.Enabled = false;
this.comboBox_seller.Visible = false;
this.label_seller.Visible = false;
this.comboBox_source.Enabled = false;
this.comboBox_source.Visible = false;
this.label_source.Visible = false;
}
}
}
}