1
lu
2024-11-13 13e0b579eb4ad6151e2f27b822837be81d3f6143
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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using Gs.DevApp.DevFrm.Rpt;
using Gs.DevApp.DevFrm.Sys;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
 
namespace Gs.DevApp.UserControl
{
    public partial class UcToolBarMenu : XtraUserControl
    {
        public UcToolBarMenu()
        {
            InitializeComponent();
            btnAdd.ItemClick += BtnAdd_ItemClick;
            btnDel.ItemClick += BtnDel_ItemClick;
            btnEdit.ItemClick += BtnEdit_ItemClick;
            btnLoad.ItemClick += BtnLoad_ItemClick;
            btnSave.ItemClick += BtnSave_ItemClick;
            btnKG.ItemClick += BtnKG_ItemClick;
            btnEsc.ItemClick += BtnEsc_ItemClick;
            btnRole.ItemClick += BtnRole_ItemClick;
            btnQuery.ItemClick += BtnQuery_ItemClick;
            btnReport.ItemClick += BtnReport_ItemClick;
            btnDesign.ItemClick += BtnDesign_ItemClick;
            btnOut.ItemClick += BtnOut_ItemClick;
            btnIn.ItemClick += BtnIn_ItemClick;
            btnChk.ItemClick += BtnChk_ItemClick;
            btnFchk.ItemClick += BtnFchk_ItemClick;
            btnJianYan.ItemClick += BtnJianYan_ItemClick;
            btnFjianYan.ItemClick += BtnFjianYan_ItemClick;
            btnPiZhun.ItemClick += BtnPiZhun_ItemClick;
            btnLog.ItemClick += BtnLog_ItemClick;
            btnZhiLiangChk.ItemClick += BtnZhiLiangChk_ItemClick;
            btnZhiLiangFchk.ItemClick += BtnZhiLiangFchk_ItemClick;
            btnCaiGouChk.ItemClick += BtnCaiGouChk_ItemClick;
            btnCaiGouFchk.ItemClick += BtnCaiGouFchk_ItemClick;
            btnBoHui.ItemClick += BtnBoHui_ItemClick;
            var lst = new List<string>();
            foreach (BarItem item in barManager1.Items)
                if (item is BarLargeButtonItem largeButtonItem)
                    if (!string.IsNullOrEmpty(item.Caption) && item.Caption != "保存" && item.Caption != "刷新")
                        lst.Add(item.Caption);
            actions = lst;
        }
 
 
 
 
        /// <summary>
        ///     初始化按钮状态
        /// </summary>
        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            if (Parent != null) getNamespace();
        }
 
 
 
