bug
lu
2025-06-12 3d46409edbd033d22cd0e781c36add3ef7f7f3a1
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
using DevExpress.XtraEditors.Controls;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm.PDA
{
    public partial class Frm_AreaBind : DevExpress.XtraEditors.XtraForm
    {
        public Frm_AreaBind()
        {
            InitializeComponent();
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            }, tips);
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, null, (value) =>
            {
                getModel(value);
            }, (value) =>
            {
 
            }, lbGuid);
            getPageList(1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1);
        }
 
        /// <summary>
        /// </summary>
        /// <param name="curPage">第几页</param>
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            string _where = " and 1=1 and  a.s_type='仓库分区' and a.pid<>'00000000-0000-0000-0000-000000000000'";
            var pgq = new PageQueryModel(1, 999999, "a.defect_name", "asc", "", _where);
            var json = JsonConvert.SerializeObject(pgq);
            try
            {
                var strReturn =
                    UtilityHelper.HttpPost("", "MesDefectCodeManager/GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                var dt = dd.rtnData.list;
 
                if (dt.Rows.Count > 0)
                {
                    gcMain1.DataSource = dt;
                    gcMain1.ForceInitialize();
                    gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                }
                else
                    UtilityHelper.SetDefaultTable(gcMain1, gridView1);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        private void getModel(string strGuid)
        {
            bool isEdit = false;
            if (toolBarMenu1.currentAction == "add") return;
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            var _obj = new
            {
                guid = strGuid //主建
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("", "MesDefectCodeManager/GetModel2",
                    JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    lbGuid.Text = strGuid;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    gvList.Add(gvMx2);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    foreach (var a in _job["rtnData"]["list"])
                    {
                        array.Add(a);
                    }
                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
                    if (dt.Rows.Count > 0)
                    {
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    JArray array2 = new JArray();
                    foreach (var a in _job["rtnData"]["list2"])
                    {
                        array2.Add(a);
                    }
                    DataTable dt2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString());
                    if (dt2.Rows.Count > 0)
                    {
                        gcMx2.BindingContext = new BindingContext();
                        gcMx2.DataSource = dt2;
                        gcMx2.ForceInitialize();
                        gvMx2.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx2);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
                    }
                }
                else
                {
                    MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 绑定人员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit2_ButtonClick(object sender,
            ButtonPressedEventArgs e)
        {
            if (e.Button.Index == 0)
            {
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new SelectUser(userGuid);
                frm.ShowDialog();
            }
        }
        /// <summary>
        /// 绑定物料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit3_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Index == 0)
            {
                var rowhandle = gridView1.FocusedRowHandle;
                var dr = gridView1.GetDataRow(rowhandle);
                var userGuid = dr["guid"].ToString();
                var frm = new SelectItem(userGuid);
                frm.ShowDialog();
            }
        }
        /// <summary>
        /// 删除人员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptDel1_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            delBind(e, gvMx1);
        }
        /// <summary>
        /// 删除物料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptDel2_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            delBind(e,gvMx2);
        }
 
 
        private void delBind(ButtonPressedEventArgs e, DevExpress.XtraGrid.Views.Grid.GridView gv)
        {
            var rowhandle = gv.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                var dr = gv.GetDataRow(rowhandle);
                var mxGuid = dr["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                var _obj = new
                {
                    guidList = mxGuid,
                };
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                        "MesSysPageviewManager/" + "DeleteUserBind",
                        JsonConvert.SerializeObject(_obj));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        if (_rtn.rtnCode > 0)
                        {
                            getModel(lbGuid.Text.Trim());
                        }
                    }
                    MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
    }
}