From 2f7e917dc9032961335d506a689bfd30c709ba9e Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期四, 03 四月 2025 11:01:52 +0800
Subject: [PATCH] 字典

---
 DevApp/Gs.DevApp/DevFrm/QC/Frm_MesDefectCode.cs |  392 ++++++++++++++++++-------------------------------------
 1 files changed, 132 insertions(+), 260 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesDefectCode.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesDefectCode.cs
index a3eece3..2c871d0 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesDefectCode.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesDefectCode.cs
@@ -1,12 +1,12 @@
+using DevExpress.XtraTreeList;
+using DevExpress.XtraTreeList.Nodes;
+using Gs.DevApp.DevFrm.QC;
 using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
-using Gs.DevApp.UserControl;
-using MES.Service.Modes;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
-using System.Data;
-using System.Threading.Tasks;
+using System.Drawing;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm
@@ -18,49 +18,129 @@
         public Frm_MesDefectCode()
         {
             InitializeComponent();
-            this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
-            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
-            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
-            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
-            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
-            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
+            tlMenu.ContextMenuStrip = contextMenuStrip1;
+            toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
             this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
-            gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
-            Gs.DevApp.ToolBox.UtilityHelper.SetGridSear(gridView1);
-            getPageList(1);
-            pageBar1.PagerEvent += PageBar1_PagerEvent;
-            txt_pid.EditChanged += (s, e) =>
+            this.toolBarMenu1.getXmlConfig();
+            tlMenu.IndicatorWidth = 50;
+            tlMenu.CustomDrawNodeIndicator += (s, ee) =>
             {
-                txt_typeMemo.Text = this.txt_pid.GetMemo();
+                if (ee.IsNodeIndicator)
+                {
+                    var index = ee.Node.TreeList.GetVisibleIndexByNode(ee.Node);
+                    ee.Info.DisplayText = (index + 1).ToString();
+                }
+            };
+            getPageList(1);
+            this.tlMenu.MouseDown += TlMenu_MouseDown;
+            this.toolStripMenuItemAdd.Click += (s, ee) =>
+            {
+                string strGuid = "";
+                string strUpGuid = "";
+                if (tlMenu.FocusedNode != null)
+                {
+                    strUpGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
+                }
+                Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, "澧炲姞瀛愰」", strUpGuid);
+                frm.UpdateParent += (s2, ee2) =>
+                {
+                    getPageList(1);
+                };
+                frm.ShowDialog(); 
+            };
+            this.toolStripMenuItemRoot.Click += (s, ee) =>
+            {
+                string strGuid = "";
+                string strUpGuid = "";
+                Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, "澧炲姞椤圭洰", strUpGuid);
+                frm.UpdateParent += (s2, ee2) =>
+                {
+                    getPageList(1);
+                };
+                frm.ShowDialog();
+            };
+            this.toolStripMenuItemDel.Click += (s, ee) =>
+            {
+                if (tlMenu.FocusedNode != null)
+                {
+                    string rowGuid = "";
+                    string rowName = "";
+                    rowGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
+                    rowName = tlMenu.FocusedNode.GetValue("defectName").ToString();
+                    if (string.IsNullOrEmpty(rowGuid))
+                    {
+                        ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                        return;
+                    }
+                    if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
+                        return;
+                    List<dynamic> lst = new List<dynamic>();
+                    lst.Add(rowGuid);
+                    var _obj = lst;
+                    try
+                    {
+                        string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
+                        ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
+                        if (_rtn.rtnCode > 0)
+                        {
+                            tlMenu.DeleteNode(tlMenu.FocusedNode);
+                        }
+                        else
+                            ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+                    }
+                    catch (Exception ex)
+                    {
+                        ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+                    }
+                }
+            };
+            this.toolStripMenuItemEdt.Click += (s, ee) =>
+            {
+                string strGuid = "";
+                string strTitle = "";
+                string strUpGuid = "";
+                if (tlMenu.FocusedNode != null)
+                {
+                    strGuid = tlMenu.FocusedNode.GetValue("guid").ToString();
+                    strTitle = tlMenu.FocusedNode.GetValue("defectName").ToString();
+                    strUpGuid = tlMenu.FocusedNode.GetValue("pid").ToString();
+                }
+                Frm_MesDefectCodeShow frm = new Frm_MesDefectCodeShow(strGuid, strTitle, strUpGuid);
+                frm.UpdateParent += (s2, ee2) =>
+                {
+                    getPageList(1);
+                };
+                frm.ShowDialog();
             };
         }
 
