lu
2025-01-10 7e032e5eafc16d982d09275d3692b1a2d06875a2
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -358,7 +358,6 @@
                                    txt.Text = strVal;
                                }
                            else
                                txt.Text = strVal;
                            txt.ReadOnly = isEdt;
@@ -391,7 +390,12 @@
                            var txt = colType as MemoEdit;
                            if (txt != null)
                                txt.Text = strVal;
                            txt.ReadOnly = isEdt;
                            if (_isRead(txt.Tag))
                            {
                                txt.ReadOnly = true;
                            }
                            else
                                txt.ReadOnly = isEdt;
                            continue;
                        }
                        //数字卡
@@ -432,18 +436,25 @@
                        {
                            var txt = colType as CheckBox;
                            if (txt != null)
                                txt.Checked = bool.Parse(strVal);
                                switch (strVal)
                                {
                                    case "True":
                                        txt.Checked = true;
                                        break;
                                    case "1":
                                        txt.Checked = true;
                                        break;
                                    case "False":
                                        txt.Checked = false;
                                        break;
                                    default:
                                        txt.Checked = false;
                                        break;
                                }
                            txt.Enabled = !isEdt;
                            continue;
                        }
                        if (colType is CheckEdit)
                        {
                            var txt = colType as CheckEdit;
                            if (txt != null)
                                txt.Checked = bool.Parse(strVal);
                            txt.ReadOnly = isEdt;
                            continue;
                        }
                        //时间
                        if (colType is DateTimePicker)
                        {
@@ -652,12 +663,9 @@
                if (ctrl is TextEdit)
                {
                    var txt = ctrl as TextEdit;
                    if (_isRead(txt.Tag))
                    {
                        txt.ReadOnly = true;
                    }
                    else
                        txt.ReadOnly = isEdt;
                    bool _bl = _isRead(txt.Tag, isEdt);
                    txt.ReadOnly = _bl;
                    // txt.ReadOnly = isEdt;
                    continue;
                }
            }
@@ -705,8 +713,18 @@
                if (ctrl is MemoEdit)
                {
                    var txt = ctrl as MemoEdit;
                    txt.Text = "";
                    txt.ReadOnly = isEdt;
                    if (txt.Tag != null && txt.Tag.ToString().Length > 0 && txt.Tag.ToString().StartsWith("moren"))
                    {
                        txt.Text = txt.Tag.ToString().Replace("moren.", "");
                    }
                    else
                        txt.Text = "";
                    if (_isRead(txt.Tag))
                    {
                        txt.ReadOnly = true;
                    }
                    else
                        txt.ReadOnly = isEdt;
                    continue;
                }
                //下拉
@@ -747,14 +765,7 @@
                        txt.ReadOnly = isEdt;
                    continue;
                }
                if (ctrl is MemoEdit)
                {
                    var txt = ctrl as MemoEdit;
                    if (txt != null)
                        txt.Text = "";
                    txt.ReadOnly = isEdt;
                    continue;
                }
                //时间
                if (ctrl is DateTimePicker)
                {
@@ -905,7 +916,7 @@
                }
            }
        }
        /// <summary>
        ///     禁用或启用容器里面的控件
        /// </summary>
@@ -954,7 +965,12 @@
                if (ctrl is MemoEdit)
                {
                    var txt = ctrl as MemoEdit;
                    txt.ReadOnly = isEdt;
                    if (_isRead(txt.Tag))
                    {
                        txt.ReadOnly = true;
                    }
                    else
                        txt.ReadOnly = isEdt;
                    continue;
                }
                //数字卡
@@ -1152,13 +1168,19 @@
            }
        }
        private static bool _isRead(object obj)
        private static bool _isRead(object obj, bool isEdt = false)
        {
            if (obj != null && obj.ToString().ToUpper().Contains("readOnly".ToUpper()))
            ///永远是只读的
            if (obj != null && obj.ToString().ToUpper() == ("readOnly".ToUpper()))
            {
                return true;
            }
            return false;
            ///永远是可写的
            if (obj != null && obj.ToString().ToUpper() == ("readOnly-1".ToUpper()))
            {
                return false;
            }
            return isEdt;
        }
        /// <summary>
        ///     切换选项卡
@@ -1630,6 +1652,7 @@
        public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null)
        {
            gridView1.OptionsView.ColumnAutoWidth = false;//自动调整列宽
            // gridView1.BestFitColumns();//数据绑定到GridView之后调用BestFitColumns()方法
            foreach (GridColumn column in gridView1.Columns)
            {
                column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
@@ -1692,7 +1715,26 @@
                        view.ActiveEditor.MouseUp += ActiveEditor_MouseUp;
                };
            }
            gridView1.RowStyle += (s, e) =>
            {
                gridView1.OptionsSelection.EnableAppearanceFocusedRow = false;//默认选中行不变色
                gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;//默认选中单元格不变色
                if (e.RowHandle >= 0)
                {
                    DataRow row = gridView1.GetDataRow(e.RowHandle);
                    if (row == null)
                        return;
                    bool columnExists = row.Table.Columns.Contains("isRed");
                    if (columnExists == true)
                    {
                        string _isRed = row["isRed"].ToString();
                        if (_isRed == "1")
                        {
                            e.Appearance.BackColor = Color.LightPink;
                        }
                    }
                }
            };
        }
        private static void ActiveEditor_MouseUp(object sender, MouseEventArgs e)
        {