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

---
 DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs |  171 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 120 insertions(+), 51 deletions(-)

diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index 83f1141..38b4766 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -15,7 +15,6 @@
 using DevExpress.XtraEditors;
 using DevExpress.XtraTab;
 using System.Text.RegularExpressions;
-using System.Xml;
 using System.Collections.Generic;
 
 namespace Gs.DevApp.ToolBox
@@ -75,6 +74,17 @@
             }
             return responseStr;
         }
+
+        /// <summary>
+        /// 璇诲彇榛樿椤靛ぇ灏�
+        /// </summary>
+        /// <returns></returns>
+        public static int GetPageSize()
+        {
+            return 50;
+            // return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString());
+        }
+
         /// <summary>
         /// 鏍规嵁鍥剧墖鍚嶈鍙栬祫婧愭枃浠�,涓嶅甫鍚庣紑鍚�
         /// </summary>
@@ -114,11 +124,11 @@
             return token;
         }
         /// <summary>
-        /// 鏍囧噯json涓茶繑鍥濺eturnModel-->table锛�
+        /// 鏍囧噯json杩斿洖ReturnModel-->鍖呭惈TablePage鍒嗛〉锛�
         /// </summary>
         /// <param name="strReturn"></param>
         /// <returns></returns>
-        public static ReturnModel<PageListModel> GetTableByJson(string strReturn)
+        public static ReturnModel<PageListModel> ReturnToTablePage(string strReturn)
         {
             ReturnModel<PageListModel> rto = new ReturnModel<PageListModel>();
             JObject json = JObject.Parse(strReturn);
@@ -139,11 +149,11 @@
             return rto;
         }
         /// <summary>
-        /// 鏍囧噯json涓茶繑鍥濺eturnModel->瀛楃涓诧紝
+        /// 鏍囧噯json杩斿洖ReturnModel锛�
         /// </summary>
         /// <param name="strReturn"></param>
         /// <returns></returns>
-        public static ReturnModel<dynamic> GetDataByJson(string strReturn)
+        public static ReturnModel<dynamic> ReturnToDynamic(string strReturn)
         {
             ReturnModel<dynamic> rto = new ReturnModel<dynamic>();
             JObject json = JObject.Parse(strReturn);
@@ -154,11 +164,11 @@
         }
 
         /// <summary>
-        /// 鏍囧噯json涓茶繑鍥濺eturnModel-->table锛�
+        /// 鏍囧噯json涓茶繑鍥濺eturnModel-->浠呬粎鏈塴ist,涓嶅垎椤碉紝
         /// </summary>
         /// <param name="strReturn"></param>
         /// <returns></returns>
-        public static ReturnModel<DataTable> GetNoPageTableByJson(string strReturn)
+        public static ReturnModel<DataTable> ReturnToList(string strReturn)
         {
             ReturnModel<DataTable> rto = new ReturnModel<DataTable>();
             JObject json = JObject.Parse(strReturn);
@@ -174,17 +184,6 @@
             DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
             rto.rtnData = dt;
             return rto;
-        }
-
-
-        /// <summary>
-        /// 璇诲彇榛樿椤靛ぇ灏�
-        /// </summary>
-        /// <returns></returns>
-        public static int GetPageSize()
-        {
-            return 50;
-            // return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString());
         }
 
         /// <summary>
@@ -297,7 +296,7 @@
         /// </summary>
         /// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param>
         /// <param name="isEdt">鏄惁鍙紪杈�</param>