-        private async void GridView1_ColumnFilterChanged(object sender, EventArgs e)
+        private void TlMenu_MouseDown(object sender, MouseEventArgs e)
         {
-            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns);
-            await Task.Delay(100);
-            getPageList(1);
+            if (e.Button == MouseButtons.Right)
+            {
+                tlMenu.ContextMenuStrip = null;
+                TreeListHitInfo hInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y));
+                TreeListNode node = hInfo.Node;
+                tlMenu.FocusedNode = node;
+                if (node != null)
+                {
+                    toolStripMenuItemAdd.Visible = true;
+                    toolStripMenuItemEdt.Visible = true;
+                    toolStripMenuItemDel.Visible = true;
+                    toolStripMenuItemRoot.Visible = false;
+                    tlMenu.ContextMenuStrip = contextMenuStrip1;
+                }
+                else {
+                    toolStripMenuItemAdd.Visible = false;
+                    toolStripMenuItemEdt.Visible = false;
+                    toolStripMenuItemDel.Visible = false;
+                    toolStripMenuItemRoot.Visible = true;
+                    tlMenu.ContextMenuStrip = contextMenuStrip1;
+                }
+            }
         }
-        /// <summary>
-        /// 鍙屽嚮浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e)
-        {
-            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid");
-            if (!string.IsNullOrEmpty(rowGuid))
-                getModel(rowGuid, false, 999);
-        }
-        /// <summary>
-        /// 鍒嗛〉浜嬩欢
-        /// </summary>
-        /// <param name="curPage"></param>
-        /// <param name="pageSize"></param>
-        private void PageBar1_PagerEvent(int curPage, int pageSize)
-        {
-            getPageList(curPage);
-        }
+
+
         /// <summary>
         /// 鏌ヨ浜嬩欢
         /// </summary>
@@ -68,68 +148,7 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
         {
-            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
-            gridView1.ActiveFilter.Clear();
-            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
-            var frm = new ShowFilter(gridView1.Columns, _filterList);
-            frm.UpdateParent += Frm_UpdateParent;
-            frm.ShowDialog();
-        }
-        /// <summary>
-        /// 鏌ヨ鍥炶皟
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
-        {
-            _filterList = e.FilterList;
-            getPageList(1);
-        }
-
-        /// <summary>
-        /// 鍙栨秷浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
-        {
-            UtilityHelper.JumpToTab(xtraTabControl1, 0);
-        }
-
-        /// <summary>
-        /// 鍒犻櫎浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
-        {
-            string rowGuid = "", rowName = "";
-             (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_defectCode, gridView1);
-            if (string.IsNullOrEmpty(rowGuid))
-            {
-                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
-                return;
-            }
-            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + rowName + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
-                return;
-            List<dynamic> lst = new List<dynamic>();
-            lst.Add(rowGuid);
-            var _obj = lst;
-            try
-            {
-                string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
-                if (_rtn.rtnCode > 0)
-                {
-                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
-                    getPageList(1);
-                }
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-            }
-            catch (Exception ex)
-            {
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
-            }
+            Gs.DevApp.ToolBox.MsgHelper.ShowInformation("璇ョ獥浣撲笉鏀寔鏌ヨ锛岃嫢鎯虫洿鏂伴〉闈紝璇风偣鍑� 鍒锋柊");
         }
 
         /// <summary>
@@ -139,101 +158,9 @@
         /// <param name="e"></param>
         private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
         {
-            if (xtraTabControl1.SelectedTabPageIndex == 1)
-                getModel(lbGuid.Text.Trim(), false, 999);
-            else
-            {
-                _filterList.Clear();
-                if (gridView1.ActiveFilter.Count > 0)
-                {
-                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
-                    gridView1.ActiveFilter.Clear();
-                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
-                }
-                getPageList(1);
-            }
+            _filterList.Clear();
+            getPageList(1);
         }
