From 47aa4ae2904b057c6ebadfe7f7bf801b9bb64fef Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期四, 03 四月 2025 11:30:13 +0800
Subject: [PATCH] 选择字典
---
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.Designer.cs | 2
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.resx | 0
DevApp/Gs.DevApp/Gs.DevApp.csproj | 10 ++--
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs | 70 +++++++++++++++++++++++++++++++----
DevApp/Gs.DevApp/UserControl/UcDictionary.cs | 2
5 files changed, 69 insertions(+), 15 deletions(-)
diff --git a/DevApp/Gs.DevApp/Gs.DevApp.csproj b/DevApp/Gs.DevApp/Gs.DevApp.csproj
index 5c22d3f..54f208c 100644
--- a/DevApp/Gs.DevApp/Gs.DevApp.csproj
+++ b/DevApp/Gs.DevApp/Gs.DevApp.csproj
@@ -743,11 +743,11 @@
<Compile Include="DevFrm\Work\Frm_WorkTechnique.Designer.cs">
<DependentUpon>Frm_WorkTechnique.cs</DependentUpon>
</Compile>
- <Compile Include="DevFrm\Work\SelectDictionary.cs">
+ <Compile Include="UserControl\UcDictionarySelect.cs">
<SubType>Form</SubType>
</Compile>
- <Compile Include="DevFrm\Work\SelectDictionary.Designer.cs">
- <DependentUpon>SelectDictionary.cs</DependentUpon>
+ <Compile Include="UserControl\UcDictionarySelect.Designer.cs">
+ <DependentUpon>UcDictionarySelect.cs</DependentUpon>
</Compile>
<Compile Include="DevFrm\Work\SelectProcess.cs">
<SubType>Form</SubType>
@@ -1408,8 +1408,8 @@
<EmbeddedResource Include="DevFrm\Work\Frm_WorkTechnique.resx">
<DependentUpon>Frm_WorkTechnique.cs</DependentUpon>
</EmbeddedResource>
- <EmbeddedResource Include="DevFrm\Work\SelectDictionary.resx">
- <DependentUpon>SelectDictionary.cs</DependentUpon>
+ <EmbeddedResource Include="UserControl\UcDictionarySelect.resx">
+ <DependentUpon>UcDictionarySelect.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DevFrm\Work\SelectProcess.resx">
<DependentUpon>SelectProcess.cs</DependentUpon>
diff --git a/DevApp/Gs.DevApp/UserControl/UcDictionary.cs b/DevApp/Gs.DevApp/UserControl/UcDictionary.cs
index 16095ff..8503b12 100644
--- a/DevApp/Gs.DevApp/UserControl/UcDictionary.cs
+++ b/DevApp/Gs.DevApp/UserControl/UcDictionary.cs
@@ -48,7 +48,7 @@
private void simpleButton1_Click(object sender, EventArgs e)
{
- SelectDictionary frm = new SelectDictionary(this.BtnTxt, "");
+ UcDictionarySelect frm = new UcDictionarySelect(this.BtnTxt, "");
frm.UpdateParent += (ss, ee) =>
{
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.Designer.cs b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.Designer.cs
similarity index 98%
rename from DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.Designer.cs
rename to DevApp/Gs.DevApp/UserControl/UcDictionarySelect.Designer.cs
index 121317c..7019c36 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.Designer.cs
+++ b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.Designer.cs
@@ -1,6 +1,6 @@
锘縩amespace Gs.DevApp.DevFrm.Work
{
- partial class SelectDictionary
+ partial class UcDictionarySelect
{
/// <summary>
/// Required designer variable.
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.cs b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
similarity index 61%
rename from DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.cs
rename to DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
index 29bf1f2..e0aefaa 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.cs
+++ b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
@@ -1,19 +1,23 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraTreeList;
+锘縰sing DevExpress.XtraTreeList;
+using DevExpress.XtraTreeList.Nodes;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.Work
{
- public partial class SelectDictionary : DevExpress.XtraEditors.XtraForm
+ public partial class UcDictionarySelect : DevExpress.XtraEditors.XtraForm
{
+ private List<string> lstCheckedKeyID = new List<string>();//閫夋嫨灞�ID闆嗗悎
string strTitle = "";
string strWhere = "";
- public SelectDictionary(string _strTitle, string _strWhere)
+ public UcDictionarySelect(string _strTitle, string _strWhere)
{
InitializeComponent();
tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
@@ -27,12 +31,16 @@
this.Text = _strTitle;
btnIn.Click += (s, e) =>
{
+ findOrigin(tlMenu);
var list = new List<dynamic>();
- list.Add(new
+ foreach (string key in lstCheckedKeyID)
{
- dicCode = "001",
- dicTxt = "test1"
- });
+ list.Add(new
+ {
+ // dicCode = "001",
+ dicTxt = key
+ });
+ };
UpdateParent?.Invoke(this,
new UpdateParentEventArgs { DynamicList = list });
Close();
@@ -100,5 +108,51 @@
MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
}
+
+
+ #region MyRegion
+
+ /// <summary>
+ /// 鑾峰彇閫夋嫨鐘舵�佺殑鏁版嵁涓婚敭ID闆嗗悎
+ /// </summary>
+ /// <param name="parentNode">鐖剁骇鑺傜偣</param>
+ private void GetCheckedKeyID(TreeListNode parentNode)
+ {
+ if (parentNode.Nodes.Count == 0)
+ {
+ return;//閫掑綊缁堟
+ }
+ foreach (TreeListNode node in parentNode.Nodes)
+ {
+ if (node.CheckState == CheckState.Checked)
+ {
+ DataRowView drv = tlMenu.GetDataRecordByNode(node) as DataRowView;//鍏抽敭浠g爜锛屽氨鏄笉鐭ラ亾鏄繖鏍疯幏鍙栨暟鎹�岀籂缁撲簡寰堜箙(楝肩煡閬撳彲浠ヨ浆鎹负DataRowView鍟�)
+ if (drv != null)
+ {
+ string KeyFieldName = (string)drv["defectName"];
+ lstCheckedKeyID.Add(KeyFieldName);
+ }
+ }
+ GetCheckedKeyID(node);
+ }
+ }
+ /// <summary>
+ /// 鑾峰彇閫変腑鐨勮妭鐐�
+ /// </summary>
+ /// <param name="tree"></param>
+ private void findOrigin(DevExpress.XtraTreeList.TreeList tree)
+ {
+ this.lstCheckedKeyID.Clear();
+
+ if (tree.Nodes.Count > 0)
+ {
+ foreach (TreeListNode root in tree.Nodes)
+ {
+ GetCheckedKeyID(root);
+ }
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.resx b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.resx
similarity index 100%
rename from DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.resx
rename to DevApp/Gs.DevApp/UserControl/UcDictionarySelect.resx
--
Gitblit v1.9.3