From 49e7d052cc72a98b10ba9c06268c8a1d79e94a5b Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期二, 15 四月 2025 11:14:10 +0800
Subject: [PATCH] fqc

---
 DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs |  218 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 181 insertions(+), 37 deletions(-)

diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index b68706e..f665fdc 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -1,4 +1,18 @@
-锘縰sing System;
+锘縰sing 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,19 +28,6 @@
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Windows.Forms;
-using DevExpress.DataAccess.Native.EntityFramework;
-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.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;
 
@@ -324,6 +325,7 @@
                     if (cols.Length > 0)
                     {
                         var colType = cols[0];
+
                         if (colType is LookUpEdit)
                         {
                             var txt = colType as LookUpEdit;
@@ -362,6 +364,14 @@
                             else
                                 txt.Text = strVal;
                             txt.ReadOnly = isEdt;
+                            continue;
+                        }
+                        if (colType is ButtonEdit)
+                        {
+                            var txt = colType as ButtonEdit;
+                            if (txt != null)
+                                txt.Text = strVal;
+                            txt.Enabled = !isEdt;
                             continue;
                         }
                         //鏂囨湰
@@ -479,6 +489,7 @@
                                 txt.Text = strVal;
                             }
                         }
+
                         //鑷畾涔変粨搴�
                         if (colType is UcLookCk)
                         {
@@ -710,6 +721,14 @@
                     txt.ReadOnly = isEdt;
                     continue;
                 }
+                if (ctrl is ButtonEdit)
+                {
+                    var txt = ctrl as ButtonEdit;
+                    txt.Text = "";
+                    txt.Enabled = !isEdt;
+                    txt.ReadOnly = isEdt;
+                    continue;
+                }
                 //鏂囨湰
                 if (ctrl is TextEdit)
                 {
@@ -841,7 +860,7 @@
                     txt.IsReadly = isEdt;
                     continue;
                 }
-               
+
                 //鑷畾閮ㄩ棬
                 if (ctrl is UcLookDepartment)
                 {
@@ -932,6 +951,19 @@
             }
             foreach (Control ctrl in controls)
             {
+                //涓嬫媺
+                if (ctrl is ComboBoxEdit)
+                {
+                    var txt = ctrl as ComboBoxEdit;
+                    txt.ReadOnly = isEdt;
+                    continue;
+                }
+                if (ctrl is ButtonEdit)
+                {
+                    var txt = ctrl as ButtonEdit;
+                    txt.Enabled = !isEdt;
+                    continue;
+                }
                 //鏂囨湰
                 if (ctrl is TextEdit)
                 {
@@ -962,14 +994,12 @@
                     txt.ReadOnly = isEdt;
                     continue;
                 }
-
                 //鏃ユ湡
                 if (ctrl is DateTimePicker)
                 {
                     ctrl.Enabled = !isEdt;
                     continue;
                 }
-
                 //鍗曢��
                 if (ctrl is CheckBox)
                 {
@@ -1060,7 +1090,7 @@
                     txt.IsReadly = isEdt;
                     continue;
                 }
-               
+
                 //鑷畾閮ㄩ棬
                 if (ctrl is UcLookDepartment)
                 {
@@ -1662,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)
+        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) =>
             {
@@ -1683,12 +1713,31 @@
                     }
                 }
             };
-            gridView1.OptionsView.ShowGroupPanel = false;
-            gridView1.OptionsCustomization.AllowGroup = false;
-            // gridView1.Appearance.HeaderPanel.ForeColor = DevExpress.LookAndFeel.DXSkinColors.ForeColors.ControlText;
             gridView1.OptionsView.ColumnAutoWidth = false;//鑷姩璋冩暣鍒楀