-        /// <summary>
-        /// 淇敼浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
-        {
-            string rowGuid = "", rowName = "";
-            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_defectCode, gridView1);
-            if (string.IsNullOrEmpty(rowGuid))
-            {
-                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
-                return;
-            }
-            getModel(rowGuid, true, 1);
-        }
-        /// <summary>
-        /// 鏂板浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
-        {
-            UtilityHelper.JumpToTab(xtraTabControl1, 1);
-            lbGuid.Text = "";
-            UtilityHelper.CleanValueByControl(this.panel1.Controls, true);
-
-        }
-        /// <summary>
-        /// 淇濆瓨浜嬩欢
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
-        {
-            toolBarMenu1.isSetBtn = false;
-            string _txt_pid= txt_pid.GetGuid();
-            if (string.IsNullOrEmpty(txt_defectCode.Text.Trim()))
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("缂洪櫡浠g爜涓嶈兘涓虹┖锛�");
-                txt_defectCode.Focus();
-                return;
-            }
-            if (string.IsNullOrEmpty(txt_defectName.Text.Trim()))
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("缂洪櫡鍚嶇О涓嶈兘涓虹┖锛�");
-                txt_defectName.Focus();
-                return;
-            }
-            if (string.IsNullOrEmpty(_txt_pid))
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("缂洪櫡绫诲埆涓嶈兘涓虹┖锛�");
-                txt_pid.Focus();
-                return;
-            }
-            var _obj = new MesDefectCode()
-            {
-                Guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓
-                Pid = UtilityHelper.ToGuid(_txt_pid),
-                Memo=txt_memo.Text.Trim(),
-                DefectCode=txt_defectCode.Text.Trim(),
-                DefectName=txt_defectName.Text.Trim(),
-            };
-            try
-            {
-                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-                if (_rtn.rtnCode > 0)
-                {
-                    lbGuid.Text = _rtn.rtnData;
-                    toolBarMenu1.isSetBtn = true;
-                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false);
-                }
-            }
-            catch (Exception ex)
-            {
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
-            }
-        }
-
         /// <summary>
         /// 
         /// </summary>
@@ -241,80 +168,25 @@
         /// <param name="pageSize">姣忛〉鍑犳潯</param>
         private void getPageList(int curPage)
         {
-
-            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
-            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "a.defect_code",
-            "asc", "", _sbSqlWhere.ToString());
+            var pgq = new PageQueryModel(1, 999999, "a.defect_name");
             var json = JsonConvert.SerializeObject(pgq);
             try
             {
-                var strReturn = UtilityHelper.HttpPost("",
-                    _webServiceName + "GetListPage", json);
+                var strReturn =
+                    UtilityHelper.HttpPost("", _webServiceName+"GetListPage", json);
                 var dd = UtilityHelper.ReturnToTablePage(strReturn);
-                if (dd.rtnCode > 0)
-                {
-                    DataTable dt = dd.rtnData.list;
-                    gcMain.BindingContext = new BindingContext();
-                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
-                    if (dt.Rows.Count > 0)
-                    {
-                        gcMain.DataSource = dt;
-                        gcMain.ForceInitialize();
-                    }
-                    else
-                        UtilityHelper.SetDefaultTable(gcMain, gridView1);
-                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
-                    pageBar1.TotalPages = dd.rtnData.pages;//鎬婚〉
-                    pageBar1.CurrentPage = curPage;//褰撳墠椤�
-                    pageBar1.RecordCount = dd.rtnData.total;//鎬昏褰曟暟
-                }
-                else
-                {
-                    ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg);
-                }
+                var dt = dd.rtnData.list;
+                tlMenu.DataSource = dt;
+                tlMenu.KeyFieldName = "guid";
+                tlMenu.ParentFieldName = "pid";
+                tlMenu.EndUpdate();
+                this.tlMenu.CollapseAll();
             }
             catch (Exception ex)
             {
                 MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
             }
 
-        }
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="strGuid">涓婚敭</param>
-        /// <param name="isEdit">鏄惁鍙紪杈�</param>
-        /// <param name="tabIdx">閫夐」鍗″簭鍙�</param>
-        private void getModel(string strGuid, bool isEdit, int tabIdx)
-        {
-            if (string.IsNullOrEmpty(strGuid))
-            {
-                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
-                return;
-            }
-            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
-            var _obj = new
-            {
-                guid = strGuid,//涓诲缓
-            };
-            try
-            {
-                string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
-                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
-                if (_rtn.rtnCode > 0)
-                {
-                    dynamic dy = _rtn.rtnData;
-                    lbGuid.Text = strGuid;
-                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
-
-                }
-                else
-                    ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-            }
-            catch (Exception ex)
-            {
-                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
-            }
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3