lg
2024-09-20 ab354260b4b9ca8cf1aa12573310ec2a9598e084
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -15,6 +15,8 @@
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using System.Text.RegularExpressions;
using System.Xml;
using System.Collections.Generic;
namespace Gs.DevApp.ToolBox
{
@@ -191,9 +193,15 @@
        /// <param name="controls">controls:为groupBox1.Controls/panel1.Controls</param>
        /// <param name="dynamicObject">对像</param>
        /// <param name="isEdt">是否可编辑</param>
        public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt)
        public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
        {
            if (gridViews != null)
            {
                foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
                {
                    gv.OptionsBehavior.Editable = isEdt;
                }
            }
            foreach (JProperty property in dynamicObject.Properties())
            {
                string strName = property.Name;
@@ -263,6 +271,15 @@
                            txt.Enabled = isEdt;
                            continue;
                        }
                        //时间
                        if (colType is DateTimePicker)
                        {
                            DateTimePicker txt = colType as DateTimePicker;
                            if (txt != null)
                                txt.Checked = (strVal.ToString() == "1" ? true : false);
                            txt.Enabled = isEdt;
                            continue;
                        }
                    }
                }
                catch (Exception ex)
@@ -280,8 +297,15 @@
        /// </summary>
        /// <param name="controls">controls:为groupBox1.Controls/panel1.Controls</param>
        /// <param name="isEdt">是否可编辑</param>
        public static void CleanValue(ControlCollection controls, Boolean isEdt)
        public static void CleanValue(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
        {
            if (gridViews != null)
            {
                foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
                {
                    gv.OptionsBehavior.Editable = isEdt;
                }
            }
            foreach (Control ctrl in controls)
            {
                ctrl.Enabled = isEdt;
@@ -318,8 +342,15 @@
        /// </summary>
        /// <param name="controls">controls:为groupBox1.Controls/panel1.Controls</param>
        /// <param name="isEdt">是否可编辑</param>
        public static void ChangeEnable(ControlCollection controls, Boolean isEdt)
        public static void ChangeEnable(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
        {
            if (gridViews != null)
            {
                foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
                {
                    gv.OptionsBehavior.Editable = isEdt;
                }
            }
            foreach (Control ctrl in controls)
            {
                //文本
@@ -334,7 +365,12 @@
                    ctrl.Enabled = isEdt;
                    continue;
                }
                //日期
                if (ctrl is DateTimePicker)
                {
                    ctrl.Enabled = isEdt;
                    continue;
                }
            }
        }
@@ -423,7 +459,20 @@
            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)
            {
                XmlAttribute attribute = node as XmlAttribute;
                attribute.Value = newValue;
                xmlDoc.Save(configFile);
            }
        }
        public class CboItemEntity
        {
            private object _text = 0;