fqc
lu
2025-04-14 6db62ddd8db0a54afa15e06bb554950069e3859a
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -1,4 +1,18 @@
using System;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Menu;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraTab;
using DevExpress.XtraTreeList;
using Gs.DevApp.Entity;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
@@ -14,21 +28,6 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Menu;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraTab;
using DevExpress.XtraTreeList;
using Gs.DevApp.Entity;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UserControls.Data;
using static System.Windows.Forms.Control;
@@ -727,6 +726,7 @@
                    var txt = ctrl as ButtonEdit;
                    txt.Text = "";
                    txt.Enabled = !isEdt;
                    txt.ReadOnly = isEdt;
                    continue;
                }
                //文本
@@ -1692,7 +1692,7 @@
        /// <param name="fileName">字段</param>
        /// <param name="icoName">图标路径</param>
        /// <param name="action"></param>
        public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null, DevExpress.Utils.ToolTipController tips = null,bool isSearch=true)
        public static void SetGridViewParameter(GridView gridView1, PictureBox picCheckBox = null, Form fm = null, string fileName = "checkStatus", string icoName = "", DelegateGetModel action = null, DevExpress.Utils.ToolTipController tips = null, bool isPostSearch = true)
        {
            gridView1.PopupMenuShowing += (s, e) =>
            {
@@ -1715,7 +1715,8 @@
            };
            gridView1.OptionsView.ColumnAutoWidth = false;//自动调整列宽
            if (isSearch == true) {
            if (isPostSearch == true)
            {
                gridView1.OptionsView.ShowGroupPanel = false;
                gridView1.OptionsCustomization.AllowGroup = false;
                gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False;
@@ -1746,14 +1747,17 @@
                    column.OptionsColumn.ReadOnly = false;
                else
                    column.OptionsColumn.ReadOnly = true;
                if(isPostSearch==false)
                    column.OptionsColumn.ReadOnly = true;
                if (isSearch == true)
                if (isPostSearch == true)
                {
                    if (column.Tag == null || column.Tag.ToString().Length <= 0)
                        column.OptionsFilter.AllowAutoFilter = false;
                }
            }
            gridView1.IndicatorWidth = 50;
            gridView1.CustomDrawRowIndicator += (s, e) =>
            {
@@ -1885,7 +1889,7 @@
                    column.Width = 500;
            }
        }
        /// <summary>
        /// 设置选项卡
        /// </summary>
@@ -2025,7 +2029,67 @@
            Regex regex = new Regex("^[0-9]+$");
            return regex.IsMatch(str);
        }
        public static bool IsNumeric2(string str)
        {
            string input = str;
            decimal number;
            bool isNumeric = decimal.TryParse(input, out number);
            return isNumeric;
        }
        public static void PrintJiSuan(DevExpress.XtraEditors.TextEdit box1, DevExpress.XtraEditors.TextEdit box2, string sum, DevExpress.XtraEditors.RadioGroup rd)
        {
            if (rd.SelectedIndex == 2)
                return;
            try
            {
                string t1 = box1.Text.Trim();
                string t2 = box2.Text.Trim();
                if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric2(t1))
                    return;
                decimal? dc = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(sum);
                decimal? dc1 = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(t1);
                int dividend = int.Parse(sum); // 被除数
                int divisor = int.Parse(t1);   // 除数
                int quotient = dividend / divisor; // 整数部分
                int remainder = dividend % divisor; // 余数
                box2.Text = quotient.ToString();
                if (rd.SelectedIndex == 0)
                    rd.Properties.Items[0].Description = "全自动【" + remainder.ToString() + "】";
            }
            catch (Exception ex)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
            }
        }
        public static void PrintAuto(DevExpress.XtraEditors.TextEdit txt_psnQty_1, DevExpress.XtraEditors.TextEdit txt_iCount_1, DevExpress.XtraEditors.RadioGroup radOut)
        {
            txt_psnQty_1.Text = "";
            txt_iCount_1.Text = "";
            radOut.Properties.Items[0].Description = "全自动";
            if (radOut.SelectedIndex == 2)
                txt_iCount_1.ReadOnly = false;
            else
                txt_iCount_1.ReadOnly = true;
        }
        public static decimal PrintYuLiang(DevExpress.XtraEditors.RadioGroup rd)
        {
            decimal dc = 0;
            if (rd.SelectedIndex != 0)
                return 0;
            string txt = rd.Properties.Items[0].Description;// = "全自动【" + remainder.ToString() + "】";
            txt = txt.Trim().Replace("全自动【", "");
            txt = txt.Replace("】", "");
            if (string.IsNullOrEmpty(txt))
                return 0;
            return decimal.Parse(txt);
        }
    }
    /// <summary>