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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.EC;
using CY.Model;
using CY.BLL.Sys;
using CY.Infrastructure.Common;
using CY.Infrastructure.Query;
using CY.BLL;
using CY.Model.Inquiry;
using CY.BLL.OA;
using CY.SQLDAL;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //合版施工单
    public partial class AgSpecialOrderEdit : BasePage
    {
        EC_SpecialOrdersBLL bll_EC_SpecialOrdersBLL = null;
        EC_MemberDictionaryBLL bll_EC_MemberDictionaryBLL = null;
        OA_InventoryBLL bll_OA_InventoryBLL = null;
        OA_OutOfStorageBLL bll_OA_OutOfStorageBLL = null;
        EC_CuttingPaperSpecBLL bll_EC_CuttingPaperSpecBLL = null;
        public string PressesDeskHtml = "";
        public string SpecificationsSheetHtml = "";
        public string selFilmSpecHtml = "";
        public string selCTPSpecHtml = "";
        public string SelPaperSpecHtml = "";
        public string selPaperNameHtml = "";
        public string selCuttingPaperSpecHtml = "";
        public string keyid ="";
        public string printCount = "";
        public string[] Width = new string[7];
        public string[] Lenth = new string[7];
        public string xialapr = "";
        public string orderIdstrrrr = "";
 
        //初始化
        public AgSpecialOrderEdit()
        {
            bll_EC_SpecialOrdersBLL = new EC_SpecialOrdersBLL();
            bll_EC_MemberDictionaryBLL = new EC_MemberDictionaryBLL();
            bll_OA_InventoryBLL = new OA_InventoryBLL();
            bll_OA_OutOfStorageBLL = new OA_OutOfStorageBLL();
            bll_EC_CuttingPaperSpecBLL = new EC_CuttingPaperSpecBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        /// <summary>
        /// 加载合版施工单信息
        /// </summary>
        private bool InitData()
        {
            List<EC_MemberDictionary> m_EC_MemberDictionaryList = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "印刷机台") as List<EC_MemberDictionary>;
            List<EC_MemberDictionary> m_EC_MemberDictionaryList_o = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "板材规格") as List<EC_MemberDictionary>;
 
            List<EC_MemberDictionary> m_EC_MemberDictionaryList_paperName = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "自带纸名称") as List<EC_MemberDictionary>;
            List<EC_MemberDictionary> m_EC_MemberDictionaryList_paperSpec = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "自带纸规格") as List<EC_MemberDictionary>;
            List<EC_MemberDictionary> m_EC_MemberDictionaryList_filmSpec = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "自带菲林规格") as List<EC_MemberDictionary>;
            List<EC_MemberDictionary> m_EC_MemberDictionaryList_ctpSpec = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "自带CTP规格") as List<EC_MemberDictionary>;
 
            Pagination pa = new Pagination();
            pa.PageSize = 15;
            pa.PageIndex = 1;
            List<EC_CuttingPaperSpec> m_EC_CuttingPaperSpec = bll_EC_CuttingPaperSpecBLL.SelectModelPage(pa, CurrentUser.MemberId) as List<EC_CuttingPaperSpec>;
 
            
 
            if (m_EC_MemberDictionaryList != null && m_EC_MemberDictionaryList.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList)
                {
                    PressesDeskHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
            var sss = bll_EC_MemberDictionaryBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "版材规格");
            foreach (var eC_MemberDictionary in sss)
            {
                xialapr += " <div class=\"xialaprp\">" + eC_MemberDictionary.ParName + "</div>";
 
            }
            if (m_EC_MemberDictionaryList_o != null && m_EC_MemberDictionaryList_o.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList_o)
                {
                    SpecificationsSheetHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
 
            if (m_EC_MemberDictionaryList_paperName != null && m_EC_MemberDictionaryList_paperName.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList_paperName)
                {
                    selPaperNameHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
 
            if (m_EC_MemberDictionaryList_paperSpec != null && m_EC_MemberDictionaryList_paperSpec.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList_paperSpec)
                {
                    SelPaperSpecHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
 
            if (m_EC_MemberDictionaryList_filmSpec != null && m_EC_MemberDictionaryList_filmSpec.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList_filmSpec)
                {
                    selFilmSpecHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
 
            if (m_EC_MemberDictionaryList_ctpSpec != null && m_EC_MemberDictionaryList_ctpSpec.Count > 0)
            {
                foreach (var item in m_EC_MemberDictionaryList_ctpSpec)
                {
                    selCTPSpecHtml += "<option value='" + item.ParName + "'>" + item.ParName + "</option>";
                }
            }
 
            if (m_EC_CuttingPaperSpec != null && m_EC_CuttingPaperSpec.Count > 0)
            {
                foreach (var item in m_EC_CuttingPaperSpec)
                {
                    selCuttingPaperSpecHtml += "<option value='" + item.SpecName + "'>" + item.SpecName + "</option>";
                }
            }
 
            #region 获取订单及其相关
 
            EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            string orderIdStr = Request["orderid"];
            if (string.IsNullOrEmpty(orderIdStr))
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
            int? orderId = MyConvert.ConvertToInt32(orderIdStr);
            if (!orderId.HasValue)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
 
            EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.Value);
            if (null == _eC_OrderBasic)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("数据不存在!", this);
                return false;
            }
            EC_AcceptWayByOrderBLL _eC_AcceptWayByOrderBLL = new EC_AcceptWayByOrderBLL();
            EC_AcceptWayByOrder _eC_AcceptWayByOrder = _eC_AcceptWayByOrderBLL.GetModelByTargetId(orderId.Value);
            if (null == _eC_AcceptWayByOrder)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("数据不存在!", this);
                return false;
            }
 
            orderIdstrrrr = orderIdStr;
            EC_OrderPrintParameterBLL _eC_OrderPrintParameterBLL = new EC_OrderPrintParameterBLL();
            EC_OrderPrintParameter _eC_OrderPrintParameter = _eC_OrderPrintParameterBLL.GetModel(orderId.Value);
            InquiryCommonModel _inquiryCommonModel = null;
            if (null == _eC_OrderPrintParameter)
            {
                _inquiryCommonModel = new InquiryCommonModel();
            }
            else
            {
                _inquiryCommonModel = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), _eC_OrderPrintParameter.PrintParameter) as InquiryCommonModel;
            }
 
            #endregion
 
 
            EC_SpecialOrders m_EC_SpecialOrders = bll_EC_SpecialOrdersBLL.GetModelByOrderId(orderId);
            if (m_EC_SpecialOrders == null)
                m_EC_SpecialOrders = new EC_SpecialOrders();
 
            keyid = m_EC_SpecialOrders.Keyid.ToString2();
 
            OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            Sys_DictionaryBLL sys_DictionaryBLL = new Sys_DictionaryBLL();
            _inquiryCommonModel.DeliveryModeName = sys_DictionaryBLL.GetModelByKeyid(_eC_AcceptWayByOrder.AcceptTypeId);
            _inquiryCommonModel.BillModeName = _eC_AcceptWayByOrder.InvoiceDemand;
 
            this.spanSpecialNum.InnerText = string.IsNullOrEmpty(m_EC_SpecialOrders.PSO_OrderNum) ? bll_EC_SpecialOrdersBLL.GetPSO_OrderNum(CurrentUser.MemberId) : m_EC_SpecialOrders.PSO_OrderNum;
            this.spanSpecialExigency.InnerText = _eC_OrderBasic.OrderExtend.ExigencyCase.Name;
            this.spanSpecialTime.InnerText = m_EC_SpecialOrders.PSO_OrderTime == null ? DateTime.Now.ToString("yyyy-MM-dd HH:mm") : m_EC_SpecialOrders.PSO_OrderTime.Value.ToString("yyyy-MM-dd HH:mm");
            this.spanSpecialOprator.InnerText = string.IsNullOrEmpty(m_EC_SpecialOrders.Operator) ? CurrentUser.ShortName : m_EC_SpecialOrders.Operator;
            this.txtPSO_Work.InnerText = m_EC_SpecialOrders.PSO_Work;
            this.txtPSO_Remarks.InnerText = m_EC_SpecialOrders.PSO_Remarks;
 
            this.spanOrderNum.InnerText = _eC_OrderBasic.SellerOrderId;
            this.spanOrderType.InnerText = _eC_OrderBasic.OrderType.Name;
            this.spanOrderTitle.InnerText = _eC_OrderBasic.DocumentName;
            this.txtDeliveryTime.Value = _eC_OrderBasic.DeliveryTime == null ? "" : _eC_OrderBasic.DeliveryTime.Value.ToString("yyyy-MM-dd");
 
            this.spanOrderCustormName.InnerText = _eC_OrderBasic.BuyerName;
            this.spanOrderCustormLevel.InnerText = _eC_OrderBasic.OrderExtend.CustomerLevel.Name;
            this.spanOrderCustormPeople.InnerText = _eC_OrderBasic.OrderExtend.Contacts;
            this.spanOrderCustormPhone.InnerText = _eC_OrderBasic.OrderExtend.ContactPhone;
            this.spanOrderBusinessManage.InnerText = _eC_OrderBasic.OrderExtend.BusinessManager.Name;
            this.spanOrderCustormManage.InnerText = _eC_OrderBasic.OrderExtend.CustomerManager.Name;
 
            this.spanOrderName.InnerText = _eC_OrderBasic.DocumentName;
            //this.spanOrderAllMoney.InnerText = "¥" + _eC_OrderBasic.SumPrice.ToDecimal2Yen();
            //this.spanOrderSize.InnerText = _inquiryCommonModel.PrintSizeName;
            this.spanOrderPrintNum.InnerText = _eC_OrderBasic.OrderExtend.PrintNum.ToString2();
            if (_eC_OrderBasic.PrintTypeId == 13)
            {
                this.spanOrderPrintDemand.InnerHtml = "印刷数量:(" + _inquiryCommonModel.PrintBoxNumber + "款,每款" + _eC_OrderBasic.OrderExtend.PrintNum + "盒);" + _inquiryCommonModel.PrintDemand;
            }
            else
            {
                this.spanOrderPrintDemand.InnerHtml = "印刷数量:(" + _eC_OrderBasic.OrderExtend.PrintNum + ");" + _inquiryCommonModel.PrintDemand;
            }
            this.spanOrderAfterWorksDemand.InnerText = _inquiryCommonModel.AfterWorksDemand;
            this.spanOrderDeliveryModeName.InnerText = _inquiryCommonModel.DeliveryModeName;
            this.spanOrderBillModeName.InnerText = _inquiryCommonModel.BillModeName;
            this.spanOrderRemarks.InnerText = _eC_OrderBasic.Remark;
 
            printCount = _eC_OrderBasic.OrderExtend.PrintNum.ToString2();
 
            List<EC_SpecialForums> m_EC_SpecialForumsList = bll_EC_SpecialOrdersBLL.GetEC_SpecialForumsListByKeyid(m_EC_SpecialOrders.Keyid) as List<EC_SpecialForums>;
            if (m_EC_SpecialForumsList == null || m_EC_SpecialForumsList.Count == 0)
            {
                m_EC_SpecialForumsList = new List<EC_SpecialForums>();
                EC_SpecialForums m_EC_SpecialForums = new EC_SpecialForums();
                //m_EC_SpecialForums.PSF_Note = _inquiryCommonModel.AfterWorksDemand;
                m_EC_SpecialForums.PSF_Forumsid = 1;
                m_EC_SpecialForums.PSF_CTPCount = 1;
                m_EC_SpecialForumsList.Add(m_EC_SpecialForums);
                this.txtPSO_Work.InnerText = _inquiryCommonModel.AfterWorksDemand;
            }
            this.RepClientList.DataSource = m_EC_SpecialForumsList;
            this.RepClientList.DataBind();
 
            //获取开料尺寸
            EC_CuttingPaperSpec model = new EC_CuttingPaperSpec();
            //model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "小全开");
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "小全开");
            if (model != null)
            {
                Width[0] = model.Width;
                Lenth[0] = model.Length;
            }
            else
            {
                Width[0] = "";
                Lenth[0] = "";
            }
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "2开");
 
            if (model != null)
            {
                Width[1] = model.Width;
                Lenth[1] = model.Length;
            }
            else
            {
                Width[1] = "";
                Lenth[1] = "";
            }
 
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "3开");
            if (model != null)
            {
                Width[2] = model.Width;
                Lenth[2] = model.Length;
            }
            else
            {
                Width[2] = "";
                Lenth[2] = "";
            }
 
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "4开");
            if (model != null)
            {
                Width[3] = model.Width;
                Lenth[3] = model.Length;
            }
            else
            {
                Width[3] = "";
                Lenth[3] = "";
            }
 
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "6开");
            if (model != null)
            {
                Width[4] = model.Width;
                Lenth[4] = model.Length;
            }
            else
            {
                Width[4] = "";
                Lenth[4] = "";
            }
 
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "8开");
            if (model != null)
            {
                Width[5] = model.Width;
                Lenth[5] = model.Length;
            }
            else
            {
                Width[5] = "";
                Lenth[5] = "";
            }
 
            model = bll_EC_CuttingPaperSpecBLL.SelectListByMemberIdAndParType(CurrentUser.MemberId, "其它");
            if (model != null)
            {
                Width[6] = model.Width;
                Lenth[6] = model.Length;
            }
            else
            {
                Width[6] = "";
                Lenth[6] = "";
            }
        
            return true;
        }
 
        //提交事件
        protected void btn_Submit_form(object sender, EventArgs e)
        {
            try
            {  
                #region 获取值并判断值是否正确
 
                string[] PSF_Forumsid = Request["PSF_Forumsid"].ToString2().Split(',');
 
                if (PSF_Forumsid.Length == 0)
                {
                    JavaScript.MessageBox("提交失败", this);
                    return;
                }
 
                string[] PSF_Component = Request["PSF_Component"].ToString2().Split(',');
                string[] PSF_PNum = Request["PSF_PNum"].ToString2().Split(',');
                string[] PSF_PressesDesk = Request["PSF_PressesDesk"].ToString2().Split(',');
                string[] PSF_PrintedColorPositive = Request["PSF_PrintedColorPositive"].ToString2().Split(',');
                string[] PSF_PrintedColorRear = Request["PSF_PrintedColorRear"].ToString2().Split(',');
                string[] PSF_Typesetting = Request["PSF_Typesetting"].ToString2().Split(',');
                string[] PSF_Typesettinghide = Request["PSF_Typesettinghide"].ToString2().Split(',');
                string[] PSF_PrintedCount = Request["PSF_PrintedCount"].ToString2().Split(',');
                string[] PSF_PrintedPositive = Request["PSF_PrintedPositive"].ToString2().Split(',');
                string[] PSF_LastNum = Request["PSF_LastNum"].ToString2().Split(',');
                //string[] PSF_SheetSource = Request["PSF_SheetSource"].ToString2().Split(',');
                //string[] PSF_SpecificationsSheet = Request["PSF_SpecificationsSheet"].ToString2().Split(',');
                //string[] PSF_EditionCount = Request["PSF_EditionCount"].ToString2().Split(',');
                string[] PSF_PaperSource = Request["PSF_PaperSource"].ToString2().Split(',');
                string[] PSF_PaperId = Request["PSF_PaperId"].ToString2().Split(',');
                string[] PMS_PaperCount1 = Request["PMS_PaperCount1"].ToString2().Split(',');
                string[] PSF_CTPId = Request["PSF_PaperId2"].ToString2().Split(',');
                string[] PSF_PSId = Request["PSF_PaperId3"].ToString2().Split(',');
                string[] PSF_PaperName = Request["PSF_PaperName"].ToString2().Split(',');
                string[] selPaperName = Request["selPaperName"].ToString2().Split(',');
                string[] PSF_MaterialSpecifications = Request["PSF_MaterialSpecifications"].ToString2().Split(',');
                string[] SelPaperSpec = Request["SelPaperSpec"].ToString2().Split(',');
 
                string[] PSF_BigPaperCount = Request["PSF_BigPaperCount"].ToString2().Split(',');
                string[] PSF_OpenSpecifications = Request["PSF_OpenSpecifications"].ToString2().Split(',');
                string[] PSF_OpenWidth = Request["PSF_OpenWidth"].ToString2().Split(',');
                string[] PSF_OpenWidthName = Request["PSF_OpenWidthName"].ToString2().Split(',');
                string[] PSF_OpenLength = Request["PSF_OpenLength"].ToString2().Split(',');
 
                string[] selPlateType = Request["selPlateType"].ToString2().Split(',');
                string[] CTPSpecName = Request["CTPSpecName"].ToString2().Split(',');
                string[] selCTPSpec = Request["selCTPSpec"].ToString2().Split(',');
                string[] selFilmSpec = Request["selFilmSpec"].ToString2().Split(',');
                string[] CTPCount = Request["CTPCount"].ToString2().Split(',');
                string[] PSF_PSBan = Request["PSF_PSBan"].ToString2().Split(',');
                string[] PSCount = Request["PSCount"].ToString2().Split(',');
 
                string[] PSF_Note = Request["PSF_Note"].ToString2().Split(',');
                string PSO_Work = Request["PSO_Work"].ToString2();
                string PSO_Remarks = Request["PSO_Remarks"].ToString2();
 
                string[] oldPSF_PaperId = Request["oldPSF_PaperId"].ToString2().Split(',');
                string[] oldPSF_BigPaperCount = Request["oldPSF_BigPaperCount"].ToString2().Split(',');
 
                //if (PSF_Forumsid.Length != PSF_Component.Length || PSF_Forumsid.Length != PSF_PNum.Length || PSF_Forumsid.Length != PSF_PressesDesk.Length || PSF_Forumsid.Length != PSF_PrintedColorPositive.Length || PSF_Forumsid.Length != PSF_PrintedColorRear.Length || PSF_Forumsid.Length != PSF_Typesetting.Length || PSF_Forumsid.Length != PSF_PrintedCount.Length || PSF_Forumsid.Length != PSF_PrintedPositive.Length || PSF_Forumsid.Length != PSF_LastNum.Length || PSF_Forumsid.Length != PSF_SheetSource.Length || PSF_Forumsid.Length != PSF_SpecificationsSheet.Length || PSF_Forumsid.Length != PSF_EditionCount.Length || PSF_Forumsid.Length != PSF_PaperSource.Length || PSF_Forumsid.Length != PSF_PaperId.Length || PSF_Forumsid.Length != PSF_PaperName.Length || PSF_Forumsid.Length != PSF_MaterialSpecifications.Length || PSF_Forumsid.Length != PSF_BigPaperCount.Length || PSF_Forumsid.Length != PSF_OpenSpecifications.Length || PSF_Forumsid.Length != PSF_OpenWidth.Length || PSF_Forumsid.Length != PSF_OpenLength.Length || PSF_Forumsid.Length != PSF_Note.Length)
                //{
                //    JavaScript.MessageBox("提交失败", this);
                //    return;
                //}
 
                #endregion
 
                EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
                string orderIdStr = Request["orderid"];
                if (string.IsNullOrEmpty(orderIdStr))
                {
                    CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                    return;
                }
                int? orderId = MyConvert.ConvertToInt32(orderIdStr);
                if (!orderId.HasValue)
                {
                    CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                    return;
                }
                EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.Value);
                if (null == _eC_OrderBasic)
                {
                    CY.WebForm.BasePage.JavaScript.MessageBox("订单不存在!", this);
                    return;
                }
                _eC_OrderBasic.DeliveryTime = this.txtDeliveryTime.Value.ToDateTime2();
                _eC_OrderBasicBLL.UpdateModel(_eC_OrderBasic);
               
                EC_SpecialOrders m_EC_SpecialOrders = bll_EC_SpecialOrdersBLL.GetModelByOrderId(orderId);
                if (m_EC_SpecialOrders == null || m_EC_SpecialOrders.Keyid == null)
                    m_EC_SpecialOrders = new EC_SpecialOrders();
 
                List<EC_SpecialForums> m_EC_SpecialForumsList = new List<EC_SpecialForums>();
                List<OA_Inventory> m_OA_InventoryList = new List<OA_Inventory>();
                List<OA_OutOfStorage> m_OA_OutOfStorageList = new List<OA_OutOfStorage>();
 
                for (int i = 0; i < PSF_Forumsid.Length; i++)
                {
                    EC_SpecialForums m_EC_SpecialForums = new EC_SpecialForums();
                    m_EC_SpecialForums.PSF_Component = PSF_Component[i].ToString2().Replace(",+-+,", ",");
                    if (PSF_PNum[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_PNum = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_PNum = PSF_PNum[i].ToInt32();
                    }
                    m_EC_SpecialForums.PSF_PressesDesk = PSF_PressesDesk[i].ToString2().Replace(",+-+,", ",");
                    m_EC_SpecialForums.PSF_PrintedColorPositive = PSF_PrintedColorPositive[i].ToString2().Replace(",+-+,", ",");
                    m_EC_SpecialForums.PSF_PrintedColorRear = PSF_PrintedColorRear[i].ToString2().Replace(",+-+,", ",");
                    if (PSF_PressesDesk[i].IndexOf("数码") >= 0)
                    {
                        m_EC_SpecialForums.PSF_Typesetting = PSF_Typesettinghide[i].ToString2().Replace(",+-+,", ",");
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_Typesetting = PSF_Typesetting[i].ToString2().Replace(",+-+,", ",");
                    }
                       
                    
                    if (PSF_PrintedCount[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_PrintedCount = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_PrintedCount = PSF_PrintedCount[i].ToInt32();
                    }
                    if (PSF_PrintedPositive[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_PrintedPositive = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_PrintedPositive = PSF_PrintedPositive[i].ToInt32();
                    }
                    if (PSF_LastNum[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_LastNum = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_LastNum = PSF_LastNum[i].ToInt32();
                    }
                    m_EC_SpecialForums.PSF_PaperSource = PSF_PaperSource[i].ToString2().Replace(",+-+,", ",");
                    if (m_EC_SpecialForums.PSF_PaperSource == "来自仓库")
                    {
                        m_EC_SpecialForums.PSF_PaperName = PSF_PaperName[i].ToString2().Replace(",+-+,", ",");
                        m_EC_SpecialForums.PSF_MaterialSpecifications = PSF_MaterialSpecifications[i].ToString2().Replace(",+-+,", ",");
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_PaperName = selPaperName[i].ToString2().Replace(",+-+,", ",");
                        m_EC_SpecialForums.PSF_MaterialSpecifications = SelPaperSpec[i].ToString2().Replace(",+-+,", ",");
                    }
                    
                    m_EC_SpecialForums.PSF_Forumsid = PSF_Forumsid[i].ToInt32();
                    //if (PSF_BigPaperCount[i].ToInt32() == null)
                    //{
                    //    m_EC_SpecialForums.PSF_BigPaperCount = 0;
                    //}
                    //else
                    //{
                    //    m_EC_SpecialForums.PSF_BigPaperCount = PSF_BigPaperCount[i].ToInt32();
                    //}
                    m_EC_SpecialForums.PSF_BigPaperCount = 0;
                    m_EC_SpecialForums.PSF_OpenSpecifications = PSF_OpenSpecifications[i].ToString2().Replace(",+-+,", ",");
                    if (PSF_PressesDesk[i].IndexOf("轮转")>=0)
                    {
                        if (PSF_OpenWidthName[i].ToInt32() == null)
                        {
                            m_EC_SpecialForums.PSF_OpenWidth = 0;
                        }
                        else
                        {
                            m_EC_SpecialForums.PSF_OpenWidth = PSF_OpenWidthName[i].ToInt32();
                        }
                    }
                    else
                    {
                        if (PSF_OpenWidth[i].ToInt32() == null)
                        {
                            m_EC_SpecialForums.PSF_OpenWidth = 0;
                        }
                        else
                        {
                            m_EC_SpecialForums.PSF_OpenWidth = PSF_OpenWidth[i].ToInt32();
                        }
                    }
                   
                   
                    if (PSF_OpenLength[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_OpenLength = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_OpenLength = PSF_OpenLength[i].ToInt32();
                    }
                    m_EC_SpecialForums.PSF_PlateSource = selPlateType[i].ToString2().Replace(",+-+,", ",");
                    if (m_EC_SpecialForums.PSF_PlateSource == "本厂CTP")
                    {
                        m_EC_SpecialForums.PSF_CTPSpecType = CTPSpecName[i].ToString2().Replace(",+-+,", ",");
                       
                        if(CTPCount[i].ToInt32() == null)
                        {
                            m_EC_SpecialForums.PSF_CTPCount = 0;
                        }
                        else
                        {
                            m_EC_SpecialForums.PSF_CTPCount = CTPCount[i].ToInt32();
                        }
                    }
                    else if (m_EC_SpecialForums.PSF_PlateSource == "自带CTP")
                    {
                        m_EC_SpecialForums.PSF_CTPSpecType = selCTPSpec[i].ToString2().Replace(",+-+,", ",");
                        m_EC_SpecialForums.PSF_CTPCount = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_CTPSpecType = selFilmSpec[i].ToString2().Replace(",+-+,", ",");
                        m_EC_SpecialForums.PSF_CTPCount = 0;
                    }
                    m_EC_SpecialForums.PSF_FilmType = "";   
                    m_EC_SpecialForums.PSF_PSSpec = PSF_PSBan[i].ToString2().Replace(",+-+,", ",");
                    if (PSCount[i].ToInt32() == null)
                    {
                        m_EC_SpecialForums.PSF_PSCount = 0;
                    }
                    else
                    {
                        m_EC_SpecialForums.PSF_PSCount = PSCount[i].ToInt32();
                    }
                    m_EC_SpecialForums.PSF_Note = PSF_Note[i].ToString2().Replace(",+-+,", ",");
                    m_EC_SpecialForums.PSF_PaperId = 0;
                    m_EC_SpecialForumsList.Add(m_EC_SpecialForums);
 
                    //int? PaperId = PSF_PaperId[i].ToInt32();
                    //int? CtpId = PSF_CTPId[i].ToInt32();
                    //int? PSId = PSF_PSId[i].ToInt32();
                    int? PaperCount = m_EC_SpecialForums.PSF_PrintedCount ?? 0;
                    int? iCTPCount = m_EC_SpecialForums.PSF_CTPCount ?? 0;
                    int? iPSCount = m_EC_SpecialForums.PSF_PSCount ?? 0;
 
                    //int? PaperCountOld = oldPSF_BigPaperCount[i].ToInt32() ?? 0;
 
                    string[] PSF_PaperIdForStore = new string[3];
                    PSF_PaperIdForStore[0] = PSF_PaperId[i].ToString2().Trim('|');
                    PSF_PaperIdForStore[1] = PSF_CTPId[i].ToString2().Trim('|');
                    PSF_PaperIdForStore[2] = PSF_PSId[i].ToString2().Trim('|');
                    if (m_EC_SpecialOrders.Keyid == null)
                    {
                        for (int j = 0; j < PSF_PaperIdForStore.Length; j++)
                        {
                            if (j == 0)
                            {
                                string[] PSF_PaperId_NEW = PSF_PaperIdForStore[0].Trim('|').Split('|');
                                string[] PMS_PaperCount1_NEW = PMS_PaperCount1[i].ToString2().Trim('|').Split('|');
 
                                foreach (var item in PSF_PaperId_NEW)
                                {
                                    OA_Inventory m_OA_InventoryOld = bll_OA_InventoryBLL.GetModelByKeyid(item.ToInt32());
                                    if (m_OA_InventoryOld != null && m_OA_InventoryOld.FirmId == CurrentUser.MemberId)
                                    {
                                        OA_OutOfStorage m_OA_OutOfStorageOld = new OA_OutOfStorage();
                                        m_OA_OutOfStorageOld.FirmId = CurrentUser.MemberId;
                                        m_OA_OutOfStorageOld.GoodsId = m_OA_InventoryOld.GoodsId;
                                        m_OA_OutOfStorageOld.CargoSpaceId = 0;
                                        m_OA_OutOfStorageOld.WarehouseId = m_OA_InventoryOld.WarehouseId;
                                        m_OA_OutOfStorageOld.InfoType = "确认出库";
                                        m_OA_OutOfStorageOld.SuppliersId = 0;
                                        m_OA_OutOfStorageOld.Price = 0;
                                        m_OA_OutOfStorageOld.Quantity = PMS_PaperCount1_NEW[Array.IndexOf(PSF_PaperId_NEW, item)].ToInt32() ?? 0;
                                        m_OA_OutOfStorageOld.AllMoney = 0;
                                        m_OA_OutOfStorageOld.LastUpdateTime = DateTime.Now;
                                        m_OA_OutOfStorageOld.Operator = CurrentUser.ShortName;
                                        m_OA_OutOfStorageOld.Remark = "";
                                        m_OA_OutOfStorageOld.TanPrice = 0;
                                        m_OA_OutOfStorageOld.BrandId = m_OA_InventoryOld.BrandId;
                                        m_OA_OutOfStorageOld.PaperWeightId = m_OA_InventoryOld.PaperWeightId;
                                        m_OA_OutOfStorageOld.SpecificationId = m_OA_InventoryOld.SpecificationId;
                                        m_OA_OutOfStorageList.Add(m_OA_OutOfStorageOld);
                                    }
                                }
                            }
                            else
                            {
                                OA_Inventory m_OA_Inventory = bll_OA_InventoryBLL.GetModelByKeyid(PSF_PaperIdForStore[j].ToInt32());
                                if (m_OA_Inventory != null && m_OA_Inventory.FirmId == CurrentUser.MemberId)
                                {
                                    OA_OutOfStorage m_OA_OutOfStorage = new OA_OutOfStorage();
                                    m_OA_OutOfStorage.FirmId = CurrentUser.MemberId;
                                    m_OA_OutOfStorage.GoodsId = m_OA_Inventory.GoodsId;
                                    m_OA_OutOfStorage.CargoSpaceId = 0;
                                    m_OA_OutOfStorage.WarehouseId = m_OA_Inventory.WarehouseId;
                                    m_OA_OutOfStorage.InfoType = "确认出库";
                                    m_OA_OutOfStorage.SuppliersId = 0;
                                    m_OA_OutOfStorage.Price = 0;
                                    if (j == 0)
                                    {
                                        m_OA_OutOfStorage.Quantity = PaperCount;
                                    }
                                    else if (j == 1)
                                    {
                                        m_OA_OutOfStorage.Quantity = iCTPCount;
                                    }
                                    else if (j == 3)
                                    {
                                        m_OA_OutOfStorage.Quantity = iPSCount;
                                    }
                                    m_OA_OutOfStorage.AllMoney = 0;
                                    m_OA_OutOfStorage.LastUpdateTime = DateTime.Now;
                                    m_OA_OutOfStorage.Operator = CurrentUser.ShortName;
                                    m_OA_OutOfStorage.Remark = "";
                                    m_OA_OutOfStorage.TanPrice = 0;
                                    m_OA_OutOfStorage.BrandId = m_OA_Inventory.BrandId;
                                    m_OA_OutOfStorage.PaperWeightId = m_OA_Inventory.PaperWeightId;
                                    m_OA_OutOfStorage.SpecificationId = m_OA_Inventory.SpecificationId;
                                    m_OA_OutOfStorageList.Add(m_OA_OutOfStorage);
                                }
                            }
                        }
                    }
                 }
                m_EC_SpecialOrders.LastUpdateTime = DateTime.Now;
                m_EC_SpecialOrders.Operator = CurrentUser.ShortName;
                m_EC_SpecialOrders.PSO_Remarks = this.txtPSO_Remarks.InnerText;
                m_EC_SpecialOrders.PSO_Work = this.txtPSO_Work.InnerText;
 
                if (m_EC_SpecialOrders.Keyid > 0)
                {
 
                    if (bll_EC_SpecialOrdersBLL.UpdateSpecialForums(m_EC_SpecialOrders, m_EC_SpecialForumsList, m_OA_InventoryList, m_OA_OutOfStorageList))
                        //JavaScript.MessageBox("操作成功", this);
                        JavaScript.RefreshDIVOpener(this);
                    else
                    {
                        InitData();
                        JavaScript.MessageBox("提交失败", this);
                    }
                }
                else
                {
                    m_EC_SpecialOrders.Memberid = CurrentUser.MemberId;
                    m_EC_SpecialOrders.OrderNum = 0;
                    m_EC_SpecialOrders.PO_OrderId = orderId;
                    m_EC_SpecialOrders.PO_OrderNum = _eC_OrderBasic.SellerOrderId;
                    m_EC_SpecialOrders.PSO_OrderNum = bll_EC_SpecialOrdersBLL.GetPSO_OrderNum(CurrentUser.MemberId);
                    m_EC_SpecialOrders.PSO_OrderPeople = CurrentUser.ShortName;
                    m_EC_SpecialOrders.PSO_OrderTime = DateTime.Now;
                    m_EC_SpecialOrders.IsPrint = 0;// 新增设为未打印
 
                    EC_OrderOperate m_EC_OrderOperate = new EC_OrderOperate();
                    m_EC_OrderOperate.LastUpdateTime = DateTime.Now;
                    m_EC_OrderOperate.OperateType = 3;
                    m_EC_OrderOperate.Operator = CurrentUser.ShortName;
                    m_EC_OrderOperate.OrderId = orderId;
                    m_EC_OrderOperate.Remark = "";
 
                    OA_OrderWorkListRelation m_OA_OrderWorkListRelation = new OA_OrderWorkListRelation();
                    m_OA_OrderWorkListRelation.OrderId = orderId;
                    m_OA_OrderWorkListRelation.RelationTargetId = 0;
                    m_OA_OrderWorkListRelation.RelationTypeId = 1; //专版1,合版2,后道外协3,整单外协4
 
                    //bll_EC_SpecialOrdersBLL.AddSpecialForums(m_EC_OrderOperate, m_EC_SpecialOrders, m_OA_OrderWorkListRelation, m_EC_SpecialForumsList, m_OA_InventoryList, m_OA_OutOfStorageList)
                    if (bll_EC_SpecialOrdersBLL.AddSpecialForums(m_EC_OrderOperate, m_EC_SpecialOrders, m_OA_OrderWorkListRelation, m_EC_SpecialForumsList, m_OA_InventoryList, m_OA_OutOfStorageList))
                    {
                        //JavaScript.MessageBox("操作成功", this);
                        JavaScript.RefreshDIVOpener(this);
                    }
                    else
                    {
                        InitData();
                        JavaScript.MessageBox("提交失败", this);
                    }
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("提交失败", this);
            }
        }
    }
}