1
duhe
2024-07-29 e486bdcca9a38e52874c231eb1a36731d747578f
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WorkM;
 
namespace MES
{
    public partial class FrmShow : Form
    {
        public FrmShow()
        {
            InitializeComponent();
        }
 
        private void pictureBox5_Click(object sender, EventArgs e)
        {
 
        }
 
        private void pictureBox1_Click(object sender, EventArgs e)
        {
 
        }
 
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                DAL.ClsSc_ProcessExchangeBill oPeb = new DAL.ClsSc_ProcessExchangeBill();
                if (oPeb.GetIDByNo(DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text), ref DBUtility.ClsPub.sExeReturnInfo) == false)
                {
                    MessageBox.Show(DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
                long lngBillKey = oPeb.omodel.HInterID;
                if (checkBox1.Checked == true)
                {
                    GetLastOut(lngBillKey);
                }
                else
                {
                    GetLotProc(lngBillKey);
                }
 
            }
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            txtHProcExchBillNo.Text = "";
            txtHProcExchBillNo.Select();
        }
 
 
        private void GetLotProc(long lngBillKey)
        {
            DataSet DsCheck;
            DataSet DsCheckIPQC;
            DataSet DsCheck2;
            DataSet Ds;
            DataSet DsFIFO;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            //ÅжÏÉϵÀ³öÕ¾ÊÇ·ñÆ·ÖÊÈ·ÈÏ
            DsCheckIPQC = oCn.RunProcReturn("exec h_p_MES_CheckIPQCCheckByLot " + lngBillKey, "h_p_MES_CheckIPQCCheckByLot");
            if (DsCheckIPQC.Tables[0].Rows.Count > 0)
            {
                if (DsCheckIPQC.Tables[0].Rows[0]["HBillType"].ToString() == "3791")
                {
                    MessageBox.Show("³öÕ¾µ¥£º" + DsCheckIPQC.Tables[0].Rows[0]["HBillNo"].ToString() + ",δÌá½»IPQCÆ·ÖÊÈ·ÈÏ£¬²»ÔÊÐí¼ÌÐøÉ¨Ã裡", "Ìáʾ");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
                else
                {
                    MessageBox.Show("ίÍâ½ÓÊÕµ¥£º" + DsCheckIPQC.Tables[0].Rows[0]["HBillNo"].ToString() + ",δÌá½»IPQCÆ·ÖÊÈ·ÈÏ£¬²»ÔÊÐí¼ÌÐøÉ¨Ã裡", "Ìáʾ");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
            }
            //ÅжÏÊÇ·ñ´æÔÚ½ÓÊÕÊýÁ¿²»µÈÓÚ·¢³öÊýÁ¿²¢ÇÒûÓÐÌá½»MRBÆÀÉ󵥵ijöÕ¾µ¥
            DsCheck2 = oCn.RunProcReturn("exec h_p_MES_CheckHaveNoPassByLot " + lngBillKey, "h_p_MES_CheckHaveNoPassByLot");
            if (DsCheck2.Tables[0].Rows.Count > 0)
            {
                if (DsCheck2.Tables[0].Rows[0]["HBillType"].ToString() == "3791")
                {
                    MessageBox.Show("³öÕ¾µ¥£º" + DsCheck2.Tables[0].Rows[0]["HBillNo"].ToString() + ",δÌá½»MRBÆÀÉóµ¥£¬²»ÔÊÐí¼ÌÐøÉ¨Ã裡", "Ìáʾ");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
                else
                {
                    MessageBox.Show("ίÍâ½ÓÊÕµ¥£º" + DsCheck2.Tables[0].Rows[0]["HBillNo"].ToString() + ",δÌá½»MRBÆÀÉóµ¥£¬²»ÔÊÐí¼ÌÐøÉ¨Ã裡", "Ìáʾ");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
            }
            //ÅжÏÊÇ·ñ´æÔÚδÉóºËMRBÆÀÉóµ¥
            DsCheck = oCn.RunProcReturn("select * from QC_NoPassProdCheckBillMain where HProcExchInterID = " + lngBillKey + " and HChecker='' ", "QC_NoPassProdCheckBillMain");
            if (DsCheck.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("ÉϵÀ¹¤ÐòMRBÆÀÉóµ¥Î´ÉóºË£¬²»ÔÊÐí¼ÌÐøÉ¨Ã裡", "Ìáʾ");
                txtHProcExchBillNo.Text = "";
                return;
            }
            //µÃµ½LOT¿¨ÐÅÏ¢
            Ds = oCn.RunProcReturn("exec h_p_Sc_GetProcByLotNo " + lngBillKey, "h_p_Sc_GetProcByLotNo");
            if (Ds == null)
            {
                MessageBox.Show("´íÎóÔ­Òò£º" + DBUtility.ClsPub.sErrInfo);
                txtHProcExchBillNo.Text = "";
                return;
            }
            if (Ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("LOTÎÞЧ!");
                txtHProcExchBillNo.Text = "";
                return;
            }
            //³öÕ¾µ¥
            if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "×ÔÖÆ")
            {
                DsFIFO = oCn.RunProcReturn("exec h_p_MES_LotFIFO '" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["µ¥¾ÝºÅ"]) + "'," + DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSubID"]) + ",'out'", "h_p_MES_LotFIFO");
                if (DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) != "OK")
                {
                    if (MessageBox.Show(DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) + ",ÊÇ·ñ¼ÌÐø£¿", "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    { }
                    else
                    {
                        txtHProcExchBillNo.Text = "";
                        return;
                    }
                }
                MES_StationOutBill oMES_StationOutBill = new MES_StationOutBill();
                oMES_StationOutBill.lngBillKey = lngBillKey;
                oMES_StationOutBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
                oMES_StationOutBill.ShowDialog();
            }
                //ίÍâ½ÓÊÕ
            else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "ίÍâ")
            {
                //if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HChecker"]) == "")
                //{
                //    MessageBox.Show("ίÍâ·¢³öµ¥:" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HJZBillNo"]) + "δÉóºË£¬²»ÔÊÐí½ÓÊÕ!");
                //    txtHProcExchBillNo.Text = "";
                //    return;
                //}
                if (DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HCloseType"]) != 0)
                {
                    MessageBox.Show("ίÍâ·¢³öµ¥:" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HJZBillNo"]) + "Òѹرգ¬²»ÔÊÐí½ÓÊÕ!");
                    txtHProcExchBillNo.Text = "";
                    return;
                }
                DsFIFO = oCn.RunProcReturn("exec h_p_MES_LotFIFO '" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["µ¥¾ÝºÅ"]) + "'," + DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSubID"]) + ",'out'", "h_p_MES_LotFIFO");
                if (DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) != "OK")
                {
                    if (MessageBox.Show(DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) + ",ÊÇ·ñ¼ÌÐø£¿", "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    { }
                    else
                    {
                        txtHProcExchBillNo.Text = "";
                        return;
                    }
                }
                MES_StationEntrustOutBill oMES_StationEntrustOutBill = new MES_StationEntrustOutBill();
                oMES_StationEntrustOutBill.lngBillKey = lngBillKey;
                oMES_StationEntrustOutBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
                oMES_StationEntrustOutBill.ShowDialog();
            }
                //ίÍâ·¢³ö
            else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "in" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "ίÍâ")
            {
                //ÏȽøÏȳö
                DsFIFO = oCn.RunProcReturn("exec h_p_MES_LotFIFO '" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["µ¥¾ÝºÅ"]) + "'," + DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSubID"]) + ",'in'", "h_p_MES_LotFIFO");
                if (DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) != "OK")
                {
                    if (MessageBox.Show(DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) + ",ÊÇ·ñ¼ÌÐø£¿", "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    { }
                    else
                    {
                        txtHProcExchBillNo.Text = "";
                        return;
                    }
                }
                MES_StationEntrustInBill oMES_StationEntrustInBill = new MES_StationEntrustInBill();
                oMES_StationEntrustInBill.lngBillKey = lngBillKey;
                oMES_StationEntrustInBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
                oMES_StationEntrustInBill.ShowDialog();
            }
                //½øÕ¾µ¥
            else
            {
                DsFIFO = oCn.RunProcReturn("exec h_p_MES_LotFIFO '" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["µ¥¾ÝºÅ"]) + "'," + DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HSubID"]) + ",'in'", "h_p_MES_LotFIFO");
                if (DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) != "OK")
                {
                    if (MessageBox.Show(DBUtility.ClsPub.isStrNull(DsFIFO.Tables[0].Rows[0][0]) + ",ÊÇ·ñ¼ÌÐø£¿", "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    { }
                    else
                    {
                        txtHProcExchBillNo.Text = "";
                        return;
                    }
                }
                MES_StationInBill oMES_StationInBill = new MES_StationInBill();
                oMES_StationInBill.lngBillKey = lngBillKey;
                oMES_StationInBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
                oMES_StationInBill.ShowDialog();
            }
            txtHProcExchBillNo.Text = "";
        }
 
        public MES_StationOutBill oFrm;
        public MES_StationEntrustOutBill oFrm2;
        private void GetLastOut(long HLotInterID)
        {
            DataSet Ds;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            Ds = oCn.RunProcReturn("exec h_p_Sc_GetLastOutByLotNo " + HLotInterID, "h_p_Sc_GetLastOutByLotNo");
            if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 0)
            {
                MessageBox.Show("²»´æÔÚ³öÕ¾µ¥£¡");
                txtHProcExchBillNo.Text = "";
                return;
            }
            if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][1]) == "×ÔÖÆ")
            {
                DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill();
                if (oBill.ShowBill(DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]), ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    oFrm = new MES_StationOutBill();
                    oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                    oFrm.BillOld = oBill;
                    oFrm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("µ¥¾ÝδÕÒµ½", "Ìáʾ");
                }
                oBill = null;
            }
            else
            {
                DAL.ClsSc_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill();
                if (oBill.ShowBill(DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]), ref DBUtility.ClsPub.sExeReturnInfo))
                {
                        oFrm2 = new MES_StationEntrustOutBill();
                        oFrm2.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                        oFrm2.BillOld = oBill;
                        oFrm2.ShowDialog();
                }
                else
                {
                    MessageBox.Show("µ¥¾ÝδÕÒµ½", "Ìáʾ");
                }
                oBill = null;
            }
            txtHProcExchBillNo.Text = "";
        }
 
        private void pictureBox6_Click(object sender, EventArgs e)
        {
 
        }
 
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            MES_StationOutBill oMES_StationOutBill = new MES_StationOutBill();
            oMES_StationOutBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
            oMES_StationOutBill.ModCaption = "Éú²úÍ깤»ã±¨µ¥";
            oMES_StationOutBill.ShowDialog();
        }
 
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            MES_StationInBill oMES_StationInBill = new MES_StationInBill();
            oMES_StationInBill.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
            oMES_StationInBill.ModCaption = "Éú²ú½øÕ¾È·Èϵ¥";
            oMES_StationInBill.ShowDialog();
        }
 
        private void pictureBox4_Click(object sender, EventArgs e)
        {
 
        }
 
        private void pictureBox7_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}