lu
2025-04-03 a9e7dd0920d8d57dc5e3831a8a01a4b81457fb1c
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
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using MES.Service.Modes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
 
 
namespace Gs.DevApp.DevFrm.QC
{
    public partial class Frm_MesDefectCodeShow : DevExpress.XtraEditors.XtraForm
    {
        string lbGuid = "";
        string strTitle = "";
        string strUpGuid = "";
        string _webServiceName = "MesDefectCodeManager/";
        public Frm_MesDefectCodeShow(string _lbGuid, string _strTitle, string _strUpGuid)
        {
            InitializeComponent();
            getSelect();
            this.lbGuid = _lbGuid;
            this.strTitle = _strTitle;
            this.strUpGuid = _strUpGuid;
            if (string.IsNullOrEmpty(lbGuid))
            {
                this.Text = strTitle;
            }
            else
            {
                this.Text = "更新【" + strTitle + "】";
                var _obj = new
                {
                    guid = lbGuid,//主建
                };
                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;
                        UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, true);
                        txt_sType.Enabled = false;
                    }
                    else
                        ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
 
        private void btnQuery_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_defectCode.Text))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("编号不能为空!");
                txt_defectCode.Focus();
                return;
            }
            if (txt_sType.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("类型不能为空!");
                txt_sType.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_defectName.Text))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("名称不能为空!");
                txt_defectName.Focus();
                return;
            }
            var _obj = new MesDefectCode()
            {
                Guid = UtilityHelper.ToGuid(lbGuid.Trim()),
                DefectCode = txt_defectCode.Text.Trim(),
                SType = txt_sType.Text.Trim(),
                DefectName = txt_defectName.Text.Trim(),
                Pid= UtilityHelper.ToGuid(strUpGuid.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)
                {
                    UpdateParent?.Invoke(this, new UpdateParentEventArgs { StringSingle = "" });
                    Close();
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        private void btnEsc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        /// <summary>
        ///     回调事件
        /// </summary>
        public event EventHandler<UpdateParentEventArgs> UpdateParent;
 
 
        private void getSelect() {
 
            var _obj = new
            {
              
            };
            var strReturn = UtilityHelper.HttpPost("", _webServiceName + "SelectCategory", JsonConvert.SerializeObject(_obj));
            var dd = UtilityHelper.ReturnToList(strReturn);
            var dt = dd.rtnData;
            txt_sType.Properties.Items.Add("-请选择-");
            txt_sType.SelectedIndex = 0;
            foreach (DataRow dr in dt.Rows)
            {
                txt_sType.Properties.Items.Add(dr["typeMemo"].ToString());
            }
        }
    }
}