|
|
@@ -0,0 +1,545 @@
|
|
|
+using NPOI.HSSF.UserModel;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
+using System.Drawing;
|
|
|
+using System.IO;
|
|
|
+using System.Windows.Forms;
|
|
|
+using UAS_MES_NEW.DataOperate;
|
|
|
+using UAS_MES_NEW.Entity;
|
|
|
+using UAS_MES_NEW.PublicMethod;
|
|
|
+
|
|
|
+namespace UAS_MES_NEW.Special
|
|
|
+{
|
|
|
+ public partial class Special_Reset : Form
|
|
|
+ {
|
|
|
+ DataHelper dh;
|
|
|
+
|
|
|
+ LogStringBuilder sql = new LogStringBuilder();
|
|
|
+ AutoSizeFormClass asc = new AutoSizeFormClass();
|
|
|
+ DataTable Dbfind;
|
|
|
+ DataTable dt;
|
|
|
+
|
|
|
+ List<String> sb = new List<string>();
|
|
|
+
|
|
|
+ public Special_Reset()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Special_BoxSplit_Load(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ dh = SystemInf.dh;
|
|
|
+ asc.controllInitializeSize(this);
|
|
|
+ cd_stepcode.FormName = Name;
|
|
|
+ cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
|
|
|
+ cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" };
|
|
|
+ cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
|
|
|
+ cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
|
|
|
+ cd_stepcode.DBTitle = "回流工序";
|
|
|
+ cd_stepcode.DbChange += Cd_stepcode_DbChange;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Cd_stepcode_DbChange(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ Dbfind = cd_stepcode.ReturnData;
|
|
|
+ BaseUtil.SetFormValue(this.Controls, Dbfind);
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool ReSN(string sncode, string stepcode)
|
|
|
+ {
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select ms_paststep,nvl(ms_qccheck,0)ms_qccheck,nvl(ms_ifqccheck,0)ms_ifqccheck,ms_makecode,nvl(ms_outstatus,0)ms_outstatus,nvl(pr_ifrepaircheck,0)pr_ifrepaircheck from makeserial left join product on pr_code=ms_prodcode where ms_sncode ='" + sncode + "' order by ms_id desc", "select");
|
|
|
+ if (!dt.Rows[0]["ms_paststep"].ToString().Contains(cd_stepcode.Text))
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(">>序列号" + sncode + "不允许回流到未执行工序\n", Color.Red);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["ms_outstatus"].ToString() == "-1")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(">>序列号" + sncode + "已出货不允许回流\n", Color.Red);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ((dt.Rows[0]["ms_qccheck"].ToString() == "-1"&& dt.Rows[0]["pr_ifrepaircheck"].ToString() == "-1") || dt.Rows[0]["ms_ifqccheck"].ToString() == "-1")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(">>序列号" + sncode + "处于抽检状态,不允许重置站点\n", Color.Red);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ string makecode = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
+ string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + stepcode + "'").ToString();
|
|
|
+ dh.ExecuteSql("update makeserial set ms_status=1,ms_outboxcode='',ms_printcount = 0,ms_stepcode='', ms_nextstepcode= '" + stepcode + "' where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'", "update");
|
|
|
+ dh.ExecuteSql("delete makebad where mb_sncode = '" + sncode + "' and mb_makecode='" + makecode + "' and mb_status = 0", "delete");
|
|
|
+ dh.ExecuteSql("delete labelprintlog where lpl_value = '" + sncode + "' ", "delete");
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("update craftmaterial set cm_status=-1,cm_lastdeco=-1,cm_dropman='" + User.UserCode + "',");
|
|
|
+ sql.Append("cm_dropdate =sysdate,CM_REMARK = '重置站点拆解',cm_dropstep='" + User.CurrentStepCode + "',");
|
|
|
+ sql.Append("cm_dropsccode='" + User.UserSourceCode + "' where cm_sncode = '" + sncode + "' and cm_makecode='" + makecode + "' and cm_stepcode in (select cd_stepcode from craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id where ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_detno >=" + cd_stepno.Text + " )");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "update");
|
|
|
+ LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sncode, "");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void Split_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (sb.Count == 0 || cd_stepcode.Text == "")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(">>采集数与回流工位不能为空\n", Color.Red);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ string Delete = MessageBox.Show(this.ParentForm, "是否确认重置站点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
+ if (Delete == "Yes")
|
|
|
+ {
|
|
|
+ if (serBtn.Checked)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < sb.Count; i++)
|
|
|
+ {
|
|
|
+ if (ReSN(sb[i].ToString(), cd_stepcode.Text))
|
|
|
+ OperatResult.AppendText("SN:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
|
|
|
+ }
|
|
|
+ WeighRecord.Clear();
|
|
|
+ sb.Clear();
|
|
|
+ }
|
|
|
+ else if (bigboxBtn.Checked)
|
|
|
+ {
|
|
|
+ string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + cd_stepcode.Text + "'").ToString();
|
|
|
+ for (int i = 0; i < sb.Count; i++)
|
|
|
+ {
|
|
|
+ if (dh.CheckExist("package", "pa_outboxcode='" + sb[i].ToString() + "' and pa_status=1"))
|
|
|
+ {
|
|
|
+ DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial left Join package on pa_outboxcode=ms_outboxcode where ms_outboxcode = '" + sb[i].ToString() + "' and pa_status=1", "select");
|
|
|
+ for (int k = 0; k < dt2.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
|
|
|
+ }
|
|
|
+ dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
|
|
|
+ dh.ExecuteSql("insert into PACKAGEBACKUP(PAB_ID, PAB_PRODCODE, PAB_OUTBOXCODE, PAB_PACKDATE, PAB_LEVEL, PAB_PACKAGEQTY, PAB_TOTALQTY, PAB_MAKECODE, PAB_STATUS,\r\nPAB_INDATE, PAB_SALECODE, PAB_PRINTCOUNT, PAB_CUSTCODE, PAB_TYPE, PAB_WEIGHT, PAB_CURRENTQTY, PAB_PACKTYPE, PAB_CHECKNO, PAB_DOWNSTATUS, PAB_STANDARDQTY, \r\nPAB_SCCODE, PAB_YMD, PAB_MOTHERCODE) select PA_ID, PA_PRODCODE, PA_OUTBOXCODE, \r\nPA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, \r\nPA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_CURRENTSTEP from package where pa_mothercode='" + sb[i].ToString() +"'", "insert");
|
|
|
+ dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
|
|
|
+ dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
|
|
|
+ //删除箱的明细
|
|
|
+ dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
|
|
|
+ LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sb[i].ToString(), "");
|
|
|
+ OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "未封箱,不允许回流\n", Color.Green);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ WeighRecord.Clear();
|
|
|
+ sb.Clear();
|
|
|
+ }
|
|
|
+ else if (pallet.Checked)
|
|
|
+ {
|
|
|
+ string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + cd_stepcode.Text + "'").ToString();
|
|
|
+ for (int i = 0; i < sb.Count; i++)
|
|
|
+ {
|
|
|
+ string pa_outboxcode = dh.getFieldDataByCondition("package", "pa_outboxcode", "pa_outboxcode='" + sb[i].ToString() + "' and pa_type=3").ToString();
|
|
|
+ if (dh.CheckExist("package", "pa_outboxcode='" + sb[i].ToString() + "' and pa_status=1"))
|
|
|
+ {
|
|
|
+ DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial left Join package on pa_outboxcode=ms_outboxcode where ms_outboxcode in(select pd_innerboxcode from packagedetail where pd_outboxcode='" + pa_outboxcode + "') and pa_status=1", "select");
|
|
|
+ for (int k = 0; k < dt2.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
|
|
|
+ }
|
|
|
+ dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
|
|
|
+ dh.ExecuteSql("insert into PACKAGEBACKUP(PAB_ID, PAB_PRODCODE, PAB_OUTBOXCODE, PAB_PACKDATE, PAB_LEVEL, PAB_PACKAGEQTY, PAB_TOTALQTY, PAB_MAKECODE, PAB_STATUS,\r\nPAB_INDATE, PAB_SALECODE, PAB_PRINTCOUNT, PAB_CUSTCODE, PAB_TYPE, PAB_WEIGHT, PAB_CURRENTQTY, PAB_PACKTYPE, PAB_CHECKNO, PAB_DOWNSTATUS, PAB_STANDARDQTY, \r\nPAB_SCCODE, PAB_YMD, PAB_MOTHERCODE) select PA_ID, PA_PRODCODE, PA_OUTBOXCODE, \r\nPA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, \r\nPA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_CURRENTSTEP from package where pa_mothercode='" + sb[i].ToString() + "'", "insert");
|
|
|
+ dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
|
|
|
+ dh.ExecuteSql("delete from package where pa_mothercode = '" + sb[i].ToString() + "'", "delete");
|
|
|
+ //删除箱的明细
|
|
|
+ dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
|
|
|
+ LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sb[i].ToString(), "");
|
|
|
+ OperatResult.AppendText("栈板:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("栈板:" + sb[i].ToString() + "未封箱,不允许回流\n", Color.Green);
|
|
|
+ }
|
|
|
+ if (pa_outboxcode != "")
|
|
|
+ {
|
|
|
+ List<string> SQLS = new List<string>();
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into packagebackupdetail(pbd_id,pbd_paid,pbd_outboxcode,pbd_innerboxcode,pbd_barcode,pbd_innerqty,pbd_prodcode,pbd_makecode,pbd_buildate,pbd_ymd)");
|
|
|
+ sql.Append("select pd_id,pd_paid,pd_outboxcode,pd_innerboxcode,pd_barcode,pd_innerqty,pd_prodcode,pd_makecode,pd_builddate,pd_ymd from packagedetail where ");
|
|
|
+ sql.Append("pd_outboxcode='" + pa_outboxcode + "'");
|
|
|
+ SQLS.Add(sql.GetString());
|
|
|
+ SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode + "'");
|
|
|
+ DataTable dt = dh.getFieldsDatasByCondition("packagedetail left join package on pa_id=pd_paid", new string[] { "nvl(sum(pd_innerqty),0)", "count(1)" }, "pa_outboxcode='" + pa_outboxcode + "'");
|
|
|
+ string totalqty = dt.Rows[0][0].ToString();
|
|
|
+ string currentqty = dt.Rows[0][1].ToString();
|
|
|
+ SQLS.Add("update package set PA_TOTALQTY='" + totalqty + "',pa_packageqty='" + currentqty + "',pa_currentqty='" + currentqty + "' where pa_outboxcode='" + pa_outboxcode + "'");
|
|
|
+ dh.ExecuteSQLTran(SQLS.ToArray());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ WeighRecord.Clear();
|
|
|
+ sb.Clear();
|
|
|
+ }
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("MERGE INTO makecraftdetail USING (select mcd_macode,mcd_detno,mcd_stepcode,mcd_stepname,nvl(count(distinct A.ms_sncode),0) n,nvl(count(distinct B.ms_sncode),0) bn,(select nvl(count(distinct sp_sncode),0) from STEPPASSED where SP_MAKECODE = mcd_macode AND SP_STEPCODE = mcd_stepcode) inqty from MAKECRAFTdetail");
|
|
|
+ sql.Append(" left join makeserial A on mcd_macode = A.ms_makecode and mcd_stepcode = A.ms_nextstepcode AND A.MS_STATUS = 1 LEFT JOIN MAKESERIAL B ON mcd_macode = B.ms_makecode AND MCD_STEPCODE = B.MS_STEPCODE AND B.MS_STATUS = 3 where mcd_macode = '" + ms_makecode.Text + "' group by mcd_macode,mcd_detno, mcd_stepcode, mcd_stepname order by mcd_detno asc) A");
|
|
|
+ sql.Append(" ON (makecraftdetail.MCD_MACODE = A.MCD_MACODE and makecraftdetail.mcd_stepcode = A.mcd_stepcode) ");
|
|
|
+ sql.Append(" WHEN MATCHED THEN UPDATE SET makecraftdetail.mcd_inqty = A.inqty,makecraftdetail.mcd_outqty = A.inqty,makecraftdetail.mcd_okqty = A.inqty ");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "update");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void bigboxBtn_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (((RadioButton)sender).Checked == true)
|
|
|
+ {
|
|
|
+ if (WeighRecord.Items.Count > 0)
|
|
|
+ {
|
|
|
+ string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
+ if (logout_confirm == "Yes")
|
|
|
+ {
|
|
|
+ WeighRecord.Items.Clear();
|
|
|
+ sb.Clear();
|
|
|
+ ms_makecode.Text = "";
|
|
|
+ ms_prodcode.Text = "";
|
|
|
+ cr_code.Text = "";
|
|
|
+ cd_stepcode.Text = "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ serBtn.Checked = bigboxBtn.Checked;
|
|
|
+ bigboxBtn.Checked = !serBtn.Checked;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (((RadioButton)sender).Name == "serBtn")
|
|
|
+ {
|
|
|
+ input.Focus();
|
|
|
+ OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
|
|
|
+ }
|
|
|
+ else if (((RadioButton)sender).Name == "bigboxBtn")
|
|
|
+ {
|
|
|
+ input.Focus();
|
|
|
+ OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
|
|
|
+ }
|
|
|
+ else if (((RadioButton)sender).Name == "pallet")
|
|
|
+ {
|
|
|
+ input.Focus();
|
|
|
+ OperatResult.AppendText("请输入栈板进行采集\n", Color.Black, input);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cr_code_TextChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void input_KeyDown(object sender, KeyEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.KeyCode == Keys.Enter)
|
|
|
+ {
|
|
|
+ if (serBtn.Checked)
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + input.Text + "' order by ms_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[0]["ms_sncode"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + input.Text + "' order by ms_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[0]["ms_sncode"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + input.Text + "' order by mil_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[0]["mil_sncode"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + input.Text + "' order by mil_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[0]["mil_sncode"].ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,ms_sncode,ms_craftcode cr_code,ms_status,ms_outboxcode from makeserial where ms_sncode = '" + input.Text + "' or ms_imei1='" + input.Text + "' or ms_imei2='" + input.Text + "' order by ms_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[0]["ms_sncode"].ToString();
|
|
|
+ if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["ms_status"].ToString() == "3")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
+ if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
|
|
|
+ sb.Add(dt.Rows[0]["ms_sncode"].ToString());
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
|
|
|
+ cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (bigboxBtn.Checked)
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pa_makecode ms_makecode,pa_prodcode ms_prodcode,pa_outboxcode,pa_mothercode,ma_craftcode,nvl(pa_iostatus,0)pa_iostatus,ma_craftcode cr_code from package left join make on pa_makecode = ma_code where pa_outboxcode = '" + input.Text + "' and pa_type = '1'", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "处于状态入库状态,不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["pa_mothercode"].ToString() != "")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
+ if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
|
|
|
+ sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
|
|
|
+ cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (pallet.Checked)
|
|
|
+ {
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pa_makecode ms_makecode,pa_prodcode ms_prodcode,pa_outboxcode,pa_mothercode,ma_craftcode,nvl(pa_iostatus,0)pa_iostatus,ma_craftcode cr_code from package left join make on pa_makecode = ma_code where pa_outboxcode = '" + input.Text + "' and pa_type = '3'", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("栈板:" + input.Text + "处于状态入库状态,不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (dt.Rows[0]["pa_mothercode"].ToString() != "")
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("栈板:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
+ if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("栈板:" + input.Text + "已采集\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
|
|
|
+ sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
|
|
|
+ OperatResult.AppendText("栈板:" + input.Text + "采集\n", Color.Green, input);
|
|
|
+ cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void 数据清空_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ BaseUtil.CleanControls(this.Controls);
|
|
|
+ WeighRecord.Items.Clear();
|
|
|
+ sb.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Special_Reset_SizeChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ asc.controlAutoSize(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Export_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ ExportFileDialog.Description = "选择导出的路径";
|
|
|
+ DialogResult result = ExportFileDialog.ShowDialog();
|
|
|
+ if (result == DialogResult.OK)
|
|
|
+ {
|
|
|
+ ExcelHandler eh = new ExcelHandler();
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select ''箱号,'' SN from dual ");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ eh.ExportExcel(dt, ExportFileDialog.SelectedPath + "\\导出模板.xls");
|
|
|
+ //string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ImportExcel_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ ImportExcel1.Filter = "(*.xls)|*.xls";
|
|
|
+ DialogResult result;
|
|
|
+ result = ImportExcel1.ShowDialog();
|
|
|
+ if (result == DialogResult.OK)
|
|
|
+ {
|
|
|
+ DataTable dt = ExcelToDataTable(ImportExcel1.FileName, true);
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (bigboxBtn.Checked)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[i]["箱号"].ToString();
|
|
|
+ input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
|
|
|
+ }
|
|
|
+ if (serBtn.Checked)
|
|
|
+ {
|
|
|
+ input.Text = dt.Rows[i]["SN"].ToString();
|
|
|
+ input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static DataTable ExcelToDataTable(string filePath, bool isColumnName)
|
|
|
+ {
|
|
|
+ DataTable dataTable = null;
|
|
|
+ FileStream fs = null;
|
|
|
+ DataColumn column = null;
|
|
|
+ DataRow dataRow = null;
|
|
|
+ IWorkbook workbook = null;
|
|
|
+ ISheet sheet = null;
|
|
|
+ IRow row = null;
|
|
|
+ ICell cell = null;
|
|
|
+ int startRow = 0;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (fs = File.OpenRead(filePath))
|
|
|
+ {
|
|
|
+ // 2007版本
|
|
|
+ workbook = new HSSFWorkbook(fs);
|
|
|
+ if (workbook != null)
|
|
|
+ {
|
|
|
+ sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
|
|
|
+ dataTable = new DataTable();
|
|
|
+ if (sheet != null)
|
|
|
+ {
|
|
|
+ int rowCount = sheet.LastRowNum;//总行数
|
|
|
+ if (rowCount > 0)
|
|
|
+ {
|
|
|
+ IRow firstRow = sheet.GetRow(0);//第一行
|
|
|
+ int cellCount = firstRow.LastCellNum;//列数
|
|
|
+
|
|
|
+ //构建datatable的列
|
|
|
+ if (isColumnName)
|
|
|
+ {
|
|
|
+ startRow = 1;//如果第一行是列名,则从第二行开始读取
|
|
|
+ for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
|
|
|
+ {
|
|
|
+ cell = firstRow.GetCell(i);
|
|
|
+ if (cell != null)
|
|
|
+ {
|
|
|
+ if (cell.StringCellValue != null)
|
|
|
+ {
|
|
|
+ column = new DataColumn(cell.StringCellValue);
|
|
|
+ dataTable.Columns.Add(column);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
|
|
|
+ {
|
|
|
+ column = new DataColumn("column" + (i + 1));
|
|
|
+ dataTable.Columns.Add(column);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //填充行
|
|
|
+ for (int i = startRow; i <= rowCount; ++i)
|
|
|
+ {
|
|
|
+ row = sheet.GetRow(i);
|
|
|
+ if (row == null) continue;
|
|
|
+
|
|
|
+ dataRow = dataTable.NewRow();
|
|
|
+ for (int j = row.FirstCellNum; j < cellCount; ++j)
|
|
|
+ {
|
|
|
+ cell = row.GetCell(j);
|
|
|
+ if (cell == null)
|
|
|
+ {
|
|
|
+ dataRow[j] = "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
|
|
|
+ switch (cell.CellType)
|
|
|
+ {
|
|
|
+ case CellType.BLANK:
|
|
|
+ dataRow[j] = "";
|
|
|
+ break;
|
|
|
+ case CellType.NUMERIC:
|
|
|
+ short format = cell.CellStyle.DataFormat;
|
|
|
+ //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
|
|
|
+ if (format == 14 || format == 31 || format == 57 || format == 58)
|
|
|
+ dataRow[j] = cell.DateCellValue;
|
|
|
+ else
|
|
|
+ dataRow[j] = cell.NumericCellValue;
|
|
|
+ break;
|
|
|
+ case CellType.STRING:
|
|
|
+ dataRow[j] = cell.StringCellValue;
|
|
|
+ break;
|
|
|
+ case CellType.FORMULA:
|
|
|
+ dataRow[j] = cell.StringCellValue;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataTable.Rows.Add(dataRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dataTable;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine(ex.Message);
|
|
|
+ if (fs != null)
|
|
|
+ {
|
|
|
+ fs.Close();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|