From e6a9b817b0fd82dd89bf58107388edd1ab89bf11 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期五, 06 十二月 2024 10:22:52 +0800
Subject: [PATCH] 细节
---
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 170 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 108 insertions(+), 62 deletions(-)
diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index fecb3a4..de8f29d 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -13,6 +13,7 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
+using DevExpress.RichEdit.Export;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
@@ -25,6 +26,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static System.Windows.Forms.Control;
+
namespace Gs.DevApp.ToolBox
{
@@ -64,35 +66,35 @@
/// <param name="meth">鏂规硶鍚嶇О</param>
/// <param name="param">鍙傛暟</param>
/// <returns></returns>
- public static async Task<string> HttpPostAsync(string url, string meth, string param)
- {
- if (string.IsNullOrEmpty(url))
- url = WebApiUrl;
- url += meth;
- var request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "POST";
- request.ContentType = "application/json";
- request.Headers.Add("token", GetBasicAuthTicket());
- 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);
- await requestStream.WriteAsync(dataBytes, 0, dataBytes.Length);
- }
+ //public static async Task<string> HttpPostAsync(string url, string meth, string param)
+ //{
+ // if (string.IsNullOrEmpty(url))
+ // url = WebApiUrl;
+ // url += meth;
+ // var request = (HttpWebRequest)WebRequest.Create(url);
+ // request.Method = "POST";
+ // request.ContentType = "application/json";
+ // request.Headers.Add("token", GetBasicAuthTicket());
+ // 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);
+ // await requestStream.WriteAsync(dataBytes, 0, dataBytes.Length);
+ // }
- using (WebResponse response = await request.GetResponseAsync())
- {
- using (StreamReader reader = new StreamReader(response.GetResponseStream()))
- {
- return await reader.ReadToEndAsync();
- }
- }
- }
+ // using (WebResponse response = await request.GetResponseAsync())
+ // {
+ // using (StreamReader reader = new StreamReader(response.GetResponseStream()))
+ // {
+ // return await reader.ReadToEndAsync();
+ // }
+ // }
+ //}
/// <summary>
/// httpPost璁块棶鏈嶅姟
@@ -103,24 +105,28 @@
/// <returns></returns>
public static string HttpPost(string url, string meth, string param)
{
- if (string.IsNullOrEmpty(url))
- url = WebApiUrl;
- url += meth;
- var request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "POST";
- request.ContentType = "application/json";
- request.Headers.Add("token", GetBasicAuthTicket());
- request.Accept = "*/*";
- request.Timeout = 15000;
- request.AllowAutoRedirect = false;
- request.ServicePoint.Expect100Continue = false;
- HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
- request.CachePolicy = noCachePolicy;
+ DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("鎷煎懡鍔犺浇涓紝璇风◢鍚�..." + meth, "鍙嬫儏鎻愮ず");
+ HttpWebRequest request = null;
StreamWriter requestStream = null;
WebResponse response = null;
string responseStr = null;
try
{
+ if (string.IsNullOrEmpty(url))
+ url = WebApiUrl;
+ url += meth;
+ request = (HttpWebRequest)WebRequest.Create(url);
+ request.Method = "POST";
+ request.ContentType = "application/json";
+ request.Headers.Add("token", GetBasicAuthTicket());
+ request.Accept = "*/*";
+ request.Timeout = 15000;
+ request.AllowAutoRedirect = false;
+ request.ServicePoint.Expect100Continue = false;
+ wdf.SetCaption("鍔犺浇杩涘害锛�10/100锛�");
+ HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
+ request.CachePolicy = noCachePolicy;
+ wdf.SetCaption("鍔犺浇杩涘害锛�20/100锛�");
requestStream = new StreamWriter(request.GetRequestStream());
requestStream.Write(param);
requestStream.Close();
@@ -133,9 +139,11 @@
//File.WriteAllText(Server.MapPath("~/") + @"\test.txt", responseStr);
reader.Close();
}
+ wdf.SetCaption("鍔犺浇杩涘害锛�80/100锛�");
}
catch (Exception ex)
{
+ wdf.Close();
LogHelper.Debug(url, param + ":" + ex.Message);
throw ex;
}
@@ -145,7 +153,8 @@
requestStream = null;
response = null;
}
-
+ wdf.SetCaption("鍔犺浇杩涘害锛�90/100锛�");
+ wdf.Close();
return responseStr;
}
@@ -193,7 +202,14 @@
{
var dt = new DataTable();
foreach (GridColumn col in gv.Columns)
- dt.Columns.Add(col.FieldName, typeof(string));
+ {
+ if (col.UnboundDataType == typeof(bool))
+ dt.Columns.Add(col.FieldName, typeof(System.Boolean));
+ else
+ {
+ dt.Columns.Add(col.FieldName, typeof(string));
+ }
+ }
gc.BindingContext = new BindingContext();
gc.DataSource = dt;
gc.ForceInitialize();
@@ -293,13 +309,16 @@
{
foreach (GridColumn colmn in gv.Columns)
{
- if (colmn.Name.ToString().Contains("gvMxDel"))
+ if (colmn.Name.ToString().Contains("gvMxDel") || colmn.Name.ToString().Contains("gvMxTui"))
{
- colmn.Visible = !isEdt;
- break;
+ // colmn.Visible = !isEdt;
+ // break;
+ colmn.OptionsColumn.AllowEdit = true;
}
+ else
+ colmn.OptionsColumn.AllowEdit = !isEdt;
}
- gv.OptionsBehavior.Editable = !isEdt;
+ //gv.OptionsBehavior.Editable = !isEdt;
}
var _btnAry = controls.Find("btnSelect", false);
if (_btnAry.Length > 0)
@@ -607,13 +626,16 @@
{
foreach (GridColumn colmn in gv.Columns)
{
- if (colmn.Name.ToString().Contains("gvMxDel"))
+ if (colmn.Name.ToString().Contains("gvMxDel") || colmn.Name.ToString().Contains("gvMxTui"))
{
- colmn.Visible = !isEdt;
- break;
+ // colmn.Visible = !isEdt;
+ // break;
+ colmn.OptionsColumn.AllowEdit = true;
}
+ else
+ colmn.OptionsColumn.AllowEdit = !isEdt;
}
- gv.OptionsBehavior.Editable = !isEdt;
+ //gv.OptionsBehavior.Editable = !isEdt;
}
foreach (Control ctrl in controls)
{
@@ -782,13 +804,16 @@
{
foreach (GridColumn colmn in gv.Columns)
{
- if (colmn.Name.ToString().Contains("gvMxDel"))
+ if (colmn.Name.ToString().Contains("gvMxDel") || colmn.Name.ToString().Contains("gvMxTui"))
{
- colmn.Visible = !isEdt;
- break;
+ // colmn.Visible = !isEdt;
+ // break;
+ colmn.OptionsColumn.AllowEdit = true;
}
+ else
+ colmn.OptionsColumn.AllowEdit = !isEdt;
}
- gv.OptionsBehavior.Editable = !isEdt;
+ //gv.OptionsBehavior.Editable = !isEdt;
}
foreach (Control ctrl in controls)
{
@@ -1057,6 +1082,14 @@
return 0;
}
}
+
+ public static int ToBit(string str)
+ {
+ if (str.ToUpper() == "true".ToUpper())
+ return 1;
+ return 0;
+ }
+
/// <summary>
/// 璇诲彇grid鐨勫綋鍓嶈
/// </summary>
@@ -1311,16 +1344,20 @@
return _sbSqlWhere.ToString();
}
/// <summary>
- /// 鍒濆鍖杇ridview
+ ///
/// </summary>
- /// <param name="gridView1"></param>
- public static void SetGridSear(GridView gridView1)
+ /// <param name="gridView1">gridview</param>
+ /// <param name="btnChkIco">鍥炬爣鎸夐挳</param>
+ /// <param name="fm">褰撳墠绐椾綋</param>
+ /// <param name="fileName">瀛楁</param>
+ /// <param name="icoName">鍥炬爣璺緞</param>
+ public static void SetGridSear(GridView gridView1, PictureBox btnChkIco = null, Form fm = null, string fileName = "checkStatus", string icoName = "")
{
foreach (GridColumn column in gridView1.Columns)
{
column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains;
column.OptionsFilter.ImmediateUpdateAutoFilter = false;
- column.OptionsColumn.AllowEdit = false;
+ // column.OptionsColumn.AllowEdit = false;
if (column.Tag == null || column.Tag.ToString().Length <= 0)
column.OptionsFilter.AllowAutoFilter = false;
}
@@ -1345,10 +1382,15 @@
e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5);
e.Graphics.DrawString(str, f, Brushes.Gray, r);
};
-
+ if (btnChkIco != null)
+ {
+ gridView1.FocusedRowChanged += (s, e) =>
+ {
+ UtilityHelper.SetCheckIco(s, btnChkIco, fm, fileName, icoName);
+ };
+ }
}
#endregion
-
public static bool IsNumeric(string str)
{
@@ -1356,7 +1398,11 @@
return regex.IsMatch(str);
}
-
+ /// <summary>
+ /// yz_quantity_0锛寉z_瀛楁_绫诲瀷
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
public static void SetValidatingEditor(object sender, BaseContainerValidateEditorEventArgs e)
{
//yz_quantity_0
--
Gitblit v1.9.3