From c78ffe15080b3218671f03c7d85a5e8edd484b62 Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期日, 22 九月 2024 20:54:15 +0800
Subject: [PATCH] 仓库管理

---
 DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs |  110 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 87 insertions(+), 23 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs
index 847fc8a..bb2ac9a 100644
--- a/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs
@@ -1,15 +1,15 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraGrid.Views.Base;
-using DevExpress.XtraGrid.Views.Grid;
+锘縰sing DevExpress.XtraGrid.Columns;
 using DevExpress.XtraGrid.Views.Grid.ViewInfo;
 using DevExpress.XtraTreeList;
 using DevExpress.XtraTreeList.Nodes;
 using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using System;
+using System.Collections.Generic;
 using System.Data;
-using System.Drawing;
+using System.Windows.Controls;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.Warehouse
@@ -64,6 +64,9 @@
                 if (clickedNode.FirstNode == null)
                 {
                     string rowGuid = clickedNode.GetValue("guid").ToString();
+                    string depotGuid = clickedNode.GetValue("upGuid").ToString();
+                    if (!string.IsNullOrEmpty(depotGuid))
+                        rowGuid = depotGuid;
                     getModel(rowGuid, false, 999);
                 }
             }
@@ -106,7 +109,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
         }
         /// <summary>
         /// 鍒犻櫎浜嬩欢
@@ -115,13 +118,14 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
         {
-            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu);
             if (string.IsNullOrEmpty(rowGuid))
             {
-                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鍒犻櫎鐨勮锛�");
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + tlMenu.FocusedNode.GetValue("name") + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
             {
                 return;
             }
@@ -129,14 +133,13 @@
             {
                 guidList = rowGuid,//涓诲缓
             };
-            string strJson = "";
             try
             {
-                strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                string strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 if (_rtn.rtnCode > 0)
                 {
-                    UtilityHelper.ChangeTab(xtraTabControl1, 0);
+                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
                     getPageList(1, UtilityHelper.GetPageSize());
                 }
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -153,7 +156,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+            UtilityHelper.JumpToTab(xtraTabControl1, 0);
             getPageList(1, UtilityHelper.GetPageSize());
         }
         /// <summary>
@@ -163,7 +166,13 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
         {
-            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
+            string rowGuid, rowName;
+            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu);
+            string depotGuid = "";
+            if (tlMenu.FocusedNode != null)
+                depotGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("upGuid"));
+            if (!string.IsNullOrEmpty(depotGuid))
+                rowGuid = depotGuid;
             if (string.IsNullOrEmpty(rowGuid))
             {
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
@@ -178,9 +187,12 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
         {
-            UtilityHelper.ChangeTab(xtraTabControl1, 1);
+            UtilityHelper.JumpToTab(xtraTabControl1, 1);
             lbGuid.Text = "";
-            UtilityHelper.CleanValue(this.panel1.Controls, true);
+            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
+            gridViews.Add(gvMx1);
+            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
+            _setTable();
         }
         /// <summary>
         /// 淇濆瓨浜嬩欢
@@ -192,7 +204,7 @@
             toolBarMenu1.isSetBtn = false;
             if (string.IsNullOrEmpty(txt_itemNo.Text.Trim()))
             {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("缂栧彿鍙蜂笉鑳戒负绌猴紒");
+                Gs.DevApp.ToolBox.MsgHelper.Warning("缂栧彿涓嶈兘涓虹┖锛�");
                 txt_itemNo.Focus();
                 return;
             }
@@ -220,6 +232,23 @@
                 txt_isStatus.Focus();
                 return;
             }
+            gvMx1.UpdateCurrentRow();
+            List<dynamic> lst = new List<dynamic>();
+            for (int i = 0; i < gvMx1.DataRowCount; i++)
+            {
+                DataRow row = gvMx1.GetDataRow(i);
+                if (row != null)
+                {
+                    lst.Add(new
+                    {
+                        guid = row["guid"].ToString(),
+                        sectionCode = row["sectionCode"].ToString(),
+                        sectionName = row["sectionName"].ToString(),
+                        remark = row["remark"].ToString(),
+                        isStatus = row["isStatusTxt"].ToString(),
+                    });
+                }
+            }
             var _obj = new
             {
                 guid = lbGuid.Text.Trim(),//涓诲缓
@@ -229,17 +258,20 @@
                 category = txt_category.SelectedIndex,
                 isWy = txt_isWy.SelectedIndex,
                 isStatus = txt_isStatus.SelectedIndex,
+                list = lst
             };
             try
             {
                 string strJson = UtilityHelper.HttpPost("", "Depot/EditModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
                 if (_rtn.rtnCode > 0)
                 {
                     lbGuid.Text = _rtn.rtnData;
                     toolBarMenu1.isSetBtn = true;
-                    UtilityHelper.ChangeEnable(this.panel1.Controls, false);
+                    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
+                    gridViews.Add(gvMx1);
+                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gridViews);
                 }
             }
             catch (Exception ex)
@@ -259,7 +291,7 @@
             try
             {
                 string strReturn = UtilityHelper.HttpPost("", "Depot/GetListPage", json);
-                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
+                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                 DataTable dt = dd.rtnData.list;
                 this.tlMenu.DataSource = dt;
                 this.tlMenu.KeyFieldName = "guid";
@@ -287,7 +319,7 @@
                 ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
                 return;
             }
-            UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
+            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
             var _obj = new
             {
                 guid = strGuid,//涓诲缓
@@ -295,12 +327,32 @@
             try
             {
                 string strJson = UtilityHelper.HttpPost("", "Depot/GetModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                 if (_rtn.rtnCode > 0)
                 {
                     dynamic dy = _rtn.rtnData;
                     lbGuid.Text = strGuid;
-                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
+                    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
+                    gridViews.Add(gvMx1);
+                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gridViews);
+                    JObject _job = JObject.Parse(strJson);
+                    JArray array = new JArray();
+                    var d = _job["rtnData"]["list"];
+                    foreach (var a in d)
+                    {
+                        array.Add(a);
+                    }
+                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
+                    if (dt.Rows.Count > 0)
+                    {
+                        gridControl1.BindingContext = new BindingContext();
+                        gridControl1.DataSource = dt;
+                        gridControl1.ForceInitialize();
+                    }
+                    else
+                    {
+                        _setTable();
+                    }
                 }
                 else
                     ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
@@ -310,6 +362,18 @@
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
         }
+
+        private void _setTable()
+        {
+            DataTable dt = new DataTable();
+            foreach (GridColumn col in gvMx1.Columns)
+            {
+                dt.Columns.Add(col.FieldName, typeof(string));
+            }
+            gridControl1.BindingContext = new BindingContext();
+            gridControl1.DataSource = dt;
+            gridControl1.ForceInitialize();
+        }
     }
 }
 

--
Gitblit v1.9.3