lu
2025-04-03 47aa4ae2904b057c6ebadfe7f7bf801b9bb64fef
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
ÎļþÃû´Ó DevApp/Gs.DevApp/DevFrm/Work/SelectDictionary.cs ÐÞ¸Ä
@@ -1,19 +1,23 @@
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList;
using 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;//关键代码,就是不知道是这样获取数据而纠结了很久(鬼知道可以转换为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
    }
}