From 0add14097df300ccf917ed65d711b0a303fcb05f Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期六, 14 九月 2024 11:50:27 +0800
Subject: [PATCH] 基础资料

---
 DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs |  155 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 103 insertions(+), 52 deletions(-)

diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index a892778..a2c73a3 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -9,7 +9,7 @@
 using System.Resources;
 using System.Drawing;
 using Newtonsoft.Json;
-using Gs.DevApp.Models;
+using Gs.DevApp.Entity;
 using System.Windows.Forms;
 using static System.Windows.Forms.Control;
 using DevExpress.XtraEditors;
@@ -173,7 +173,7 @@
             rto.rtnData = dt;
             return rto;
         }
-         
+
 
         /// <summary>
         /// 璇诲彇榛樿椤靛ぇ灏�
@@ -193,54 +193,86 @@
         /// <param name="isEdt">鏄惁鍙紪杈�</param>
         public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt)
         {
+
             foreach (JProperty property in dynamicObject.Properties())
             {
                 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)
+                try
                 {
-                    Control colType = cols[0];
-                    //涓嬫媺
-                    if (colType is ComboBoxEdit)
+                    //    // 濡傛灉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)
                     {
-                        ComboBoxEdit txt = colType as ComboBoxEdit;
-                        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;
-                        continue;
-                    }
-                     //鏁板瓧鍗�
-                    if (colType is NumericUpDown)
-                    {
-                        NumericUpDown txt = colType as NumericUpDown;
-                        if (txt != null)
-                            txt.Text = strVal;
-                        txt.Enabled = isEdt;
-                        continue;
+                        Control colType = cols[0];
+                        //LookUpEdit
+                        if (colType is LookUpEdit)
+                        {
+                            LookUpEdit txt = colType as LookUpEdit;
+                            if (txt != null)
+                            {
+                                txt.EditValue = strVal;
+                                // txt.Text = strVal;
+                            }
+                            txt.Enabled = isEdt;
+                            continue;
+                        }
+                        //涓嬫媺
+                        if (colType is ComboBoxEdit)
+                        {
+                            ComboBoxEdit txt = colType as ComboBoxEdit;
+                            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;
+                            continue;
+                        }
+                        //鏁板瓧鍗�
+                        if (colType is NumericUpDown)
+                        {
+                            NumericUpDown txt = colType as NumericUpDown;
+                            if (txt != null)
+                                txt.Text = strVal;
+                            txt.Enabled = isEdt;
+                            continue;
+                        }
+                        //鍗曢��
+                        if (colType is CheckEdit)
+                        {
+                            CheckEdit txt = colType as CheckEdit;
+                            if (txt != null)
+                                txt.Checked = (strVal.ToString() == "1" ? true : false);
+                            txt.Enabled = isEdt;
+                            continue;
+                        }
                     }
                 }
+                catch (Exception ex)
+                {
+
+                    MessageBox.Show(strName + ex.Message);
+                }
+
             }
+
         }
 
         /// <summary>
@@ -384,20 +416,39 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public static string ToCamelCase(string input)
+        public static string ToCamelCase(string propertyName)
         {
-            if (string.IsNullOrEmpty(input))
-                return input;
-
-            // 鍖归厤闈炲瓧姣嶆暟瀛楀瓧绗﹀悗鐨勭涓�涓瓧姣嶏紝骞跺皢鍏惰浆鎹负澶у啓
-            return Regex.Replace(
-                input,
-                "([a-z])([A-Z])",
-                "$1$2",
-                RegexOptions.CultureInvariant
-            ).Trim();
+            if (propertyName.Length > 0 && propertyName.All(char.IsUpper))
+                propertyName = propertyName.ToLower();
+            string dd = Regex.Replace(propertyName, @"_([a-z])", m => m.Groups[1].Value.ToUpper());
+            return dd;
         }
 
+        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