-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathOrderDesignControl2.cs
4150 lines (3399 loc) · 135 KB
/
OrderDesignControl2.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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml;
using System.Globalization;
using System.Threading;
using DigitalPlatform.GUI;
using DigitalPlatform.Xml;
using DigitalPlatform.IO;
using DigitalPlatform.Text;
using DigitalPlatform.Core;
namespace DigitalPlatform.CommonControl
{
/// <summary>
/// 新一代订购设计控件
/// 2012/5/25
/// </summary>
public partial class OrderDesignControl2 : UserControl
{
internal bool m_bFocused = false;
bool m_bHideSelection = true;
internal int DisableNewlyOrderTextChanged = 0;
internal int DisableNewlyArriveTextChanged = 0;
public Item2 LastClickItem = null; // 最近一次click选择过的Item2对象
// 获取值列表时作为线索的数据库名
public string BiblioDbName = ""; // 数据库名。用于获得值列表
// 获得缺省记录
/// <summary>
/// 获得缺省记录
/// </summary>
public event GetDefaultRecordEventHandler GetDefaultRecord = null;
/// <summary>
/// 获得值列表
/// </summary>
public event GetValueTableEventHandler GetValueTable = null;
// const int WM_NUMBER_CHANGED = API.WM_USER + 201;
int m_nInSuspend = 0;
// public int m_nTotalCopy = 0;
public List<Item2> Items = new List<Item2>();
bool m_bChanged = false;
public OrderDesignControl2()
{
InitializeComponent();
}
bool m_bSeriesMode = false;
// 是否为期刊模式? true表示为期刊模式,false表示为图书模式
[Category("Appearance")]
[DescriptionAttribute("SeriesMode")]
[DefaultValue(false)]
public bool SeriesMode
{
get
{
return this.m_bSeriesMode;
}
set
{
if (this.m_bSeriesMode != value)
{
this.m_bSeriesMode = value;
SetSeriesMode(value);
}
}
}
void SetSeriesMode(bool bSeriesMode)
{
this.DisableUpdate();
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
item.SeriesMode = bSeriesMode;
}
if (bSeriesMode == true)
{
this.dpColumn_range.Visible = true;
this.dpColumn_range.Text = "时间范围";
this.dpColumn_issueCount.Visible = true;
}
else
{
// this.label_range.Visible = false;
this.dpColumn_range.Visible = true; // ????
this.dpColumn_range.Text = "预计出版时间";
this.dpColumn_issueCount.Visible = false;
}
this.EnableUpdate();
}
bool m_bArriveMode = false;
// 是否为验收模式? true表示为验收模式,false表示为订购模式
[Category("Appearance")]
[DescriptionAttribute("ArriveMode")]
[DefaultValue(false)]
public bool ArriveMode
{
get
{
return this.m_bArriveMode;
}
set
{
this.m_bArriveMode = value;
SetArriveMode(value);
}
}
void SetArriveMode(bool bArriveMode)
{
if (bArriveMode == true)
{
// 验收态
/*
this.label_orderedTotalCopy.Text = "已验收总复本数(&O):";
this.label_newlyOrderTotalCopy.Text = "新验收总复本数(&N):";
* */
this.dpColumn_copy.ForeColor = Color.Red;
this.dpColumn_price.ForeColor = Color.Red;
this.dpColumn_location.ForeColor = Color.Red;
this.label_newlyOrderTotalCopy.Visible = false;
this.textBox_newlyOrderTotalCopy.Visible = false;
this.button_newItem.Visible = false;
this.label_arrivedTotalCopy.Visible = true;
this.textBox_arrivedTotalCopy.Visible = true;
// 2008/11/3
this.panel_targetRecPath.Visible = true;
this.label_newlyArriveTotalCopy.Visible = true;
this.textBox_newlyArriveTotalCopy.Visible = true;
// 2008/11/3
this.button_fullyAccept.Visible = true;
}
else
{
// false 表示订购态
/*
this.label_orderedTotalCopy.Text = "已订购总复本数(&O):";
this.label_newlyOrderTotalCopy.Text = "新订购总复本数(&N):";
* */
this.dpColumn_copy.ForeColor = this.ForeColor;
this.dpColumn_price.ForeColor = this.ForeColor;
this.dpColumn_location.ForeColor = this.ForeColor;
this.label_newlyOrderTotalCopy.Visible = true;
this.textBox_newlyOrderTotalCopy.Visible = true;
this.button_newItem.Visible = true;
this.label_arrivedTotalCopy.Visible = false;
this.textBox_arrivedTotalCopy.Visible = false;
// 2008/11/3
this.panel_targetRecPath.Visible = false;
this.label_newlyArriveTotalCopy.Visible = false;
this.textBox_newlyArriveTotalCopy.Visible = false;
// 2008/11/3
this.button_fullyAccept.Visible = false;
}
}
bool m_bOrderedTotalCopyVisible = false;
// 已订购份数 是否可见?
internal bool OrderedTotalCopyVisible
{
get
{
return this.m_bOrderedTotalCopyVisible;
}
set
{
if (this.m_bOrderedTotalCopyVisible != value)
{
this.m_bOrderedTotalCopyVisible = value;
this.textBox_orderedTotalCopy.Visible = value;
this.label_orderedTotalCopy.Visible = value;
}
}
}
bool m_bArrivedTotalCopyVisible = false;
// 已验收份数 是否可见?
internal bool ArrivedTotalCopyVisible
{
get
{
return this.m_bArrivedTotalCopyVisible;
}
set
{
if (this.m_bArrivedTotalCopyVisible != value)
{
this.m_bArrivedTotalCopyVisible = value;
this.textBox_arrivedTotalCopy.Visible = value;
this.label_arrivedTotalCopy.Visible = value;
}
}
}
// 验收目标记录路径
public string TargetRecPath
{
get
{
return this.textBox_targetRecPath.Text;
}
set
{
this.textBox_targetRecPath.Text = value;
}
}
[Category("Appearance")]
[DescriptionAttribute("HideSelection")]
[DefaultValue(true)]
public bool HideSelection
{
get
{
return this.m_bHideSelection;
}
set
{
if (this.m_bHideSelection != value)
{
this.m_bHideSelection = value;
this.RefreshLineColor(); // 迫使颜色改变
}
}
}
/// <summary>
/// 内容是否发生过修改
/// </summary>
[Category("Content")]
[DescriptionAttribute("Changed")]
[DefaultValue(false)]
public bool Changed
{
get
{
return this.m_bChanged;
}
set
{
if (this.m_bChanged != value)
{
this.m_bChanged = value;
if (value == false)
ResetLineState();
}
}
}
// 修改复本字符串中的套数部分
// parameters:
// strText 待修改的整个复本字符串
// strCopy 要改成的套数部分
// return:
// 返回修改后的整个复本字符串
public static string ModifyCopy(string strText, string strCopy)
{
int nRet = strText.IndexOf("*");
if (nRet == -1)
return strCopy;
return strCopy + "*" + strText.Substring(nRet + 1).Trim();
}
// 修改复本字符串中的套内册数部分
// parameters:
// strText 待修改的整个复本字符串
// strRightCopy 要改成的套内册数部分
// return:
// 返回修改后的整个复本字符串
public static string ModifyRightCopy(string strText, string strRightCopy)
{
int nRet = strText.IndexOf("*");
if (nRet == -1)
return strText + "*" + strRightCopy;
return strText.Substring(0, nRet).Trim() + "*" + strRightCopy;
}
// 从复本数字符串中得到套数部分
// 也就是 "3*5"返回"3"部分。如果只有一个数字,就取它
public static string GetCopyFromCopyString(string strText)
{
int nRet = strText.IndexOf("*");
if (nRet == -1)
return strText;
return strText.Substring(0, nRet).Trim();
}
// 从复本数字符串中得到套内册数部分
// 也就是 "3*5"返回"5"部分。如果只有一个数字,就返回""
public static string GetRightFromCopyString(string strText)
{
int nRet = strText.IndexOf("*");
if (nRet == -1)
return "";
return strText.Substring(nRet + 1).Trim();
}
// return:
// -1 error
// 0 succeed
static int VerifyDateRange(string strValue,
out string strError)
{
strError = "";
string strStart = "";
string strEnd = "";
int nRet = strValue.IndexOf("-");
if (nRet == -1)
{
strStart = strValue;
if (strStart.Length != 8)
{
strError = "时间范围 '" + strValue + "' 格式不正确";
return -1;
}
strEnd = "";
}
else
{
strStart = strValue.Substring(0, nRet).Trim();
if (strStart.Length != 8)
{
strError = "时间范围 '" + strValue + "' 内 '" + strStart + "' 格式不正确";
return -1;
}
strEnd = strValue.Substring(nRet + 1).Trim();
if (strStart.Length != 8)
{
strError = "时间范围 '" + strValue + "' 内 '" + strEnd + "' 格式不正确";
return -1;
}
}
if (String.Compare(strStart, strEnd) > 0)
{
strError = "时间范围内的起始时间不应大于结束时间";
return -1;
}
return 0;
}
// 进行检查
// return:
// -1 函数运行出错
// 0 检查没有发现错误
// 1 检查发现了错误
public int Check(out string strError)
{
strError = "";
bool bStrict = true; // 是否严格检查
// 检查是否每行都输入了价格、份数
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
// 只检查新规划的事项
if ((item.State & ItemState.ReadOnly) != 0)
continue;
// 进行检查
// return:
// -1 函数运行出错
// 0 检查没有发现错误
// 1 检查发现了错误
int nRet = item.location.Check(out strError);
if (nRet != 0)
{
strError = "第 " + (i + 1).ToString() + " 行: 去向 格式有问题: " + strError;
return 1;
}
// 2009/11/9
string strTotalPrice = "";
try
{
strTotalPrice = item.TotalPrice;
}
catch (Exception ex)
{
strError = "获取item.TotalPrice时出错: " + ex.Message;
return -1;
}
if (String.IsNullOrEmpty(strTotalPrice) == true)
{
if (String.IsNullOrEmpty(item.Price) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入价格";
return 1;
}
}
else
{
if (String.IsNullOrEmpty(item.StateString) == true
&& String.IsNullOrEmpty(item.Price) == false)
{
strError = "第 " + (i + 1).ToString() + " 行: 当输入了价格 ('"+item.Price+"') 时,必须把总价格设置为空 (但现在为 '"+strTotalPrice+"')";
return 1;
}
}
if (this.ArriveMode == false) // 2009/2/4
{
// 订购模式
if (String.IsNullOrEmpty(item.CopyString) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入复本数";
return 1;
}
}
else
{
// 验收模式
// 不一定每一行都要验收
// TODO: 是否检查一下至少有一行验收了?不太好检查。
}
if (this.SeriesMode == true)
{
if (String.IsNullOrEmpty(item.RangeString) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入时间范围";
return 1;
}
if (item.RangeString.Length != (2*8 + 1))
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入完整的时间范围";
return 1;
}
// return:
// -1 error
// 0 succeed
nRet = VerifyDateRange(item.RangeString,
out strError);
if (nRet == -1)
{
strError = "第 " + (i + 1).ToString() + " 行: " + strError;
return 1;
}
if (String.IsNullOrEmpty(item.IssueCountString) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入期数";
return 1;
}
}
if (bStrict == true)
{
if (String.IsNullOrEmpty(item.Source) == true
&& item.Seller != "交换" && item.Seller != "赠")
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入经费来源";
return 1;
}
// 2009/2/15
if (item.Seller == "交换" || item.Seller == "赠")
{
if (String.IsNullOrEmpty(item.Source) == false)
{
strError = "第 " + (i + 1).ToString() + " 行: 如果渠道为 交换 或 赠,则经费来源必须为空";
return 1;
}
}
if (String.IsNullOrEmpty(item.Seller) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入渠道";
return 1;
}
/*
if (String.IsNullOrEmpty(item.CatalogNo) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入书目号";
return 1;
}
* */
if (String.IsNullOrEmpty(item.Class) == true)
{
strError = "第 " + (i + 1).ToString() + " 行: 尚未输入类别";
return 1;
}
}
}
if (bStrict == true)
{
// 检查 渠道 + 经费来源 + 价格 3元组是否有重复
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
// 只检查新规划的事项
if ((item.State & ItemState.ReadOnly) != 0)
continue;
// 2009/2/4 只检查新输入的订购事项
if (String.IsNullOrEmpty(item.StateString) == false)
continue;
for (int j = i + 1; j < this.Items.Count; j++)
{
// 只检查新规划的事项
if ((item.State & ItemState.ReadOnly) != 0)
continue;
// 2009/2/4 只检查新输入的订购事项
if (String.IsNullOrEmpty(item.StateString) == false)
continue;
Item2 temp_item = this.Items[j];
if (this.SeriesMode == false)
{
// 对图书检查三元组
if (item.Seller == temp_item.Seller
&& item.Source == temp_item.Source
&& item.Price == temp_item.Price)
{
strError = "第 " + (i + 1).ToString() + " 行 和 第 " + (j + 1) + " 行之间 渠道/经费来源/价格 三元组重复,需要将它们合并为一行";
return 1;
}
}
else
{
// 对期刊检查四元组
if (item.Seller == temp_item.Seller
&& item.Source == temp_item.Source
&& item.Price == temp_item.Price
&& item.RangeString == temp_item.RangeString)
{
strError = "第 " + (i + 1).ToString() + " 行 和 第 " + (j + 1) + " 行之间 渠道/经费来源/时间范围/价格 四元组重复,需要将它们合并为一行";
return 1;
}
}
}
}
}
return 0;
}
// 获得总份数。包括了所有新规划的和已订购(已验收)的事项
public int GetTotalCopy()
{
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
value += cur_element.CopyValue;
}
return value;
}
// 获得新规划的总份数。不包括已订购(已验收)的事项
public int GetNewlyOrderTotalCopy()
{
Debug.Assert(this.ArriveMode == false, "本函数只能在订购状态下使用");
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.ReadOnly) != 0)
continue;
value += cur_element.CopyValue;
}
return value;
}
// 获得新验收的总份数。不包括未订购的事项。不包括(显示为只读的)已验收事项
public int GetNewlyArriveTotalCopy()
{
Debug.Assert(this.ArriveMode == true, "本函数只能在验收状态下使用");
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
value += cur_element.location.ArrivedCount - cur_element.location.ReadOnlyArrivedCount;
}
return value;
}
// 检测是否有事项尚未订购(状态为空,表示刚刚输入了采购数据)
// return:
// -1 error
// 0 没有处于未订购状态的事项
// 1 有部分处于未订购状态的事项
// 2 全部事项都是未订购状态
public int NotOrdering(out string strMessage)
{
strMessage = "";
int nNotOrderItemCount = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if (cur_element.StateString == "")
{
Debug.Assert(cur_element.location.ReadOnly == true, "");
nNotOrderItemCount++;
}
}
if (nNotOrderItemCount == this.Items.Count)
{
strMessage = "全部 " + this.Items.Count.ToString() + " 个事项都处在未订购状态";
return 2;
}
if (nNotOrderItemCount > 0)
{
strMessage = "全部 " + this.Items.Count + " 个事项中有 "+nNotOrderItemCount.ToString()+" 个事项处在未订购状态";
return 1;
}
strMessage = "没有事项处在未订购状态";
return 0;
}
// 获得可新验收的最大总份数。包含了本函数操作前已经新验收的份数。
public int GetNewlyArrivingTotalCopy()
{
Debug.Assert(this.ArriveMode == true, "本函数只能在验收状态下使用");
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
// 要看看item本身的状态是不是完全不允许验收 2008/11/12
if (cur_element.location.ReadOnly == true)
continue;
value += cur_element.location.Count - cur_element.location.ReadOnlyArrivedCount;
}
return value;
}
// 获得已订购(已验收)的总份数。不包括新规划的事项
public int GetOrderedTotalCopy()
{
Debug.Assert(this.ArriveMode == false, "本函数只能在订购状态下使用");
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.ReadOnly) == 0)
continue;
value += cur_element.CopyValue;
}
return value;
}
// 获得已验收的总份数。不包括新规划的事项
public int GetArrivedTotalCopy()
{
Debug.Assert(this.ArriveMode == true, "本函数只能在验收状态下使用");
int value = 0;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
value += cur_element.location.ReadOnlyArrivedCount;
/*
if ((cur_element.State & ItemState.ReadOnly) == 0)
continue;
value += cur_element.CopyValue;
* */
}
return value;
}
public void SelectAll()
{
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.Selected) == 0)
cur_element.State |= ItemState.Selected;
}
}
public void SelectItem(Item2 element,
bool bClearOld)
{
if (bClearOld == true)
{
for (int i = 0; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if (cur_element == element)
continue; // 暂时不处理当前行
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
}
// 选中当前行
if ((element.State & ItemState.Selected) == 0)
element.State |= ItemState.Selected;
this.LastClickItem = element;
}
public void ToggleSelectItem(Item2 element)
{
// 选中当前行
if ((element.State & ItemState.Selected) == 0)
element.State |= ItemState.Selected;
else
element.State -= ItemState.Selected;
this.LastClickItem = element;
}
public void RangeSelectItem(Item2 element)
{
Item2 start = this.LastClickItem;
int nStart = this.Items.IndexOf(start);
if (nStart == -1)
return;
int nEnd = this.Items.IndexOf(element);
if (nStart > nEnd)
{
// 交换
int nTemp = nStart;
nStart = nEnd;
nEnd = nTemp;
}
for (int i = nStart; i <= nEnd; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.Selected) == 0)
cur_element.State |= ItemState.Selected;
}
// 清除其余位置
for (int i = 0; i < nStart; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
for (int i = nEnd + 1; i < this.Items.Count; i++)
{
Item2 cur_element = this.Items[i];
if ((cur_element.State & ItemState.Selected) != 0)
cur_element.State -= ItemState.Selected;
}
}
public bool HasGetValueTable()
{
if (this.GetValueTable != null)
return true;
return false;
}
public void OnGetValueTable(object sender, GetValueTableEventArgs e)
{
if (this.GetValueTable != null)
this.GetValueTable(sender, e);
}
// 获得一个未曾使用的index字符串
// paremeters:
// exclude 查阅过程中,排除此项。如果不需要本参数(即不排除任何事项),用使用值null
string GetNewIndex(Item2 exclude)
{
for (int j = 1; ; j++)
{
string strIndex = j.ToString();
bool bFound = false;
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
if (item == exclude)
continue;
if (item.Index == strIndex)
{
bFound = true;
break;
}
}
if (bFound == false)
return strIndex;
}
}
// 将全部行的状态恢复为普通状态
// 不过,仍保留了Ordered状态
void ResetLineState()
{
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
if ((item.State & ItemState.ReadOnly) != 0)
item.State = ItemState.Normal | ItemState.ReadOnly;
else
item.State = ItemState.Normal;
}
}
void RefreshLineColor()
{
for (int i = 0; i < this.Items.Count; i++)
{
Item2 item = this.Items[i];
item.SetLineColor();
}
}
// 新规划订购的总份数
// 或者 新验收的总份数
public int NewlyOrderTotalCopy
{
get
{
if (String.IsNullOrEmpty(this.textBox_newlyOrderTotalCopy.Text) == true)
return 0;
return Convert.ToInt32(this.textBox_newlyOrderTotalCopy.Text);
}
set
{
this.textBox_newlyOrderTotalCopy.Text = value.ToString();
}
}
public void Clear()
{
this.DisableUpdate();
try
{
#if NO
for (int i = 0; i < this.Items.Count; i++)
{
Item2 element = this.Items[i];
ClearOneItemControls(this.tableLayoutPanel_content,
element);
}
#endif
this.Items.Clear();
this.dpTable1.Rows.Clear();
/*
this.tableLayoutPanel_content.RowCount = 2; // 为什么是2?
for (; ; )
{
if (this.tableLayoutPanel_content.RowStyles.Count <= 2)
break;
this.tableLayoutPanel_content.RowStyles.RemoveAt(2);
}
* */
// 2008/12/30
this.textBox_arrivedTotalCopy.Text = "";
this.textBox_newlyArriveTotalCopy.Text = "";
this.textBox_newlyOrderTotalCopy.Text = "";
this.textBox_orderedTotalCopy.Text = "";
}
finally
{
this.EnableUpdate();
}
}
#if NO
// 清除一个Item2对象对应的Control
public void ClearOneItemControls(
TableLayoutPanel table,
Item2 line)
{
// color
Label label = line.label_color;
table.Controls.Remove(label);
// catalog no
table.Controls.Remove(line.textBox_catalogNo);
// seller
table.Controls.Remove(line.comboBox_seller);
// source
table.Controls.Remove(line.comboBox_source);
// range
table.Controls.Remove(line.dateRange_range);