-        public static void CleanValue(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
+        public static void CleanValueByControl(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
         {
             if (gridViews != null)
             {
@@ -342,7 +341,7 @@
         /// </summary>
         /// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param>
         /// <param name="isEdt">鏄惁鍙紪杈�</param>
-        public static void ChangeEnable(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
+        public static void ChangeEnableByControl(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
         {
             if (gridViews != null)
             {
@@ -351,8 +350,10 @@
                     gv.OptionsBehavior.Editable = isEdt;
                 }
             }
+          
             foreach (Control ctrl in controls)
             {
+                ctrl.Enabled = isEdt;
                 //鏂囨湰
                 if (ctrl is TextEdit)
                 {
@@ -379,7 +380,7 @@
         /// </summary>
         /// <param name="tabControl">閫夐」鍗″鍣�</param>
         /// <param name="idx">浠�0寮�濮嬶紝濡傛灉鏄�999锛屽垯鍏ㄩ儴鍙敤</param>
-        public static void ChangeTab(XtraTabControl tabControl, int idx)
+        public static void JumpToTab(XtraTabControl tabControl, int idx)
         {
             if (idx == 999)
             {
@@ -397,7 +398,6 @@
             tabControl.TabPages[idx].PageEnabled = true;
             tabControl.SelectedTabPageIndex = idx;
         }
-
 
         public static void TreeViewCheck(TreeViewEventArgs e)
         {
@@ -459,45 +459,114 @@
             string dd = Regex.Replace(propertyName, @"_([a-z])", m => m.Groups[1].Value.ToUpper());
             return dd;
         }
-        public static void UpdateAppConfig(string key, string newValue)
-        {
-            string configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
-            XmlDocument xmlDoc = new XmlDocument();
-            xmlDoc.Load(configFile);
 
-            XmlNode node = xmlDoc.SelectSingleNode($"//appSettings//add[@key='{key}']");
-            if (node != null)
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="xtraTabControl1"></param>
+        /// <param name="lbGuid">缂栬緫妗嗕腑鐨勪富閿悕</param>
+        /// <param name="txtName">缂栬緫妗嗕腑鐨勬枃鏈鍚�</param>
+        /// <param name="gridView1"></param>
+        /// <param name="gridRowName">鍒楄〃涓殑鏂囨湰鍒楀悕</param>
+        /// <param name="SelectedTabPageIndex"></param>
+        /// <returns></returns>
+        public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+            , System.Windows.Forms.Label lbGuid
+            , DevExpress.XtraEditors.TextEdit txtName
+            , DevExpress.XtraGrid.Views.Grid.GridView gridView1
+            , int SelectedTabPageIndex = 1)
+        {
+            string _strGuid = "";
+            string _strName = "";
+            if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
             {
-                XmlAttribute attribute = node as XmlAttribute;
-                attribute.Value = newValue;
-                xmlDoc.Save(configFile);
+                _strGuid = lbGuid.Text.Trim();
+                _strName = txtName.Text.Trim();
             }
+            else
+            {
+                DataRow dr = gridView1.GetFocusedDataRow();
+                if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+                {
+
+                }
+                else {
+                    _strGuid = dr["guid"].ToString();
+                    _strName = dr[1].ToString();
+                }
+            }
+            return (_strGuid, _strName);
         }
-        public class CboItemEntity
+        public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+            , System.Windows.Forms.Label lbGuid
+            , DevExpress.XtraEditors.TextEdit txtName
+            , System.Windows.Forms.TreeView tlMenu
+            , int SelectedTabPageIndex = 1)
         {
-            private object _text = 0;
-            private object _Value = "";
-            /// <summary>
-            /// 鏄剧ず鍊�
-            /// </summary>
-            public object Text
+            string _strGuid = "";
+            string _strName = "";
+            if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
             {
-                get { return this._text; }
-                set { this._text = value; }
+                _strGuid = lbGuid.Text.Trim();
+                _strName = txtName.Text.Trim();
             }
-            /// <summary>
-            /// 瀵硅薄鍊�
-            /// </summary>
-            public object Value
+            else
             {
-                get { return this._Value; }
-                set { this._Value = value; }
+                TreeNode clickedNode = tlMenu.SelectedNode;
+                if (clickedNode != null)
+                {
+                    _strGuid = clickedNode.Name.ToString();
+                    _strName = clickedNode.Text.Trim();
+                }
             }
+            return (_strGuid, _strName);
+        }
+        public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+            , System.Windows.Forms.Label lbGuid
+             , DevExpress.XtraEditors.TextEdit txtName
+            , DevExpress.XtraTreeList.TreeList tlMenu
+            , int SelectedTabPageIndex = 1)
+        {
+            string _strGuid = "";
+            string _strName = "";
+            if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
+            {
+                _strGuid = lbGuid.Text.Trim();
+                _strName = txtName.Text.Trim();
+            }
+            else
+            {
+                _strGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
+                _strName = tlMenu.FocusedNode.GetValue(0).ToString();
+            }
+            return (_strGuid, _strName);
+        }
+    }
 
-            public override string ToString()
-            {
-                return this.Text.ToString();
-            }
+    public class CboItemEntity
+    {
+        private object _text = 0;
+        private object _Value = "";
+        /// <summary>
+        /// 鏄剧ず鍊�
+        /// </summary>
+        public object Text
+        {
+            get { return this._text; }
+            set { this._text = value; }
+        }
+        /// <summary>
+        /// 瀵硅薄鍊�
+        /// </summary>
+        public object Value
+        {
+            get { return this._Value; }
+            set { this._Value = value; }
+        }
+
+        public override string ToString()
+        {
+            return this.Text.ToString();
         }
     }
 }

--
Gitblit v1.9.3