123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicForm;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_OutBoxSnCheck : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- LogStringBuilder sql;
- DataTable dt;
- public Make_OutBoxSnCheck()
- {
- InitializeComponent();
- }
- private void Make_LabelCheck_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- //聚焦SN号
- pa_outboxcode.Focus();
- //打开界面提示用户:请输入SN
- OperateResult.AppendText(">>请采集箱号\n", Color.Black);
- sql = new LogStringBuilder();
- dh = SystemInf.dh;
- }
- string pa_nextstep = "";
- private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- string ErrorMessage = "";
- private void sncode_KeyDown(object sender, KeyEventArgs e)
- {
- //判断是enter事件
- if (e.KeyCode == Keys.Enter)
- {
- if (sncode.Text == "")
- {
- OperateResult.AppendText("<<输入不能为空\n", Color.Red);
- return;
- }
- bool FindSN = false;
- bool AllCheck = true;
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + sncode.Text + "' order by mil_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + sncode.Text + "' order by mil_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
- }
- }
- }
- }
- int CheckRow = 0;
- for (int i = 0; i < CheckSnDGV.Rows.Count; i++)
- {
- if (CheckSnDGV.Rows[i].Cells["pd_barcode"].Value.ToString() == sncode.Text)
- {
- if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
- {
- CheckSnDGV.Rows[i].Cells["pd_checksn"].Value = sncode.Text;
- FindSN = true;
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱装箱核对成功", "核对条码" + sncode.Text + "箱号" + pa_outboxcode.Text, "", "");
- }
- else
- {
- OperateResult.AppendText("<<SN" + sncode.Text + "已校验\n", Color.Red, sncode);
- return;
- }
- }
- if (CheckSnDGV.Rows[i].Cells["pd_checksn"].Value == null)
- {
- AllCheck = false;
- }
- else
- {
- CheckRow = CheckRow + 1;
- }
- }
- if (FindSN)
- {
- OperateResult.AppendText("<<SN" + sncode.Text + "校验成功\n", Color.Green, sncode);
- }
- else
- {
- OperateResult.AppendText("<<SN" + sncode.Text + "校验失败,不在箱中\n", Color.Red, sncode);
- }
- CheckNum.Text = CheckRow + "/" + CheckSnDGV.Rows.Count;
- if (AllCheck)
- {
- if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode)
- {
- if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集", out ErrorMessage))
- {
- dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + pa_outboxcode.Text + "'").ToString() + "', PA_CURRENTSTEP = '' ", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- }
- }
- OperateResult.AppendText("<<卡通箱核对成功\n", Color.DarkGreen, sncode);
- CheckRow = 0;
- SetCheck set = new SetCheck("OK", Color.Green);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- pa_outboxcode.Clear();
- pa_outboxcode.Focus();
- }
- }
- }
- private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- dt = (DataTable)dh.ExecuteSql("select pd_barcode,pd_makecode pa_makecode,pa_nextstep from packagedetail left join package on pa_id=pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- //CheckNum.Text = CheckRow + "/" + CheckSnDGV.Rows.Count;
- pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
- if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "")
- {
- OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "的下一工序" + pa_nextstep + "不是当前岗位资源对应工序\n", Color.Red);
- return;
- }
- BaseUtil.FillDgvWithDataTable(CheckSnDGV, dt);
- BaseUtil.SetFormValue(this.Controls, dt);
- sncode.Focus();
- }
- else
- {
- OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
- }
- }
- }
- private void cancel_Click(object sender, EventArgs e)
- {
- }
- }
- }
|