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
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.Text = "工序采集 - " + _fGx + " - " + fBc;
            this.fGx = _fGx;
            this.fBc = _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) =>
            {
                getModel("", badTag);
            };
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_checkVal">检测值</param>
        /// <param name="_checkResult">检测结果</param>
        private void getModel(string _checkVal, string _checkResult)
        {
            string _barCode = txt_barCode.Text.Trim();
            string _inBz = ""; ; //备注
            if (string.IsNullOrEmpty(_barCode))
            {
                Toast vm = new Toast(-1, "~请先扫追溯码~");
                vm.Show();
                return;
            }
            var _obj = new
            {
                barCode = _barCode,
                inBz = _inBz,
                checkVal = _checkVal,
                checkResult = _checkResult,
                processNo = txt_gx.Text.Trim(),//工序
                banCi = txt_bc.Text.Trim(),//班次
                gongWei = txt_gw.Text.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();
            }
        }
    }
}