From 0f99d4d12f2eae29bbe343f4b3131f2faeccda5d Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期二, 14 一月 2025 17:31:20 +0800
Subject: [PATCH] 泵曲线修改

---
 WinFrmUI/HStation.WinFrmUI.Basic.Core/03-SysFlagManage/SysFlagManageMainPanel.cs |  110 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 74 insertions(+), 36 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Basic.Core/03-SysFlagManage/SysFlagManageMainPanel.cs b/WinFrmUI/HStation.WinFrmUI.Basic.Core/03-SysFlagManage/SysFlagManageMainPanel.cs
index c8576b9..7c86897 100644
--- a/WinFrmUI/HStation.WinFrmUI.Basic.Core/03-SysFlagManage/SysFlagManageMainPanel.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Basic.Core/03-SysFlagManage/SysFlagManageMainPanel.cs
@@ -53,7 +53,7 @@
             var moduleid = this.sysFlagTreeListCtrl1.GetCurrentID();
             if (moduleid == 0)
             {
-                 return;
+                return;
             }
             dlg.SetBindingData(moduleid);
             dlg.ReloadDataEvent += async (rhs) =>
@@ -135,12 +135,7 @@
         {
             if (barCheckSorter.Checked)
             {
-                behaviorManager1.Attach<DragDropBehavior>(gridView1, behavior =>
-                {
-                    behavior.BeginDragDrop += Behavior_BeginDragDrop;
-                    behavior.DragDrop += Behavior_DragDrop;
-                    behavior.EndDragDrop += Behavior_EndDragDrop;
-                });
+                behaviorManager1.Attach<DragDropBehavior>(gridView1);
             }
             else
             {
@@ -148,44 +143,87 @@
             }
         }
 
-        private void Behavior_DragDrop(object sender, DragDropEventArgs e)
+        private async void dragDropEvents1_DragDrop(object sender, DevExpress.Utils.DragDrop.DragDropEventArgs e)
         {
-            //behaviorManager1.Detach<DragDropBehavior>(gridView1);
-            return;
-        }
-
-        private void Behavior_DragEnter(object sender, DragEnterEventArgs e)
-        {
-            return;
-        }
-
-        private void Behavior_BeginDragDrop(object sender, BeginDragDropEventArgs e)
-        {
-            _LastRowIndex = gridView1.FocusedRowHandle;
-            var currentCellValue = gridView1.GetFocusedValue();
-        }
-
-        //鎷栨嫿鎺掑簭鎿嶄綔
-        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)
+            var indexs = e.Data as int[];
+            if (indexs == null || indexs.Length < 1)
             {
-                sorterList.Add(new Yw.Vmo.Sorter() { ID = item.ID, SortCode = i });
-                i++;
+                e.Handled = true;
+                return;
             }
-            if (await _bll.UpdateSorter(sorterList))
+            var sourceIndex = indexs[0];
+            var sourceObj = this.gridView1.GetRow(sourceIndex) as SysFlagViewModel;
+            if (sourceObj == null)
             {
-                this.sysFlagViewModelBindingSource.ResetBindings(false);
+                e.Handled = true;
+                return;
+            }
+
+            var destIndex = this.gridView1.GetRowHandleByCP(e.Location);
+            if (destIndex < 0)
+            {
+                e.Handled = true;
+                return;
+            }
+
+            var destObj = this.gridView1.GetRow(destIndex) as SysFlagViewModel;
+            if (destObj == null)
+            {
+                e.Handled = true;
+                return;
+            }
+
+            var sorters = new List<Yw.Vmo.Sorter>();
+
+            if (e.InsertType == InsertType.Before)
+            {
+                sorters.Add(new Yw.Vmo.Sorter() { ID = sourceObj.ID, SortCode = destObj.SortCode });
+                _allBindingList.ForEach(x =>
+                {
+                    if (x.SortCode >= destObj.SortCode)
+                    {
+                        if (x != sourceObj)
+                        {
+                            sorters.Add(new Yw.Vmo.Sorter() { ID = x.ID, SortCode = x.SortCode + 1 });
+                        }
+                    }
+                });
+            }
+            else if (e.InsertType == InsertType.After)
+            {
+                sorters.Add(new Yw.Vmo.Sorter() { ID = sourceObj.ID, SortCode = destObj.SortCode + 1 });
+                _allBindingList.ForEach(x =>
+                {
+                    if (x.SortCode > destObj.SortCode)
+                    {
+                        if (x != sourceObj)
+                        {
+                            sorters.Add(new Yw.Vmo.Sorter() { ID = x.ID, SortCode = x.SortCode + 1 });
+                        }
+                    }
+                });
             }
             else
             {
-                gridView1.FocusedRowHandle = _LastRowIndex;
-                TipFormHelper.ShowError("淇敼鎺掑簭澶辫触!");
+                e.Handled = true;
                 return;
             }
+
+            var bol = await _bll.UpdateSorter(sorters);
+            if (!bol)
+            {
+                e.Handled = true;
+                return;
+            }
+
+            _allBindingList.ForEach(x =>
+            {
+                var sorter = sorters.Find(t => t.ID == x.ID);
+                if (sorter != null)
+                {
+                    x.SortCode = sorter.SortCode;
+                }
+            });
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3