lixiaojun
2024-10-29 1d8832e8e8e862a296f80c18ae2f1dac40419b68
WinFrmUI/HStation.WinFrmUI.Basic/02-SysPropManage/SysPropManageMainPanel.cs
@@ -1,4 +1,8 @@
namespace HStation.WinFrmUI.Basic
using DevExpress.Utils.Behaviors;
using DevExpress.Utils.DragDrop;
using DevExpress.XtraTreeList;
namespace HStation.WinFrmUI.Basic
{
    public partial class SysPropManageMainPanel : DocumentPage
    {
@@ -7,6 +11,9 @@
            InitializeComponent();
            this.gridView1.SetNormalView();
            this.gridView1.RegistCustomDrawRowIndicator();
            this.PageTitle.Caption = "属性管理";
            this.PageTitle.HeaderSvgImage = this.svgImage32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.propGroupTreeListCtrl1.FocusedChangedEvent += ModuleTreeListCtrl1_FocusedChangedEvent;
        }
@@ -127,5 +134,44 @@
                dlg.ShowDialog();
            }
        }
        //排序
        private void barCheckItemSorter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (barCheckSorter.Checked)
            {
                behaviorManager1.Attach<DragDropBehavior>(gridView1, behavior =>
                {
                    //        behavior.BeginDragDrop += Behavior_BeginDragDrop;
                    behavior.EndDragDrop += Behavior_EndDragDrop;
                });
            }
            else
            {
                behaviorManager1.Detach<DragDropBehavior>(gridView1);
            }
        }
        private async void Behavior_EndDragDrop(object sender, EndDragDropEventArgs e)
        {
            var vm = this.gridView1.GetCurrentViewModel(_allBindingList);
            var sorterList = new List<Yw.Vmo.Sorter>();
            int i = 1;
            foreach (var item in _allBindingList)
            {
                sorterList.Add(new Yw.Vmo.Sorter() { ID = item.ID, SortCode = i });
                i++;
            }
            if (await _bll.UpdateSorter(sorterList))
            {
                this.propViewModelBindingSource.ResetBindings(false);
            }
            else
            {
                //     gridView1.FocusedRowHandle = _LastRowIndex;
                TipFormHelper.ShowError("修改排序失败!");
                return;
            }
        }
    }
}