From c115ac388af5a6928716f0146a75a2a42fb27d8e Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期日, 22 九月 2024 20:52:16 +0800
Subject: [PATCH] 仓库管理
---
DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs | 317 ++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 243 insertions(+), 74 deletions(-)
diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index a892778..38b4766 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -9,12 +9,13 @@
using System.Resources;
using System.Drawing;
using Newtonsoft.Json;
-using Gs.DevApp.Models;
+using Gs.DevApp.Entity;
using System.Windows.Forms;
using static System.Windows.Forms.Control;
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using System.Text.RegularExpressions;
+using System.Collections.Generic;
namespace Gs.DevApp.ToolBox
{
@@ -73,6 +74,17 @@
}
return responseStr;
}
+
+ /// <summary>
+ /// 璇诲彇榛樿椤靛ぇ灏�
+ /// </summary>
+ /// <returns></returns>
+ public static int GetPageSize()
+ {
+ return 50;
+ // return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString());
+ }
+
/// <summary>
/// 鏍规嵁鍥剧墖鍚嶈鍙栬祫婧愭枃浠�,涓嶅甫鍚庣紑鍚�
/// </summary>
@@ -112,11 +124,11 @@
return token;
}
/// <summary>
- /// 鏍囧噯json涓茶繑鍥濺eturnModel-->table锛�
+ /// 鏍囧噯json杩斿洖ReturnModel-->鍖呭惈TablePage鍒嗛〉锛�
/// </summary>
/// <param name="strReturn"></param>
/// <returns></returns>
- public static ReturnModel<PageListModel> GetTableByJson(string strReturn)
+ public static ReturnModel<PageListModel> ReturnToTablePage(string strReturn)
{
ReturnModel<PageListModel> rto = new ReturnModel<PageListModel>();
JObject json = JObject.Parse(strReturn);
@@ -137,11 +149,11 @@
return rto;
}
/// <summary>
- /// 鏍囧噯json涓茶繑鍥濺eturnModel->瀛楃涓诧紝
+ /// 鏍囧噯json杩斿洖ReturnModel锛�
/// </summary>
/// <param name="strReturn"></param>
/// <returns></returns>
- public static ReturnModel<dynamic> GetDataByJson(string strReturn)
+ public static ReturnModel<dynamic> ReturnToDynamic(string strReturn)
{
ReturnModel<dynamic> rto = new ReturnModel<dynamic>();
JObject json = JObject.Parse(strReturn);
@@ -152,11 +164,11 @@
}
/// <summary>
- /// 鏍囧噯json涓茶繑鍥濺eturnModel-->table锛�
+ /// 鏍囧噯json涓茶繑鍥濺eturnModel-->浠呬粎鏈塴ist,涓嶅垎椤碉紝
/// </summary>
/// <param name="strReturn"></param>
/// <returns></returns>
- public static ReturnModel<DataTable> GetNoPageTableByJson(string strReturn)
+ public static ReturnModel<DataTable> ReturnToList(string strReturn)
{
ReturnModel<DataTable> rto = new ReturnModel<DataTable>();
JObject json = JObject.Parse(strReturn);
@@ -173,17 +185,6 @@
rto.rtnData = dt;
return rto;
}
-
-
- /// <summary>
- /// 璇诲彇榛樿椤靛ぇ灏�
- /// </summary>
- /// <returns></returns>
- public static int GetPageSize()
- {
- return 50;
- // return int.Parse(System.Configuration.ConfigurationSettings.AppSettings.Get("PageSize").ToString());
- }
/// <summary>
/// 鏍规嵁瀵硅薄鎵归噺璁剧疆鏂囨湰鍊�
@@ -191,56 +192,103 @@
/// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param>
/// <param name="dynamicObject">瀵瑰儚</param>
/// <param name="isEdt">鏄惁鍙紪杈�</param>
- public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt)
+ public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
{
+ if (gridViews != null)
+ {
+ foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
+ {
+ gv.OptionsBehavior.Editable = isEdt;
+ }
+ }
foreach (JProperty property in dynamicObject.Properties())
{
string strName = property.Name;
string strVal = property.Value.ToString();
- // // 濡傛灉value鏄竴涓璞★紝鍙互閫掑綊閬嶅巻
- // if (property.Value is JObject)
- // {
- // JObject nestedObject = (JObject)property.Value;
- // foreach (JProperty nestedProperty in nestedObject.Properties())
- // {
- // Console.WriteLine("\tName: {0}, Value: {1}", nestedProperty.Name, nestedProperty.Value);
- // }
- // }
- Control[] cols = controls.Find("txt_" + strName, true);
- if (cols.Length > 0)
+ try
{
- Control colType = cols[0];
- //涓嬫媺
- if (colType is ComboBoxEdit)
+ // // 濡傛灉value鏄竴涓璞★紝鍙互閫掑綊閬嶅巻
+ // if (property.Value is JObject)
+ // {
+ // JObject nestedObject = (JObject)property.Value;
+ // foreach (JProperty nestedProperty in nestedObject.Properties())
+ // {
+ // Console.WriteLine("\tName: {0}, Value: {1}", nestedProperty.Name, nestedProperty.Value);
+ // }
+ // }
+ Control[] cols = controls.Find("txt_" + strName, true);
+ if (cols.Length > 0)
{
- ComboBoxEdit txt = colType as ComboBoxEdit;
- if (txt.Properties.TextEditStyle == DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor)
- txt.SelectedIndex = int.Parse(strVal);
- else
- txt.Text = strVal;
- txt.Enabled = isEdt;
- continue;
- }
- //鏂囨湰
- if (colType is TextEdit)
- {
- TextEdit txt = colType as TextEdit;
- if (txt != null)
- txt.Text = strVal;
- txt.Enabled = isEdt;
- continue;
- }
- //鏁板瓧鍗�
- if (colType is NumericUpDown)
- {
- NumericUpDown txt = colType as NumericUpDown;
- if (txt != null)
- txt.Text = strVal;
- txt.Enabled = isEdt;
- continue;
+ Control colType = cols[0];
+ //LookUpEdit
+ if (colType is LookUpEdit)
+ {
+ LookUpEdit txt = colType as LookUpEdit;
+ if (txt != null)
+ {
+ txt.EditValue = strVal;
+ // txt.Text = strVal;
+ }
+ txt.Enabled = isEdt;
+ continue;
+ }
+ //涓嬫媺
+ if (colType is ComboBoxEdit)
+ {
+ ComboBoxEdit txt = colType as ComboBoxEdit;
+ if (txt.Properties.TextEditStyle == DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor)
+ txt.SelectedIndex = int.Parse(strVal);
+ else
+ txt.Text = strVal;
+ txt.Enabled = isEdt;
+ continue;
+ }
+ //鏂囨湰
+ if (colType is TextEdit)
+ {
+ TextEdit txt = colType as TextEdit;
+ if (txt != null)
+ txt.Text = strVal;
+ txt.Enabled = isEdt;
+ continue;
+ }
+ //鏁板瓧鍗�
+ if (colType is NumericUpDown)
+ {
+ NumericUpDown txt = colType as NumericUpDown;
+ if (txt != null)
+ txt.Text = strVal;
+ txt.Enabled = isEdt;
+ continue;
+ }
+ //鍗曢��
+ if (colType is CheckEdit)
+ {
+ CheckEdit txt = colType as CheckEdit;
+ if (txt != null)
+ txt.Checked = (strVal.ToString() == "1" ? true : false);
+ txt.Enabled = isEdt;
+ continue;
+ }
+ //鏃堕棿
+ if (colType is DateTimePicker)
+ {
+ DateTimePicker txt = colType as DateTimePicker;
+ if (txt != null)
+ txt.Checked = (strVal.ToString() == "1" ? true : false);
+ txt.Enabled = isEdt;
+ continue;
+ }
}
}
+ catch (Exception ex)
+ {
+
+ MessageBox.Show(strName + ex.Message);
+ }
+
}
+
}
/// <summary>
@@ -248,8 +296,15 @@
/// </summary>
/// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param>
/// <param name="isEdt">鏄惁鍙紪杈�</param>
- public static void CleanValue(ControlCollection controls, Boolean isEdt)
+ public static void CleanValueByControl(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
{
+ if (gridViews != null)
+ {
+ foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
+ {
+ gv.OptionsBehavior.Editable = isEdt;
+ }
+ }
foreach (Control ctrl in controls)
{
ctrl.Enabled = isEdt;
@@ -286,10 +341,19 @@
/// </summary>
/// <param name="controls">controls:涓篻roupBox1.Controls/panel1.Controls</param>
/// <param name="isEdt">鏄惁鍙紪杈�</param>
- public static void ChangeEnable(ControlCollection controls, Boolean isEdt)
+ public static void ChangeEnableByControl(ControlCollection controls, Boolean isEdt, List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = null)
{
+ if (gridViews != null)
+ {
+ foreach (DevExpress.XtraGrid.Views.Grid.GridView gv in gridViews)
+ {
+ gv.OptionsBehavior.Editable = isEdt;
+ }
+ }
+
foreach (Control ctrl in controls)
{
+ ctrl.Enabled = isEdt;
//鏂囨湰
if (ctrl is TextEdit)
{
@@ -302,7 +366,12 @@
ctrl.Enabled = isEdt;
continue;
}
-
+ //鏃ユ湡
+ if (ctrl is DateTimePicker)
+ {
+ ctrl.Enabled = isEdt;
+ continue;
+ }
}
}
@@ -311,7 +380,7 @@
/// </summary>
/// <param name="tabControl">閫夐」鍗″鍣�</param>
/// <param name="idx">浠�0寮�濮嬶紝濡傛灉鏄�999锛屽垯鍏ㄩ儴鍙敤</param>
- public static void ChangeTab(XtraTabControl tabControl, int idx)
+ public static void JumpToTab(XtraTabControl tabControl, int idx)
{
if (idx == 999)
{
@@ -329,7 +398,6 @@
tabControl.TabPages[idx].PageEnabled = true;
tabControl.SelectedTabPageIndex = idx;
}
-
public static void TreeViewCheck(TreeViewEventArgs e)
{
@@ -384,20 +452,121 @@
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
- public static string ToCamelCase(string input)
+ public static string ToCamelCase(string propertyName)
{
- if (string.IsNullOrEmpty(input))
- return input;
-
- // 鍖归厤闈炲瓧姣嶆暟瀛楀瓧绗﹀悗鐨勭涓�涓瓧姣嶏紝骞跺皢鍏惰浆鎹负澶у啓
- return Regex.Replace(
- input,
- "([a-z])([A-Z])",
- "$1$2",
- RegexOptions.CultureInvariant
- ).Trim();
+ if (propertyName.Length > 0 && propertyName.All(char.IsUpper))
+ propertyName = propertyName.ToLower();
+ string dd = Regex.Replace(propertyName, @"_([a-z])", m => m.Groups[1].Value.ToUpper());
+ return dd;
}
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="xtraTabControl1"></param>
+ /// <param name="lbGuid">缂栬緫妗嗕腑鐨勪富閿悕</param>
+ /// <param name="txtName">缂栬緫妗嗕腑鐨勬枃鏈鍚�</param>
+ /// <param name="gridView1"></param>
+ /// <param name="gridRowName">鍒楄〃涓殑鏂囨湰鍒楀悕</param>
+ /// <param name="SelectedTabPageIndex"></param>
+ /// <returns></returns>
+ public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+ , System.Windows.Forms.Label lbGuid
+ , DevExpress.XtraEditors.TextEdit txtName
+ , DevExpress.XtraGrid.Views.Grid.GridView gridView1
+ , int SelectedTabPageIndex = 1)
+ {
+ string _strGuid = "";
+ string _strName = "";
+ if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
+ {
+ _strGuid = lbGuid.Text.Trim();
+ _strName = txtName.Text.Trim();
+ }
+ else
+ {
+ DataRow dr = gridView1.GetFocusedDataRow();
+ if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+ {
+ }
+ else {
+ _strGuid = dr["guid"].ToString();
+ _strName = dr[1].ToString();
+ }
+ }
+ return (_strGuid, _strName);
+ }
+ public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+ , System.Windows.Forms.Label lbGuid
+ , DevExpress.XtraEditors.TextEdit txtName
+ , System.Windows.Forms.TreeView tlMenu
+ , int SelectedTabPageIndex = 1)
+ {
+ string _strGuid = "";
+ string _strName = "";
+ if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
+ {
+ _strGuid = lbGuid.Text.Trim();
+ _strName = txtName.Text.Trim();
+ }
+ else
+ {
+ TreeNode clickedNode = tlMenu.SelectedNode;
+ if (clickedNode != null)
+ {
+ _strGuid = clickedNode.Name.ToString();
+ _strName = clickedNode.Text.Trim();
+ }
+ }
+ return (_strGuid, _strName);
+ }
+ public static (string, string) GetCurrentRow(XtraTabControl xtraTabControl1
+ , System.Windows.Forms.Label lbGuid
+ , DevExpress.XtraEditors.TextEdit txtName
+ , DevExpress.XtraTreeList.TreeList tlMenu
+ , int SelectedTabPageIndex = 1)
+ {
+ string _strGuid = "";
+ string _strName = "";
+ if (xtraTabControl1.SelectedTabPageIndex == SelectedTabPageIndex && lbGuid.Text.Length > 10)
+ {
+ _strGuid = lbGuid.Text.Trim();
+ _strName = txtName.Text.Trim();
+ }
+ else
+ {
+ _strGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
+ _strName = tlMenu.FocusedNode.GetValue(0).ToString();
+ }
+ return (_strGuid, _strName);
+ }
+ }
+
+ public class CboItemEntity
+ {
+ private object _text = 0;
+ private object _Value = "";
+ /// <summary>
+ /// 鏄剧ず鍊�
+ /// </summary>
+ public object Text
+ {
+ get { return this._text; }
+ set { this._text = value; }
+ }
+ /// <summary>
+ /// 瀵硅薄鍊�
+ /// </summary>
+ public object Value
+ {
+ get { return this._Value; }
+ set { this._Value = value; }
+ }
+
+ public override string ToString()
+ {
+ return this.Text.ToString();
+ }
}
}
--
Gitblit v1.9.3