From 65927056612a7ffef20708aefda33d09be51ef6b Mon Sep 17 00:00:00 2001 From: lg <999544862qq.com> Date: 星期日, 08 九月 2024 22:16:00 +0800 Subject: [PATCH] 权限整理 --- DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 124 +++++++++++++++++++++++++++++++++-------- 1 files changed, 100 insertions(+), 24 deletions(-) diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs index af004f7..a892778 100644 --- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs @@ -1,6 +1,5 @@ 锘縰sing Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; @@ -15,6 +14,7 @@ using static System.Windows.Forms.Control; using DevExpress.XtraEditors; using DevExpress.XtraTab; +using System.Text.RegularExpressions; namespace Gs.DevApp.ToolBox { @@ -150,19 +150,30 @@ rto.rtnData = json["rtnData"]; return rto; } + /// <summary> - /// 璁剧疆绯荤粺瀛椾綋澶у皬锛岀洰鍓嶅苟涓嶉�氱敤 + /// 鏍囧噯json涓茶繑鍥濺eturnModel-->table锛� /// </summary> - public static float GetFontSize = 10; - public static void SetFont(Control control) + /// <param name="strReturn"></param> + /// <returns></returns> + public static ReturnModel<DataTable> GetNoPageTableByJson(string strReturn) { - float size = GetFontSize; - foreach (Control childControl in control.Controls) + ReturnModel<DataTable> rto = new ReturnModel<DataTable>(); + JObject json = JObject.Parse(strReturn); + rto.rtnCode = int.Parse(json["rtnCode"].ToString()); + rto.rtnMsg = json["rtnMsg"].ToString(); + rto.rtnData = new DataTable(); + JArray array = new JArray(); + var d = json["rtnData"]; + foreach (var a in d) { - childControl.Font = new Font(childControl.Font.FontFamily, size, childControl.Font.Style); - SetFont(childControl); + array.Add(a); } + DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); + rto.rtnData = dt; + return rto; } + /// <summary> /// 璇诲彇榛樿椤靛ぇ灏� @@ -170,19 +181,20 @@ /// <returns></returns> public static int GetPageSize() { - return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString()); + return 50; + // return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString()); } /// <summary> - /// 鏍规嵁瀵硅薄鎵归噺璁剧疆鏂囨湰鍊�, + /// 鏍规嵁瀵硅薄鎵归噺璁剧疆鏂囨湰鍊� /// </summary> - /// <param name="controls"></param> - /// <param name="dynamicObject"></param> + /// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param> + /// <param name="dynamicObject">瀵瑰儚</param> + /// <param name="isEdt">鏄惁鍙紪杈�</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鏄竴涓璞★紝鍙互閫掑綊閬嶅巻 @@ -198,41 +210,73 @@ if (cols.Length > 0) { Control colType = cols[0]; + //涓嬫媺 if (colType is ComboBoxEdit) { ComboBoxEdit txt = colType as ComboBoxEdit; - txt.SelectedIndex = int.Parse(strVal); + if (txt.Properties.TextEditStyle == DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor) + txt.SelectedIndex = int.Parse(strVal); + else + txt.Text = strVal; txt.Enabled = isEdt; continue; } + //鏂囨湰 if (colType is TextEdit) { TextEdit txt = colType as TextEdit; if (txt != null) - { txt.Text = strVal; - txt.Enabled = isEdt; - } + txt.Enabled = isEdt; + continue; + } + //鏁板瓧鍗� + if (colType is NumericUpDown) + { + NumericUpDown txt = colType as NumericUpDown; + if (txt != null) + txt.Text = strVal; + txt.Enabled = isEdt; continue; } } - } } /// <summary> /// 娓呯┖瀹瑰櫒閲岄潰鐨勬帶浠� /// </summary> - /// <param name="controls">瀹瑰櫒</param> - /// <param name="isEdt">娓呯┖鍚庢槸鍚﹀彲缂栬緫</param> + /// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param> + /// <param name="isEdt">鏄惁鍙紪杈�</param> public static void CleanValue(ControlCollection controls, Boolean isEdt) { - foreach (Control ctrl in controls)//鎴栦负groupBox1.Controls/panel1.Controls + foreach (Control ctrl in controls) { + ctrl.Enabled = isEdt; + //澶氳鏂囨湰 + if (ctrl is MemoEdit) + { + MemoEdit txt = ctrl as MemoEdit; + txt.Text = ""; + txt.Enabled = isEdt; + continue; + } + //涓嬫媺 + if (ctrl is ComboBoxEdit) + { + ComboBoxEdit txt = ctrl as ComboBoxEdit; + if (txt.Properties.TextEditStyle == DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor) + txt.SelectedIndex = 0; + else + txt.Text = ""; + txt.Enabled = isEdt; + continue; + } + //鏂囨湰 if (ctrl is TextEdit) { ctrl.Text = ""; - ctrl.Enabled = isEdt; + continue; } } } @@ -240,14 +284,25 @@ /// <summary> /// 绂佺敤鎴栧惎鐢ㄥ鍣ㄩ噷闈㈢殑鎺т欢 /// </summary> - /// <param name="controls">瀹瑰櫒</param> + /// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param> /// <param name="isEdt">鏄惁鍙紪杈�</param> public static void ChangeEnable(ControlCollection controls, Boolean isEdt) { - foreach (Control ctrl in controls)//鎴栦负groupBox1.Controls/panel1.Controls + foreach (Control ctrl in controls) { + //鏂囨湰 if (ctrl is TextEdit) + { ctrl.Enabled = isEdt; + continue; + } + //鏁板瓧鍗� + if (ctrl is NumericUpDown) + { + ctrl.Enabled = isEdt; + continue; + } + } } @@ -323,5 +378,26 @@ } } + + /// <summary> + /// 杞┘宄板懡鍚� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public static string ToCamelCase(string input) + { + if (string.IsNullOrEmpty(input)) + return input; + + // 鍖归厤闈炲瓧姣嶆暟瀛楀瓧绗﹀悗鐨勭涓�涓瓧姣嶏紝骞跺皢鍏惰浆鎹负澶у啓 + return Regex.Replace( + input, + "([a-z])([A-Z])", + "$1$2", + RegexOptions.CultureInvariant + ).Trim(); + } + + } } -- Gitblit v1.9.3