lixiaojun
2024-10-29 c2bb91cc8706cdeb18b0835a36a4266891daccf3
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
    {
@@ -130,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;
            }
        }
    }
}