lg
2025-12-01 fdd03a15cf958c62cedea4807da425c6ce3ccee6
DevApp/Gs.DevApp/DevFrm/Rk/SelectItemTbl.cs
@@ -1,4 +1,5 @@
using Gs.DevApp.ToolBox;
using DevExpress.XtraEditors;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -11,25 +12,70 @@
    {
        private readonly string _webServiceName = "MesItemTblManager/";
        private string daaGuid = "";
        //勾选次序
        Dictionary<string, int> ageDict = new Dictionary<string, int>();
        public SelectItemTbl(string _daaGuid)
        {
            InitializeComponent();
            #region  勾选
            this.gridView1.CustomDrawColumnHeader += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomDrawColumnHeader(s, e); };
            this.gridView1.MouseUp += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain, gridView1); };
            this.colChkInt.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
            this.colChkInt.OptionsFilter.AllowAutoFilter = false;
            this.colChkInt.OptionsFilter.AllowFilter = false;
            this.colChkInt.OptionsFilter.AllowInHeaderSearch = DevExpress.Utils.DefaultBoolean.False;
            this.colChkInt.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
            this.colChkInt.VisibleIndex = 0;
            #endregion
            #region 勾选次序2025-11-24
            this.gridView1.CellValueChanged += (s, e) =>
            {
                var row = gridView1.GetDataRow(e.RowHandle);
                var mxGuid = row["guid"].ToString();
                bool isChecked = (bool)e.Value;
                int dicCount = ageDict.Count + 1;
                if (isChecked)
                {
                    ageDict.Add(mxGuid, dicCount); // 添加新键值对
                }
            };
            #endregion
            this.daaGuid = _daaGuid;
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", null, null, false);
            getPageList(1);
            btnIn.Click += (s, e) =>
            {
                var list = new List<string>();
                int[] rows = this.gridView1.GetSelectedRows();//先获取选择行的行号
                DataTable dt = this.gcMain.DataSource as DataTable;//得到GridControl的数据源
                foreach (int idx in rows)
                gridView1.PostEditor();
                gridView1.UpdateCurrentRow();
                var list = new List<dynamic>();
                DataTable dt = this.gcMain.DataSource as DataTable;
                {
                    string _guid = dt.Rows[idx]["dabGuid"].ToString();
                    list.Add(_guid);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string checkBox = dr["chkInt"].ToString();
                        string _guid = dr["guid"].ToString();
                        int _idx = 0;
                        // 安全获取(推荐)
                        if (ageDict.TryGetValue(_guid, out _idx))
                        {
                        }
                        else
                            _idx = 0;
                        if (Gs.DevApp.ToolBox.UtilityHelper.ToCheck(checkBox))
                        {
                            list.Add(new
                            {
                                guid = _guid,
                                index = _idx
                            });
                        }
                    }
                }
                UpdateParent?.Invoke(this,
                    new UpdateParentEventArgs { StringList = list });
                Close();
                UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list }); Close();
            };
        }