fqc
lu
2025-05-06 437425784b7612e10d4a54bd64905c508347514d
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
using Gs.DevApp.DevFrm.Work;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm.FQC
{
    public partial class Frm_FqcDetect01 : DevExpress.XtraEditors.XtraForm
    {
        string _strTag= "N:不合格";
        string _webServiceName = "FqcManager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        public Frm_FqcDetect01()
        {
            InitializeComponent();
            this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick;
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx3);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "fsubmitTxt", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            }, tips);
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            {
                getModel(value, "0");
            }, (value) =>
            {
                getPageList(this.pageBar1.CurrentPage);
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            txtJianYan.KeyDown += TxtJianYan_KeyDown;
            this.btnLoad.Click += BtnLoad_Click;
            xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged;
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
            btnIpt.Click += BtnIpt_Click;
            txt_suppId.getSuppler("");
            //选择工单
            txt_lotNo.Click += (s, e) =>
            {
                var frm = new SelectFqcDaa();
                frm.UpdateParent += (ss, ee) =>
                {
                    try
                    {
                        var lst = new List<dynamic>();
                        lst = ee.DynamicList;
                        txt_itemId.Text = lst[0].itemId;
                        txt_itemModel.Text = lst[0].itemModel;
                        txt_itemName.Text = lst[0].itemName;
                        txt_itemNo.Text = lst[0].itemNo;
                        txt_lotNo.Text = lst[0].gdbh;
                        txt_lineName.Text = lst[0].lineName;
                        txt_lineId.Text = lst[0].lineId;
                        txt_checkStates.Text = "W:未知";
                        txt_fcheckResu.Text = "W:未知";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
            };
            //选择箱码
            txt_kbList.Click += (s, e) =>
            {
                string _lotNo = txt_lotNo.Text.Trim();
                if (string.IsNullOrEmpty(_lotNo))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请先选择工单!");
                    return;
                }
                var frm = new SelectFqcBox(_lotNo);
                frm.UpdateParent += (ss, ee) =>
                {
                    try
                    {
                        var lst = new List<dynamic>();
                        lst = ee.DynamicList;
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        decimal kbSl = 0;
                        foreach (var item in lst)
                        {
                            if (sb.Length > 0)
                                sb.Append(",");
                            sb.Append(item.itemBarcode);
                            kbSl += decimal.Parse(item.sl.ToString());
                        };
                        txt_kbList.Text = sb.ToString();
                        txt_kbSl.Text = kbSl.ToString();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
            };
            // 读取缺陷等级
            getRptDefectLevel();
        }
 
        /// <summary>
        /// 批量录入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void BtnIpt_Click(object sender, EventArgs e)
        {
            bool bl = btnLoad.Enabled;
            Gs.DevApp.DevFrm.QC.Frm_MesQaItemsDetect01Input frm = new Gs.DevApp.DevFrm.QC.Frm_MesQaItemsDetect01Input(this.lbGuid.Text.Trim(), bl);
            frm.ShowDialog();
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            Task.Delay(100);
            getPageList(1);
        }
        private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle >= 0)
            {
                DataRow row = gvMx1.GetDataRow(e.FocusedRowHandle);
                string rowGuid = row["guid"].ToString();
                if (string.IsNullOrEmpty(rowGuid))
                    return;
                getList12(rowGuid);
            }
        }
        /// <summary>
        ///  重新加载检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (!MsgHelper.AskQuestion("确定重新加载检验项目吗,该操作将会清空之前的检验记录?"))
                return;
            string strGuid = lbGuid.Text.Trim();
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            var _obj = new
            {
                guid = strGuid,
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", "MesQaItemsDetect01Manager/ReloadModel5", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    getModel(lbGuid.Text.Trim(), "0");
                }
                else
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 输入检验事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TxtJianYan_KeyDown(object sender, KeyEventArgs e)
        {
            int intHandle = this.gvMx1.FocusedRowHandle;
            if (intHandle < 0)
            {
                ToolBox.MsgHelper.Warning("提示:请选择检验项目!");
                return;
            }
            if (e.KeyCode == Keys.Enter)
            {
                string guid5 = this.gvMx1.GetDataRow(intHandle)["guid"].ToString();
                string _strCmd = txtJianYan.Text.Trim().ToUpper();
                string _strOK = "OK";
                string _strNG = "NG";
                if (!(_strCmd.StartsWith(_strOK) || _strCmd.StartsWith(_strNG)))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!");
                    return;
                }
                if (!_strCmd.Contains("-"))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或 NG 命令!");
                    return;
                }
                string[] _ary = _strCmd.Split('-');
                if (_ary.Length != 2)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("命令输入错误:请正确使用OK 或  NG 命令!");
                    return;
                }
                var _obj = new
                {
                    inOrderGuid1 = UtilityHelper.ToGuid(lbGuid.Text.Trim()), ////这是检验单guid
                    inOrderGuid5 = guid5,//这是抽样的guid
                    inP1 = _strCmd,//或者0k-19,或者ng-19
                };
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                       "MesQaItemsDetect01Manager/EdtModel12",
                        JsonConvert.SerializeObject(_obj));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        getModel(lbGuid.Text.Trim(), guid5);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg);
                    }
                    txtJianYan.Text = "";
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
 
        /// <summary>
        /// 分页事件
        /// </summary>
        /// <param name="curPage"></param>
        /// <param name="pageSize"></param>
        private void PageBar1_PagerEvent(int curPage, int pageSize)
        {
            getPageList(curPage);
        }
        /// <summary>
        /// 查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
            gridView1.ActiveFilter.Clear();
            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
            var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
        /// <summary>
        /// 查询回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
        {
            _filterList = e.FilterList;
            getPageList(1);
        }
        /// <summary>
        /// 日志事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLogClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
        ///提交检验事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnJianYanClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1, "releaseNo");
            toolBarMenu1.guidKey = rowGuid;
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定提交检验吗?"))
                return;
            if (txt_fcheckResu.Text.Trim() == _strTag)
            {
                if (string.IsNullOrEmpty(txt_msg.TextTxt.Trim()))
                {
                    MsgHelper.Warning("单据为不合格时,请填写违规信息!");
                    return;
                }
                string _txt_fngHandle = txt_fngHandle.Text.Trim();
                string _txt_fmrmode = txt_fmrmode.GetCode();
                string _txt_fzrId = txt_fzrId.GetId();
                string _txt_workNo = txt_workNo.Text.Trim();
                string _txt_msg = txt_msg.TextTxt;
                string _txt_zrType = txt_zrType.Text.Trim();
                if (txt_fngHandle.SelectedIndex <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("请选择处置结果!");
                    txt_fngHandle.Focus();
                    return;
                }
                if (txt_zrType.SelectedIndex <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("请选择责任判定!");
                    txt_zrType.Focus();
                    return;
                }
                if (_txt_fzrId.Length <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("请选择责任人!");
                    txt_fzrId.Focus();
                    return;
                }
                //当处置结果为反工时,要选择工序和反工编号
                if (txt_fngHandle.SelectedIndex == 1)
                {
                    if (string.IsNullOrEmpty(_txt_workNo))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("请填写反工单号!");
                        txt_workNo.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(_txt_fmrmode))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("请填选择反工工序!");
                        txt_fmrmode.Focus();
                        return;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(_txt_workNo))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("不需要填写反工单号!");
                        txt_workNo.Focus();
                        return;
                    }
                    if (!string.IsNullOrEmpty(_txt_fmrmode))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("不需要选择反工工序!");
                        txt_fmrmode.Focus();
                        return;
                    }
                }
            };
 
            var _obj = new
            {
                guid = rowGuid,
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnData.outMsg);
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim(), "0");
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    int _inFieldValue = 1;
                    UtilityHelper.SetCheckIco(gridView1, "fsubmitTxt", "", "iqcDate", picCheckBox, this, _inFieldValue.ToString());
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 取消事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
        {
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 1);
        }
 
        /// <summary>
        /// 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
        {
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
                return;
            var _obj = new
            {
                guid = rowGuid,
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + "DeleteModelOrMx",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 0)
                    { }
                    else
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
                    getPageList(this.pageBar1.CurrentPage);
                }
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 刷新事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            if (xtraTabControl1.SelectedTabPageIndex == 1)
                getModel(lbGuid.Text.Trim(), "0");
            else
            {
                //_filterList.Clear();
                //if (gridView1.ActiveFilter.Count > 0)
                //{
                //    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                //    gridView1.ActiveFilter.Clear();
                //    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                //}
                //getPageList(1);
                getPageList(this.pageBar1.CurrentPage);
            }
        }
        /// <summary>
        /// 新增事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
        {
            lbGuid.Text = "";
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gridViews);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            this.ucUpFileList1.pGuid = "";
            this.ucChouJianList1.pGuid = "";
        }
        /// <summary>
        /// 修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            toolBarMenu1.currentAction = "edit";
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1, "releaseNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
            if (xtraTabControl1.SelectedTabPageIndex == 1)
            {
                getModel(rowGuid, "0");
            }
            else
            {
                List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                gvList.Add(gvMx1);
                gvList.Add(gvMx2);
                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
                this.setEable(true);
            }
        }
 
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            string _txt_djType = txt_djType.Text.Trim();//单据类型
            string _txt_fbatchQty = txt_fbatchQty.Text.Trim();//抽检数量
            string _txt_lifnr = txt_lifnr.Text.Trim();//客户订单
            string _txt_suppId = txt_suppId.GetId();//客户id
            string _txt_lineId = "";//产线
            string _txt_itemId = "";//产品
            string _txt_remarks = txt_remarks.Text.Trim();//备注
            string _txt_epTag = txt_epTag.Text.Trim();//环保
            string _txt_msg = txt_msg.TextTxt;//异常
            string _txt_fmanageNo = txt_fmanageNo.Text.Trim();//流程编号
            string _txt_lotNo1 = txt_lotNo1.Text.Trim();//送检批号
            string _txt_lotNo = txt_lotNo.Text.Trim();//生产工单
            string _kbList = txt_kbList.Text.Trim();
            if (txt_djType.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("单据类型不能为空!");
                txt_djType.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_lotNo.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("工单号不能为空!");
                txt_lotNo.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_kbList.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("送检箱码不能为空!");
                txt_kbList.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_kbSl.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("送检数量不能为空!");
                txt_kbList.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_txt_fbatchQty.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("抽检数量不能为空!");
                txt_fbatchQty.Focus();
                return;
            }
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric2(_txt_fbatchQty))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请输入正确的抽检数量!");
                txt_fbatchQty.Focus();
                return;
            }
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric2(txt_kbSl.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请输入正确的送检数量!");
                txt_kbList.Focus();
                return;
            }
            if (Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(_txt_fbatchQty) > Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(txt_kbSl.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("抽检数量不能大于送检数量!");
                txt_fbatchQty.Focus();
                return;
            }
            //当不合格时的检查
            string _txt_fngHandle = txt_fngHandle.Text.Trim();
            string _txt_fmrmode = txt_fmrmode.GetCode();
            string _txt_fzrId = txt_fzrId.GetId();
            string _txt_workNo = txt_workNo.Text.Trim();
            string _txt_zrType = txt_zrType.Text.Trim();
            if (txt_fcheckResu.Text.Trim() == _strTag)
            {
                if (string.IsNullOrEmpty(txt_msg.TextTxt.Trim()))
                {
                    MsgHelper.Warning("当不合格时,请填写违规信息!");
                    txt_msg.Focus();
                    return;
                }
               
                if (txt_fngHandle.SelectedIndex <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("当不合格时,请选择处置结果!");
                    txt_fngHandle.Focus();
                    return;
                }
                if (txt_zrType.SelectedIndex <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("当不合格时,请选择责任判定!");
                    txt_zrType.Focus();
                    return;
                }
                if (_txt_fzrId.Length <= 0)
                {
                    Gs.DevApp.ToolBox.MsgHelper.Warning("当不合格时,请选择责任人!");
                    txt_fzrId.Focus();
                    return;
                }
                //当处置结果为反工时,要选择工序和反工编号
                if (txt_fngHandle.SelectedIndex == 1)
                {
                    if (string.IsNullOrEmpty(_txt_workNo))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("当不合格时,请填写反工单号!");
                        txt_workNo.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(_txt_fmrmode))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("当不合格时,请填选择反工工序!");
                        txt_fmrmode.Focus();
                        return;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(_txt_workNo))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("不需要填写反工单号!");
                        txt_workNo.Focus();
                        return;
                    }
                    if (!string.IsNullOrEmpty(_txt_fmrmode))
                    {
                        Gs.DevApp.ToolBox.MsgHelper.Warning("不需要选择反工工序!");
                        txt_fmrmode.Focus();
                        return;
                    }
                }
            };
 
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                djType = _txt_djType,//单据类型
                fbatchQty = _txt_fbatchQty,//抽检数量
                lifnr = _txt_lifnr,//客户订单
                suppId = _txt_suppId,//客户id
                lineId = _txt_lineId,//产线
                itemId = _txt_itemId,//产品
                remarks = _txt_remarks,//备注
                epTag = _txt_epTag,//环保
                msg = _txt_msg,//异常
                fmanageNo = _txt_fmanageNo,//流程编号
                lotNo1 = _txt_lotNo1,//送检批号
                lotNo = _txt_lotNo,//生产工单
                kbList = _kbList,
                fngHandle = _txt_fngHandle,
                fzrId = _txt_fzrId,
                workNo = _txt_workNo,
                fmrmode = _txt_fmrmode,
                zrType = _txt_zrType,
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            for (var i = 0; i < gvMx1.DataRowCount; i++)
            {
                var row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    Guid _guid = UtilityHelper.ToGuid(row["guid"].ToString());
                    string _defectLevel = row["defectLevel"].ToString();
                    string _defectDetails = row["defectDetails"].ToString();
                    string _fcheckResu = row["fcheckResu"].ToString();
                    if (_fcheckResu == _strTag)
                    {
                        if (string.IsNullOrEmpty(_defectLevel))
                        {
                            MsgHelper.ShowError("请选择缺陷等级!");
                            return;
                        }
                        if (string.IsNullOrEmpty(_defectDetails))
                        {
                            MsgHelper.ShowError("请填写缺陷描述!");
                            return;
                        }
                        _obj.list.Add(new
                        {
                            guid5 = _guid,
                            defectLevel = _defectLevel,
                            defectDetails = _defectDetails,
                        });
                    }
                }
            }
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    lbGuid.Text = _rtn.rtnData.outGuid;
                    txt_releaseNo.Text = _rtn.rtnData.outNo;
                    toolBarMenu1.isSetBtn = true;
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
                    this.setEable(false);
                    toolBarMenu1.currentAction = "";
                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                    getModel(lbGuid.Text, "0");
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curPage">第几页</param>
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            // _sbSqlWhere += " and isnull(fsubmit,0)=0";
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "release_no", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
            {
                string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain1.BindingContext = new BindingContext();
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
                    pageBar1.RecordCount = dd.rtnData.total;//总记录数
                }
                else
                {
                    ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void getModel(string strGuid, string guid5)
        {
            bool isEdit = false;
            if (toolBarMenu1.currentAction == "add") return;
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            var _obj = new
            {
                guid = strGuid,//主建
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    lbGuid.Text = strGuid;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    setEable(isEdit);
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    foreach (var a in _job["rtnData"]["list5"])
                    {
                        array.Add(a);
                    }
                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
                    if (dt.Rows.Count > 0)
                    {
                        gcMx1.DataSource = null;
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        ucUpFileList1.pGuid = lbGuid.Text.Trim();
                        ucChouJianList1.pGuid = lbGuid.Text.Trim();
                        if (guid5.Length > 10)
                        {
                            int rowHandle = 0;
                            rowHandle = gvMx1.LocateByValue(1, gvMx1.Columns["guid"], guid5);
                            if (rowHandle < 0)
                                rowHandle = 0;
                            gvMx1.FocusedRowHandle = rowHandle + 1;
                        }
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 选项卡切换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void XtraTabControl2_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            if (e.Page.Name == "tabMxPage2")
            {
                ucChouJianList1.getList14();
 
            }
            if (e.Page.Name == "tabMxPage3")
            {
                ucUpFileList1.getFileList();
            }
        }
        /// <summary>
        /// 根据检验项目读取抽样结果 
        /// </summary>
        /// <param name="guid5"></param>
        private void getList12(string guid5)
        {
            var _obj = new
            {
                parentGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                guid = UtilityHelper.ToGuid(guid5), //主建
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel12", JsonConvert.SerializeObject(_obj));
                JObject _job = JObject.Parse(strJson);
                JArray array = new JArray();
                foreach (var a in _job["rtnData"]["list"])
                {
                    array.Add(a);
                }
                DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
                gcMx2.BindingContext = new BindingContext();
                gcMx2.DataSource = dt;
                gcMx2.ForceInitialize();
                gvMx2.BestFitColumns();
                JArray array1 = new JArray();
                foreach (var a in _job["rtnData"]["list2"])
                {
                    array1.Add(a);
                }
                DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
                gcMx3.BindingContext = new BindingContext();
                gcMx3.DataSource = dt1;
                gcMx3.ForceInitialize();
                gvMx3.BestFitColumns();
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        private void setEable(bool bl)
        {
            txtJianYan.ReadOnly = !bl;
            btnLoad.Enabled = bl;
            ucChouJianList1.IsReadOnly(!bl);
            btnIpt.Text = (bl == true ? "录入样本" : "查看样本");
 
        }
 
        /// <summary>
        /// 读取缺陷等级
        /// </summary>
        /// <param name="curPage"></param>
        private void getRptDefectLevel()
        {
            string _where = " and 1=1 and  s_type='缺陷等级'";
            var pgq = new PageQueryModel(1, 999999, "a.defect_code", "asc", "", _where);
            var json = JsonConvert.SerializeObject(pgq);
            try
            {
                var strReturn = UtilityHelper.HttpPost("", "MesDefectCodeManager/GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                var dt = dd.rtnData.list;
                foreach (DataRow dr in dt.Rows)
                {
                    rptDefectLevel.Items.Add(dr["defectName"].ToString());
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 选择缺陷描述
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptDefectDetails_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            UcDictionarySelect frm = new UcDictionarySelect("缺陷描述", " s_type='FQC缺陷描述'");
            frm.UpdateParent += (ss, ee) =>
            {
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                var lst = ee.DynamicList;
                foreach (dynamic dym in lst)
                {
                    if (stringBuilder.Length > 0)
                        stringBuilder.Append("|");
                    stringBuilder.Append(dym.dicTxt);
                }
                gvMx1.SetFocusedRowCellValue("defectDetails", stringBuilder.ToString());
                // this.TextTxt = ;
            };
            frm.ShowDialog();
        }
    }
}