From 3d6533f1381e3e513ffb3d65bf34fb254f967088 Mon Sep 17 00:00:00 2001 From: lg <999544862qq.com> Date: 星期五, 06 九月 2024 11:39:04 +0800 Subject: [PATCH] 优化系统模块下面的增删改查 --- DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 163 insertions(+), 0 deletions(-) diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs index 2b078be..af004f7 100644 --- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs @@ -12,6 +12,9 @@ using Newtonsoft.Json; using Gs.DevApp.Models; using System.Windows.Forms; +using static System.Windows.Forms.Control; +using DevExpress.XtraEditors; +using DevExpress.XtraTab; namespace Gs.DevApp.ToolBox { @@ -160,5 +163,165 @@ SetFont(childControl); } } + + /// <summary> + /// 璇诲彇榛樿椤靛ぇ灏� + /// </summary> + /// <returns></returns> + public static int GetPageSize() + { + return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString()); + } + + /// <summary> + /// 鏍规嵁瀵硅薄鎵归噺璁剧疆鏂囨湰鍊�, + /// </summary> + /// <param name="controls"></param> + /// <param name="dynamicObject"></param> + public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt) + { + foreach (JProperty property in dynamicObject.Properties()) + { + //Console.WriteLine("Name: {0}, Value: {1}", property.Name, property.Value); + string strName = property.Name; + string strVal = property.Value.ToString(); + // // 濡傛灉value鏄竴涓璞★紝鍙互閫掑綊閬嶅巻 + // if (property.Value is JObject) + // { + // JObject nestedObject = (JObject)property.Value; + // foreach (JProperty nestedProperty in nestedObject.Properties()) + // { + // Console.WriteLine("\tName: {0}, Value: {1}", nestedProperty.Name, nestedProperty.Value); + // } + // } + Control[] cols = controls.Find("txt_" + strName, true); + if (cols.Length > 0) + { + Control colType = cols[0]; + if (colType is ComboBoxEdit) + { + ComboBoxEdit txt = colType as ComboBoxEdit; + txt.SelectedIndex = int.Parse(strVal); + txt.Enabled = isEdt; + continue; + } + if (colType is TextEdit) + { + TextEdit txt = colType as TextEdit; + if (txt != null) + { + txt.Text = strVal; + txt.Enabled = isEdt; + } + continue; + } + } + + } + } + + /// <summary> + /// 娓呯┖瀹瑰櫒閲岄潰鐨勬帶浠� + /// </summary> + /// <param name="controls">瀹瑰櫒</param> + /// <param name="isEdt">娓呯┖鍚庢槸鍚﹀彲缂栬緫</param> + public static void CleanValue(ControlCollection controls, Boolean isEdt) + { + foreach (Control ctrl in controls)//鎴栦负groupBox1.Controls/panel1.Controls + { + if (ctrl is TextEdit) + { + ctrl.Text = ""; + ctrl.Enabled = isEdt; + } + } + } + + /// <summary> + /// 绂佺敤鎴栧惎鐢ㄥ鍣ㄩ噷闈㈢殑鎺т欢 + /// </summary> + /// <param name="controls">瀹瑰櫒</param> + /// <param name="isEdt">鏄惁鍙紪杈�</param> + public static void ChangeEnable(ControlCollection controls, Boolean isEdt) + { + foreach (Control ctrl in controls)//鎴栦负groupBox1.Controls/panel1.Controls + { + if (ctrl is TextEdit) + ctrl.Enabled = isEdt; + } + } + + /// <summary> + ///鍒囨崲閫夐」鍗� + /// </summary> + /// <param name="tabControl">閫夐」鍗″鍣�</param> + /// <param name="idx">浠�0寮�濮嬶紝濡傛灉鏄�999锛屽垯鍏ㄩ儴鍙敤</param> + public static void ChangeTab(XtraTabControl tabControl, int idx) + { + if (idx == 999) + { + for (int i = 0; i < tabControl.TabPages.Count; i++) + { + tabControl.TabPages[i].PageEnabled = true; + } + tabControl.SelectedTabPageIndex = tabControl.TabPages.Count - 1; + return; + } + for (int i = 0; i < tabControl.TabPages.Count; i++) + { + tabControl.TabPages[i].PageEnabled = false; + } + tabControl.TabPages[idx].PageEnabled = true; + tabControl.SelectedTabPageIndex = idx; + } + + + public static void TreeViewCheck(TreeViewEventArgs e) + { + try + { + if (e.Node.Nodes.Count > 0) + { + bool NoFalse = true; + foreach (TreeNode tn in e.Node.Nodes) + { + if (tn.Checked == false) + { + NoFalse = false; + } + } + if (e.Node.Checked == true || NoFalse) + { + foreach (TreeNode tn in e.Node.Nodes) + { + if (tn.Checked != e.Node.Checked) + { + tn.Checked = e.Node.Checked; + } + } + } + } + if (e.Node.Parent != null && e.Node.Parent is TreeNode) + { + bool ParentNode = true; + foreach (TreeNode tn in e.Node.Parent.Nodes) + { + if (tn.Checked == false) + { + ParentNode = false; + } + } + if (e.Node.Parent.Checked != ParentNode && (e.Node.Checked == false || e.Node.Checked == true && e.Node.Parent.Checked == false)) + { + e.Node.Parent.Checked = ParentNode; + } + } + } + catch (Exception ex) + { + throw ex; + } + + } } } -- Gitblit v1.9.3