duheng
2025-03-28 b266e82b9a377fa35a766f7a3a2f5aa95f3c9125
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
namespace HStation.WinFrmUI
{
    public partial class DeleteEqualEDlg : DevExpress.XtraEditors.XtraForm
    {
        public DeleteEqualEDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
            this.gridView2.SetNormalView();
        }
 
        /// <summary>
        /// 
        /// </summary>
        public event Func<List<double>, bool> ReloadDataEvent;
 
        private class CurrentViewModel
        {
            public double Eff { get; set; }
        }
 
        private List<CurrentViewModel> _eff_list = null;
        private List<double> _delete_id_list = null;
 
        /// <summary>
        /// 
        /// </summary>
        public void SetBindingData(List<double> list)
        {
            _eff_list = new List<CurrentViewModel>();
            _delete_id_list = new();
            if (list == null || !list.Any())
                return;
            _eff_list = list.OrderByDescending(x => x).Select(x => new CurrentViewModel()
            {
                Eff = x
            }).ToList();
 
            this.gridControl2.DataSource = _eff_list;
            this.gridControl2.RefreshDataSource();
        }
 
        //删除
        private void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (_eff_list == null || _eff_list.Count < 1)
                return;
            if (e.Column == this.colDelete)
            {
                var item = _eff_list.ElementAt(e.RowHandle);
                _delete_id_list.Add(item.Eff);
                _eff_list.RemoveAt(e.RowHandle);
                this.gridControl2.RefreshDataSource();
            }
 
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
 
            return true;
        }
 
        //确定
        private void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (_delete_id_list == null || !_delete_id_list.Any())
            {
                return;
            }
 
            if (!Valid())
            {
                return;
            }
 
            if (this.ReloadDataEvent == null)
                return;
 
            var bol = this.ReloadDataEvent.Invoke(_delete_id_list);
            if (!bol)
            {
                return;
            }
 
            this.DialogResult = DialogResult.OK;
            this.Close();
 
        }
 
    }
}