duheng
2024-09-22 9ffb31c233f3b4891550293294c2ee716f77b42a
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
namespace HStation.WinFrmUI
{
    public partial class FourLinkMatchingCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public FourLinkMatchingCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView(30);
            this.gridView1.OptionsView.ShowDetailButtons = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
        }
 
        private List<FourLinkFormViewModel> _allBindingList = new List<FourLinkFormViewModel>();
 
        /// <summary>
        /// 点击事件
        /// </summary>
        public event Action<string> RowClickEvent;
 
        public void SetBindingData(List<FourLinkMatchingViewModel> fourLinkMatchingViewModels)
        {
            if (fourLinkMatchingViewModels != null)
            {
                foreach (var item in fourLinkMatchingViewModels)
                {
                    _allBindingList.Add(new FourLinkFormViewModel(item));
                }
                this.fourLinkFormViewModelBindingSource.ResetBindings(false);
            }
        }
 
        public List<FourLinkMatchingViewModel> SetMatching(List<FourLinkMatchingViewModel> inputs, List<AdaptingManageVmo> alllist)
        {
            if (inputs == null || inputs.Count == 0)
                return null;
            var resultList = new List<FourLinkMatchingViewModel>();
            foreach (var item in inputs)
            {
                var result = AsstesAutoMatchingHelper.FourLinkAutoMatching(item, alllist);
                if (result != null)
                {
                    resultList.Add(result);
                }
                else
                {
                    resultList.Add(item);
                }
            }
            _allBindingList.Clear();
            foreach (var item in resultList)
            {
                _allBindingList.Add(new FourLinkFormViewModel(item));
            }
            this.fourLinkFormViewModelBindingSource.ResetBindings(false);
            return resultList;
        }
 
        //行点击事件
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            var row = this.gridView1.GetCurrentViewModel(_allBindingList);
            if (row == null)
            {
                return;
            }
            this.RowClickEvent?.Invoke(row.Code);
        }
    }
}