lu
2025-05-08 f8ef4acfc742e9f32f0a2aa5d8bf9e122d26857f
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
using DevExpress.Utils.MVVM.Services;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm.Work
{
    public partial class Frm_Work01 : DevExpress.XtraEditors.XtraForm
    {
        string _webServiceName = "WorkCollect/";
        string fGx = "";
        string fBc = "";
        string goodTag = "√";
        string badTag = "×";
        public Frm_Work01(string _fGx, string _fBc)
        {
            InitializeComponent();
            this.fGx = _fGx;
            this.fBc = _fBc;
            this.Text = "工序采集 - " + fGx + " - " + fBc;
            txt_gx.Text = fGx;
            txt_bc.Text = fBc;
            txt_barCode.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter) { getModel("", goodTag); };
            };
            btnGood.Click += (s, e) =>
            {
                getModel("", goodTag);
            };
            btnBad.Click += (s, e) =>
            {
                UcDictionarySelect frm = new UcDictionarySelect("缺陷描述", " s_type='工序采集不良项目'");
                frm.UpdateParent += (ss, ee) =>
                {
                    System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                    var lst = ee.DynamicList;
                    foreach (dynamic dym in lst)
                    {
                        if (stringBuilder.Length > 0)
                            stringBuilder.Append("|");
                        stringBuilder.Append(dym.dicTxt);
                    }
                    string _txt = stringBuilder.ToString();
                    if (string.IsNullOrEmpty(_txt))
                    {
                        Toast vm = new Toast(-1, "~当为不良时,请选择不良项目~");
                        vm.Show();
                    }
                    else
                        getModel("", badTag, _txt);
                };
                frm.ShowDialog();
            };
        }
 
 
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_checkVal">检测值</param>
        /// <param name="_checkResult">检测结果</param>
        /// <param name="_badReson">不良原因</param>
        /// <param name="_inBz">备注</param>
        private void getModel(string _checkVal, string _checkResult, string _badReson = "", string _inBz = "")
        {
            string _barCode = txt_barCode.Text.Trim();
            if (string.IsNullOrEmpty(_barCode))
            {
                Toast vm = new Toast(-1, "~请先扫追溯码~");
                vm.Show();
                return;
            }
            var _obj = new
            {
                barCode = _barCode,
                inBz = _inBz.Trim(),
                checkVal = _checkVal,
                checkResult = _checkResult,
                processNo = txt_gx.Text.Trim(),//工序
                banCi = txt_bc.Text.Trim(),//班次
                gongWei = txt_gw.Text.Trim(),//工位
                badReson = _badReson.Trim()
            };
            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, false);
                    lbSum1.Text = dy.lbSum1;
                    lbSum2.Text = dy.lbSum2;
                    lbSum3.Text = dy.lbSum3;
                    lbSum4.Text = dy.lbSum4;
                    prog1.Position = dy.jd;
                    //良品
                    txt_barCode.ReadOnly = false;
                    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);
                    }
                    string _msg = _rtn.rtnMsg;
                    if (!string.IsNullOrEmpty(_msg))
                    {
 
                        Toast vm = new Toast((goodTag == "√" ? 1 : -1), _msg);
                        vm.Show();
                    };
                }
                else
                {
                    Toast vm = new Toast(-1, _rtn.rtnMsg);
                    vm.Show();
                }
            }
            catch (Exception ex)
            {
                Toast vm = new Toast(-1, ex.Message);
                vm.Show();
            }
        }
    }
}