lu
2024-11-20 4b880429bff7f9ade1ebc25d7c1e425fb24e6dff
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -5,6 +5,7 @@
using System.Drawing;
using System.IO;
using System.Net;
using System.Net.Cache;
using System.Net.Http;
using System.Reflection;
using System.Resources;
@@ -12,7 +13,6 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.Office.Model;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
@@ -76,6 +76,9 @@
            request.Accept = "*/*";
            request.Timeout = 15000;
            request.AllowAutoRedirect = false;
            request.ServicePoint.Expect100Continue = false;
            HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
            request.CachePolicy = noCachePolicy;
            using (Stream requestStream = await request.GetRequestStreamAsync())
            {
                byte[] dataBytes = Encoding.UTF8.GetBytes(param);
@@ -110,6 +113,9 @@
            request.Accept = "*/*";
            request.Timeout = 15000;
            request.AllowAutoRedirect = false;
            request.ServicePoint.Expect100Continue = false;
            HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
            request.CachePolicy = noCachePolicy;
            StreamWriter requestStream = null;
            WebResponse response = null;
            string responseStr = null;
@@ -283,8 +289,10 @@
        {
            isEdt = !isEdt;
            if (gridViews != null)
                foreach (var gv in gridViews) {
                    foreach (GridColumn colmn in gv.Columns) {
                foreach (var gv in gridViews)
                {
                    foreach (GridColumn colmn in gv.Columns)
                    {
                        if (colmn.Name.ToString().Contains("gvMxDel"))
                        {
                            colmn.Visible = !isEdt;
@@ -293,8 +301,9 @@
                    }
                    gv.OptionsBehavior.Editable = !isEdt;
                }
           var _btnAry=  controls.Find("btnSelect", false);
            if (_btnAry.Length > 0) {
            var _btnAry = controls.Find("btnSelect", false);
            if (_btnAry.Length > 0)
            {
                var _btnType = _btnAry[0];
                _btnType.Enabled = !isEdt;
            }
@@ -389,7 +398,7 @@
                            txt.ReadOnly = isEdt;
                            continue;
                        }
                        //数字卡
                        if (colType is NumericUpDown)
                        {
@@ -457,9 +466,9 @@
                            var txt = colType as Label;
                            if (_dddddd == "txt_checkStatus")
                            {
                                if (strVal == "True" || strVal=="1")
                                if (strVal == "True" || strVal == "1")
                                    txt.Text = "已审核";
                                if (strVal == "False" || strVal=="0" || strVal=="")
                                if (strVal == "False" || strVal == "0" || strVal == "")
                                    txt.Text = "未审核";
                            }
                            else
@@ -471,8 +480,11 @@
                        if (colType is UcLookCk)
                        {
                            var txt = colType as UcLookCk;
                            txt.SetIdOrCode( strVal);
                            txt.Enabled = !isEdt;
                            txt.SetIdOrCode(strVal);
                            if (txt.IsReadly == false)
                                txt.Enabled = !isEdt;
                            else
                                txt.Enabled = false;
                            continue;
                        }
                        //自定义供应商
@@ -480,7 +492,10 @@
                        {
                            var txt = colType as UcLookSupplier;
                            txt.SetIdOrCode(strVal);
                            txt.Enabled = !isEdt;
                            if (txt.IsReadly == false)
                                txt.Enabled = !isEdt;
                            else
                                txt.Enabled = false;
                            continue;
                        }
                        //自定义物料
@@ -488,7 +503,10 @@
                        {
                            var txt = colType as UcLookItems;
                            txt.SetIdOrCode(strVal);
                            txt.Enabled = !isEdt;
                            if (txt.IsReadly == false)
                                txt.Enabled = !isEdt;
                            else
                                txt.Enabled = false;
                            continue;
                        }
                        if (colType is SimpleButton)
@@ -695,7 +713,8 @@
                }
                //单选
                if (ctrl is CheckBox) {
                if (ctrl is CheckBox)
                {
                    ctrl.Enabled = !isEdt;
                    continue;
                }
@@ -808,10 +827,23 @@
            return Guid.Parse(str);
        }
        public static int ToInt(string str) {
        public static int ToInt(string str)
        {
            try
            {
                return int.Parse(str);
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public static long ToLong(string str)
        {
            try
            {
                return long.Parse(str);
            }
            catch (Exception)
            {
@@ -852,7 +884,7 @@
                else
                {
                    _strGuid = dr["guid"].ToString();
                      _strName = dr[1].ToString();
                    _strName = dr[1].ToString();
                }
            }
@@ -983,6 +1015,28 @@
            return "";
        }
        public static void SetCheckIco(object s, PictureBox btnChkIco, Form fm,string icoName="")
        {
            GridView dgv = s as GridView;
            if (dgv != null) {
                if (dgv.GetSelectedRows() != null) {
                    var selectedRow = dgv.GetSelectedRows()[0]; // 获取第一个选中行的索引
                    if (selectedRow >= 0) {
                        var checkStatus = dgv.GetRowCellValue(selectedRow, "checkStatus").ToString(); // 获取指定列的值
                        btnChkIco.Text = checkStatus;
                        btnChkIco.Visible = true;
                        if (checkStatus == "1" || checkStatus.ToUpper() == true.ToString().ToUpper())
                            btnChkIco.Image = global::Gs.DevApp.Properties.Resources.ico_check;
                        else
                            btnChkIco.Image = global::Gs.DevApp.Properties.Resources.ico_noCheck;
                        btnChkIco.Anchor = AnchorStyles.Top | AnchorStyles.Right; // 靠右
                        btnChkIco.Location = new Point(fm.ClientSize.Width - btnChkIco.Width - 20, 80); // 距离顶部10像素
                    }
                }
            }
        }
    }
    /// <summary>