lu
2025-04-14 ecb7a60de1639f520712ce95f99414b0dd2c9713
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
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using MES.Service.Modes;
using Newtonsoft.Json;
using System;
using System.Data;
 
 
namespace Gs.DevApp.DevFrm.QC
{
    public partial class Frm_MesDefectCodeShow : DevExpress.XtraEditors.XtraForm
    {
        string strGuid = "";
        string strUpGuid = "";
        string _webServiceName = "MesDefectCodeManager/";
        public Frm_MesDefectCodeShow(string _strGuid, string _strUpGuid)
        {
            InitializeComponent();
            getSelect();
            this.strGuid = _strGuid;
            this.strUpGuid = _strUpGuid;
 
            //这是更新
            if (!string.IsNullOrEmpty(this.strGuid))
            {
                getMode(strGuid);
                this.Text = "更新【" + txt_defectName.Text + "】";
                txt_sType.Enabled = false;
                return;
            }
            //这是增加子项
            if (!string.IsNullOrEmpty(strUpGuid))
            {
                getMode(strUpGuid);
                this.Text = "增加【" + txt_defectName.Text + "】的子项目";
                txt_sType.Enabled = false;
                txt_defectCode.Text = "";
                txt_defectName.Text = "";
                return;
            }
 
            this.Text = "增加新项";
 
        }
 
        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(strGuid.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());
            }
        }
 
        private void getMode(string strGuid)
        {
            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;
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, true);
 
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
    }
}