        private void BtnBoHui_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnBoHuiClick != null)
                btnBoHuiClick(this, e);
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定驳回参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定驳回重检吗?"))
            //    return;
            //_ckService("5");
        }
        private void BtnCaiGouFchk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnCaiGouFchkClick != null)
                btnCaiGouFchkClick(this, e);
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定采购反审核吗?"))
            //    return;
            //_ckService("-2");
        }
 
        private void BtnCaiGouChk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnCaiGouChkClick != null)
                btnCaiGouChkClick(this, e);
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定采购审核吗?"))
            //    return;
            //_ckService("2");
        }
 
        private void BtnZhiLiangFchk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnZhiLiangFchkClick != null)
                btnZhiLiangFchkClick(this, e);
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定质量反审核吗?"))
            //    return;
            //_ckService("-3");
        }
 
        private void BtnZhiLiangChk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnZhiLiangChkClick != null)
                btnZhiLiangChkClick(this, e);
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定质量审核吗?"))
            //    return;
            //_ckService("3");
        }
 
        private void BtnFchk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnFChkClick != null)
                btnFChkClick(this, e);
            else
                return;
 
            if (string.IsNullOrEmpty(guidKey))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
 
            if (string.IsNullOrEmpty(chkParameter))
            {
                MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
                return;
            }
 
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定反审核吗?"))
                return;
            _ckService(0.ToString());
        }
 
        private void BtnChk_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnChkClick != null)
                btnChkClick(this, e);
            else
                return;
 
            if (string.IsNullOrEmpty(guidKey))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
 
            if (string.IsNullOrEmpty(chkParameter))
            {
                MsgHelper.ShowError("没有指定审核参数,请联系开发人员获取支持!");
                return;
            }
 
            if (!MsgHelper.AskQuestion("你选择了1条数据,确定审核吗?"))
                return;
            _ckService(1.ToString());
        }
 
 
        private void BtnLog_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnLogClick != null) btnLogClick(this, e);
            else
                return;
            if (string.IsNullOrEmpty(guidKey))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            UserControl.ShowLogcs frm = new ShowLogcs(this.guidKey);
            frm.ShowDialog();
        }
 
        private void BtnPiZhun_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnPiZhunClick != null) btnPiZhunClick(this, e);
        }
 
        private void BtnFjianYan_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnFjianYanClick != null)
                btnFjianYanClick(this, e);
            else
                return;
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定撤回检验吗?"))
            //    return;
            //_ckService(0.ToString());
        }
 
        private void BtnJianYan_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnJianYanClick != null)
                btnJianYanClick(this, e);
            else
                return;
 
            //if (string.IsNullOrEmpty(guidKey))
            //{
            //    MsgHelper.Warning("请先选择你要操作的行!");
            //    return;
            //}
 
            //if (string.IsNullOrEmpty(chkParameter))
            //{
            //    MsgHelper.ShowError("没有指定检验参数,请联系开发人员获取支持!");
            //    return;
            //}
 
            //if (!MsgHelper.AskQuestion("你选择了1条数据,确定提交检验吗?"))
            //    return;
            //var _obj = new
            //{
            //    guid = guidKey,
            //    parameter = chkParameter
            //};
            //_ckService(1.ToString());
        }
 
        private async void BtnIn_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (string.IsNullOrEmpty(xlsInService))
            {
                MsgHelper.ShowError("没有指定导入服务,请联系开发人员获取支持!");
                return;
            }
 
            var openFileDialog = new OpenFileDialog();
            //openFileDialog.InitialDirectory = "c:\\";
            openFileDialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*";
            openFileDialog.Title = "选择文件";
            var result = openFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                var WebApiUrl = ConfigurationManager.AppSettings["WebApiUrl"] +
                                "Upload/UploadFile";
                var strJson =
                    await UtilityHelper.UploadFileAsync(openFileDialog
                        .FileName);
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                string filePath = _rtn.rtnData["filePath"].ToString();
                if (_rtn.rtnCode > 0)
                {
                    var _obj = filePath;
                    try
                    {
                        strJson = UtilityHelper.HttpPost("",
                            "XlsInOut/" + xlsInService,
                            JsonConvert.SerializeObject(_obj));
                        _rtn = UtilityHelper.ReturnToDynamic(strJson);
                        MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    }
                    catch (Exception ex)
                    {
                        MsgHelper.Warning("提示:" + ex.Message);
                    }
                }
            }
        }
 
        private void BtnOut_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (string.IsNullOrEmpty(this.xlsOutParameter))
            {
                ToolBox.MsgHelper.ShowError("没有指定导出存储过程,请联系开发人员获取支持!");
                return;
            }
            using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.Description = "选择导出文件的保存路径";
                DialogResult dialogResult = folderBrowserDialog.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    string _folder = folderBrowserDialog.SelectedPath;
                    var _obj = new Gs.DevApp.Entity.XlsOutModel(this.xlsOutParameter);
                    try
                    {
                        string strJson = UtilityHelper.HttpPost("", "XlsInOut/XlsOutView", JsonConvert.SerializeObject(_obj));
                        ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                        if (_rtn.rtnCode > 0)
                        {
                            string _file = _rtn.rtnData.fileUrl.ToString();
                            string _folderName = _folder + "\\" + _file.Replace("down/", "");
                            string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + _file;
                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(_url, _folderName);
                            }
                            ToolBox.MsgHelper.ShowInformation("导出成功!");
                        }
                        else
                        {
                            ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                        }
                    }
                    catch (Exception ex)
                    {
                        ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                    }
                }
            }
        }
 
        private void BtnReport_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnReportClick != null)
                btnReportClick(this, e);
            else
                return;
 
            if (rptParameter == "return false")
                return;
            if (string.IsNullOrEmpty(rptParameter))
            {
                MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!");
                return;
            }
            var _bl = false;
            _bl = _ckRptService();
            if (_bl)
            {
                var frm = new RptPreview(guidKey, rptParameter);
                frm.ShowDialog();
                return;
            }
 
            MsgHelper.ShowError("没有设计模板,请先设计模板!");
        }
 
        private void BtnDesign_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnDesignClick != null)
                btnDesignClick(this, e);
            else
                return;
 
            if (string.IsNullOrEmpty(rptParameter))
            {
                MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!");
                return;
            }
            var _bl = false;
            _bl = _ckRptService();
            //如果已经有模板了,直接打开设置模板
            if (_bl)
            {
                var frm = new EasyRptDesign(guidKey, rptParameter);
                frm.ShowDialog();
                return;
            }
            //否则向导设计模板
            var rptWizard = new ShowRptWizard(guidKey, rptParameter);
            rptWizard.ShowDialog();
        }
 
        private void BtnQuery_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnQueryClick != null) btnQueryClick(this, e);
        }
 
        private void BtnEsc_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (MsgHelper.AskQuestion("确定要要取消吗?"))
            {
                var lst = new List<string>();
                lst.Add(btnAdd.Name);
                lst.Add(btnEdit.Name);
                lst.Add(btnLoad.Name);
                lst.Add(btnDel.Name);
                lst.Add(btnRole.Name);
                lst.Add(btnQuery.Name);
                lst.Add(btnReport.Name);
                lst.Add(btnDesign.Name);
                lst.Add(btnChk.Name);
                lst.Add(btnFchk.Name);
                lst.Add(btnJianYan.Name);
                lst.Add(btnFjianYan.Name);
                lst.Add(btnOut.Name);
                lst.Add(btnIn.Name);
                lst.Add(btnLog.Name);
                lst.Add(btnPiZhun.Name);
                _enabledBtn(lst);
                if (btnEscClick != null) btnEscClick(this, e);
            }
        }
 
        private void BtnKG_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnKGClick != null) btnKGClick(this, e);
        }
 
        private void BtnSave_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnSaveClick != null)
            {
                btnSaveClick(this, e);
                if (isSetBtn)
                {
                    var lst = new List<string>();
                    lst.Add(btnAdd.Name);
                    lst.Add(btnEdit.Name);
                    lst.Add(btnEsc.Name);
                    _enabledBtn(lst);
                }
            }
        }
 
        private void BtnLoad_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnLoadClick != null)
                //List<string> lst = new List<string>();
                //lst.Add(btnRole.Name);
                //setBtn(lst);
                btnLoadClick(this, e);
        }
 
        private void BtnEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            var lst = new List<string>();
            lst.Add(btnSave.Name);
            lst.Add(btnEsc.Name);
            _enabledBtn(lst);
            if (btnEdtClick != null) btnEdtClick(this, e);
        }
 
        private void BtnDel_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (btnDelClick != null) btnDelClick(this, e);
        }
 
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            var lst = new List<string>();
            lst.Add(btnSave.Name);
            lst.Add(btnEsc.Name);
            _enabledBtn(lst);
            if (btnAddClick != null) btnAddClick(this, e);
        }
 
        private void BtnRole_ItemClick(object sender, ItemClickEventArgs e)
        {
            //List<string> lst = new List<string>();
            //lst.Add(btnSave.Name);
            //lst.Add(btnEsc.Name);
            //setBtn(lst);
            if (btnRoleClick != null) btnRoleClick(this, e);
        }
 
        private void _enabledBtn(List<string> lstBtn)
        {
            foreach (BarItem item in barManager1.Items)
                if (item is BarLargeButtonItem largeButtonItem)
                {
                    if (lstBtn.Contains(item.Name))
                        largeButtonItem.Enabled = true;
                    else
                        largeButtonItem.Enabled = false;
                }
        }
 
        /// <summary>
        ///     根据命名空间和权限,读取该窗体下面的按钮集合
        /// </summary>
        private void getNamespace()
        {
            var _formNamespace = "";
            Control parentControl = this;
            while (parentControl.Parent != null)
            {
                if (parentControl.Parent is Form parentForm)
                {
                    var formType = parentForm.GetType();
                    _formNamespace = formType.FullName;
                    break;
                }
 
                parentControl = parentControl.Parent;
            }
 
            var _obj = new
            {
                userGuid = LoginInfoModel.CurrentUser.LoginUserGuid,
                orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid,
                formNamespace = _formNamespace
            };
            var strReturn = "";
            try
            {
                strReturn = UtilityHelper.HttpPost("",
                    "Role/GetListByUserOrgSpace",
                    JsonConvert.SerializeObject(_obj));
                var dd = UtilityHelper.ReturnToList(strReturn);
                var dt = dd.rtnData;
                var _enabledList = new List<string>();
                foreach (BarItem item in barManager1.Items)
                {
                    ///具有联动关系的按钮(增加),
                    if (item.Caption == "增加")
                    {
                        var ld1 = dt.AsEnumerable().Any(
                            row => row.Field<string>("name") == "增加"
                            //|| row.Field<string>("name") == "修改"
                        );
                        if (ld1)
                        {
                            btnEsc.Visibility = btnSave.Visibility =
                                btnLoad.Visibility = BarItemVisibility.Always;
                            btnAdd.Visibility = BarItemVisibility.Always;
                            _enabledList.Add(item.Name);
                            continue;
                        }
                    }
 
                    ///具有联动关系的按钮(修改),
                    if (item.Caption == "修改")
                    {
                        var ld1 = dt.AsEnumerable().Any(
                            row => row.Field<string>("name") == "修改"
                        );
                        if (ld1)
                        {
                            btnEsc.Visibility = btnSave.Visibility =
                                btnLoad.Visibility = BarItemVisibility.Always;
                            btnEdit.Visibility = BarItemVisibility.Always;
                            _enabledList.Add(item.Name);
                            continue;
                        }
                    }
 
                    ///具有联动关系的按钮(查询),
                    var ld2 = dt.AsEnumerable().Any(
                        row => row.Field<string>("name") == "查询"
                    );
                    if (ld2)
                        if (item.Caption == "刷新")
                        {
                            item.Visibility = BarItemVisibility.Always;
                            //准备启用
                            _enabledList.Add(item.Name);
                            continue;
                        }
 
                    ///具有联动关系的按钮(提交检验),
                    //if (item.Caption == "提交检验")
                    //{
                    //    var ld1 = dt.AsEnumerable().Any(
                    //        row => row.Field<string>("name") == "提交检验"
                    //    );
                    //    if (ld1)
                    //    {
                    //        btnJianYan.Visibility = btnFjianYan.Visibility =
                    //            btnLoad.Visibility = BarItemVisibility.Always;
                    //        btnJianYan.Visibility = BarItemVisibility.Always;
                    //        _enabledList.Add(item.Name);
                    //        continue;
                    //    }
                    //}
 
                    //按钮是否在权限表中
                    var exists = dt.AsEnumerable().Any(row =>
                        row.Field<string>("name") == item.Caption);
                    if (exists)
                    {
                        item.Visibility = BarItemVisibility.Always;
                        //准备启用
                        var _btnName =
                            _FindBarLargeButtonItemByCaption(item.Caption);
                        if (!string.IsNullOrEmpty(_btnName))
                            _enabledList.Add(_btnName);
                    }
                }
 
                //默认启用的按钮
                _enabledList.Add(btnLoad.Name);
                _enabledBtn(_enabledList);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
 
        /// <summary>
        ///     根据文字,查找按钮name
        /// </summary>
        /// <param name="caption"></param>
        /// <returns></returns>
        private string _FindBarLargeButtonItemByCaption(string caption)
        {
            foreach (BarItem item in barManager1.Items)
                if (item is BarLargeButtonItem largeButtonItem &&
                    largeButtonItem.Caption == caption)
                    return largeButtonItem.Name;
            return null;
        }
 
        private bool _ckRptService()
        {
            try
            {
                var _obj = new
                {
                    guid = guidKey,
                    rptParameter,
                    isDesign = 1
                };
                var strJson = UtilityHelper.HttpPost("", "Report/GetRptData",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0) return true;
                return false;
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                return true;
            }
 
            return false;
        }
 
        private void _ckService(string _ckValue)
        {
            var _obj = new
            {
                guid = guidKey,
                parameter = chkParameter,
                ckValue = _ckValue
            };
            var strJson = UtilityHelper.HttpPost("", "General/GeneralCheck",
                JsonConvert.SerializeObject(_obj));
            var _rtn = UtilityHelper.ReturnToDynamic(strJson);
            MsgHelper.Warning("提示:" + _rtn.rtnData["outMsg"].ToString());
            if (_rtn.rtnCode > 0)
            {
            }
        }
 
        #region 公共事件
 
        /// <summary>
        ///     新增
        /// </summary>
        public event EventHandler btnAddClick;
 
        /// <summary>
        ///     删除
        /// </summary>
        public event EventHandler btnDelClick;
 
        /// <summary>
        ///     修改
        /// </summary>
        public event EventHandler btnEdtClick;
 
        /// <summary>
        ///     刷新
        /// </summary>
        public event EventHandler btnLoadClick;
 
        /// <summary>
        ///     保存
        /// </summary>
        public event EventHandler btnSaveClick;
 
        /// <summary>
        ///     取消
        /// </summary>
        public event EventHandler btnEscClick;
 
        /// <summary>
        ///     开工
        /// </summary>
        public event EventHandler btnKGClick;
 
        /// <summary>
        ///     权限
        /// </summary>
        public event EventHandler btnRoleClick;
 
        /// <summary>
        ///     查询
        /// </summary>
        public event EventHandler btnQueryClick;
 
        /// <summary>
        ///     审核
        /// </summary>
        public event EventHandler btnChkClick;
 
        /// <summary>
        ///     反审核
        /// </summary>
        public event EventHandler btnFChkClick;
 
 
        /// <summary>
        ///     检验
        /// </summary>
        public event EventHandler btnJianYanClick;
 
        /// <summary>
        ///     反检验
        /// </summary>
        public event EventHandler btnFjianYanClick;
 
 
        /// <summary>
        ///    批准
        /// </summary>
        public event EventHandler btnPiZhunClick;
 
 
        /// <summary>
        ///   日志
        /// </summary>
        public event EventHandler btnLogClick;
 
 
        /// <summary>
        ///   采购审核
        /// </summary>
        public event EventHandler btnCaiGouChkClick;
 
        /// <summary>
        ///   采购反审核
        /// </summary>
        public event EventHandler btnCaiGouFchkClick;
 
        /// <summary>
        ///   质量审核
        /// </summary>
        public event EventHandler btnZhiLiangChkClick;
 
 
        /// <summary>
        ///   质量反审核
        /// </summary>
        public event EventHandler btnZhiLiangFchkClick;
 
        /// <summary>
        ///   驳回
        /// </summary>
        public event EventHandler btnBoHuiClick;
 
        /// <summary>
        /// 设置报表
        /// </summary>
        public event EventHandler btnDesignClick;
 
        /// <summary>
        /// 报表
        /// </summary>
        public event EventHandler btnReportClick;
        #endregion
 
        #region 公共属性
 
        public bool isSetBtn { get; set; }
 
        /// <summary>
        ///     关键字,一般是主键
        /// </summary>
        public string guidKey { get; set; }
 
        /// <summary>
        ///     按钮名称集合
        /// </summary>
        public List<string> actions { get; }
 
        /// <summary>
        ///     报表,在数据库中要唯一,如:存储过程名{入参1名|入参值,入参2名|入参值}
        /// </summary>
        public string rptParameter { get; set; }
 
        /// <summary>
        /// 导出,视图名,如:存储过程名{入参1名|入参值,入参2名|入参值}
        /// </summary>
        public string xlsOutParameter { get; set; }
 
        /// <summary>
        ///     导入
        /// </summary>
        public string xlsInService { get; set; }
 
        /// <summary>
        ///     审核参数,表名,字段名,如:MES_HOLIDAY(表名),check_date(时间),check_status(状态),check_by(审核人),存储过程名
        /// </summary>
        public string chkParameter { get; set; }
 
        #endregion
 
 
    }
}