lu
2025-04-03 2f7e917dc9032961335d506a689bfd30c709ba9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using Gs.DevApp.DevFrm.QC;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm
{
    public partial class Frm_MesDefectCode : DevExpress.XtraEditors.XtraForm
    {
        string _webServiceName = "MesDefectCodeManager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        public Frm_MesDefectCode()
        {
            InitializeComponent();
            tlMenu.ContextMenuStrip = contextMenuStrip1;
            toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            this.toolBarMenu1.getXmlConfig();
            tlMenu.IndicatorWidth = 50;
            tlMenu.CustomDrawNodeIndicator += (s, ee) =>
            {
                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 void TlMenu_MouseDown(object sender, MouseEventArgs e)
        {
            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 ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            Gs.DevApp.ToolBox.MsgHelper.ShowInformation("该窗体不支持查询,若想更新页面,请点击 刷新");
        }
 
        /// <summary>
        /// 刷新事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            _filterList.Clear();
            getPageList(1);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curPage">第几页</param>
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            var pgq = new PageQueryModel(1, 999999, "a.defect_name");
            var json = JsonConvert.SerializeObject(pgq);
            try
            {
                var strReturn =
                    UtilityHelper.HttpPost("", _webServiceName+"GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                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);
            }
 
        }
    }
}