+
+            if (isPostSearch == true)
+            {
+                gridView1.OptionsView.ShowGroupPanel = false;
+                gridView1.OptionsCustomization.AllowGroup = false;
+                gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False;
+                gridView1.OptionsView.ShowAutoFilterRow = true;
+                gridView1.OptionsFilter.AllowFilterEditor = false;
+                gridView1.OptionsFilter.ShowCustomFunctions = DevExpress.Utils.DefaultBoolean.False;
+                gridView1.OptionsFilter.AllowColumnMRUFilterList = false;
+                gridView1.OptionsFilter.AllowMRUFilterList = false;
+                gridView1.OptionsCustomization.AllowFilter = false;
+                gridView1.OptionsFind.ShowSearchNavButtons = false;
+                gridView1.OptionsView.ShowGroupPanel = false;
+                //鏄惁鏄剧ず搴曢儴鐨勮繃婊ゆ潯
+                // gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;
+            }
+
+            // gridView1.Appearance.HeaderPanel.ForeColor = DevExpress.LookAndFeel.DXSkinColors.ForeColors.ControlText;
             foreach (GridColumn column in gridView1.Columns)
             {
+                column.MinWidth = 10;
+                column.MaxWidth = 0;
+
                 column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                 column.OptionsColumn.AllowEdit = true;
                 // column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
@@ -1698,20 +1747,17 @@
                     column.OptionsColumn.ReadOnly = false;
                 else
                     column.OptionsColumn.ReadOnly = true;
-                if (column.Tag == null || column.Tag.ToString().Length <= 0)
-                    column.OptionsFilter.AllowAutoFilter = false;
+                
+                if(isPostSearch==false)
+                    column.OptionsColumn.ReadOnly = true;
+
+                if (isPostSearch == true)
+                {
+                    if (column.Tag == null || column.Tag.ToString().Length <= 0)
+                        column.OptionsFilter.AllowAutoFilter = false;
+                }
             }
-            gridView1.OptionsFilter.AllowAutoFilterConditionChange = DevExpress.Utils.DefaultBoolean.False;
-            gridView1.OptionsView.ShowAutoFilterRow = true;
-            gridView1.OptionsFilter.AllowFilterEditor = false;
-            gridView1.OptionsFilter.ShowCustomFunctions = DevExpress.Utils.DefaultBoolean.False;
-            gridView1.OptionsFilter.AllowColumnMRUFilterList = false;
-            gridView1.OptionsFilter.AllowMRUFilterList = false;
-            gridView1.OptionsCustomization.AllowFilter = false;
-            gridView1.OptionsFind.ShowSearchNavButtons = false;
-            gridView1.OptionsView.ShowGroupPanel = false;
-            //鏄惁鏄剧ず搴曢儴鐨勮繃婊ゆ潯
-            // gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;
+
             gridView1.IndicatorWidth = 50;
             gridView1.CustomDrawRowIndicator += (s, e) =>
             {
@@ -1789,8 +1835,44 @@
                     //}
                 }
             };
-
-          
+            if (tips != null)
+            {
+                tips.Appearance.BackColor = Color.LightBlue; // 璁剧疆鑳屾櫙棰滆壊
+                tips.Appearance.ForeColor = Color.Black; // 璁剧疆鍓嶆櫙鑹诧紙鏂囧瓧棰滆壊锛�
+                gridView1.MouseMove += (s, e) =>
+                {
+                    try
+                    {
+                        GridHitInfo hi = gridView1.CalcHitInfo(new Point(e.X, e.Y));
+                        if (hi.InRowCell)
+                        {
+                            int cuRowHandle = hi.RowHandle;
+                            if (cuRowHandle < 0)
+                                return;
+                            DataRow curRow = gridView1.GetDataRow(cuRowHandle);
+                            var column = hi.Column;
+                            string showTxt = curRow[column.FieldName].ToString();
+                            ToolTipControllerShowEventArgs aa = new ToolTipControllerShowEventArgs();
+                            aa.AllowHtmlText = DefaultBoolean.True;
+                            aa.Title = column.Caption; //HTML, 绮椾綋 
+                            aa.ToolTip = showTxt; //鏂 
+                            aa.ShowBeak = true;
+                            aa.Rounded = true; ////鍦嗚 
+                            aa.RoundRadius = 7; //鍦嗚鐜� 
+                                                // aa.ToolTipType = ToolTipType.SuperTip; //瓒呯骇鏍峰紡锛屽彲澶氳鎴栨樉绀哄浘鏍� 
+                            aa.ToolTipType = ToolTipType.Standard;//鏍囧噯鏍峰紡锛屽彲鏄剧ず楦熷槾銆� 
+                            aa.IconType = ToolTipIconType.Information; //娑堟伅鍥炬爣 
+                            aa.IconSize = ToolTipIconSize.Small; //澶у浘鏍� 
+                            tips.ShowHint(aa);
+                        }
+                        else
+                            tips.HideHint();
+                    }
+                    catch (Exception exception)
+                    {
+                    }
+                };
+            }
         }
         private static void ActiveEditor_MouseUp(object sender, MouseEventArgs e)
         {
@@ -1896,6 +1978,8 @@
             {
                 // column.DefaultCellStyle.Alignment = true;
                 column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
+                column.MinWidth = 10;
+                column.MaxWidth = 0;
             }
             gridView1.OptionsView.ColumnAutoWidth = false;//鑷姩璋冩暣鍒楀
             gridView1.OptionsFilter.AllowFilterEditor = false;
@@ -1945,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>

--
Gitblit v1.9.3