using DevExpress.XtraSpellChecker; using LabelManager2; using Seagull.BarTender.Print; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Threading; 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.Packing { public partial class Packing_BigBoxCollection : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; DataTable dt; LogStringBuilder sql = new LogStringBuilder(); Document doc; Packing_NewBigBox NewBigBox; string pa_id; ApplicationClass lbl; Thread thread; string ErrorMessage = ""; string pa_nextstep = ""; Engine engine; public Packing_BigBoxCollection() { InitializeComponent(); } //创建打印进程 private void NewPrint() { try { engine = new Engine(true); //BaseUtil.WriteLbl(); } catch { OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red); } } private void 栈板称重_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); AutoOutBoxCode.Checked = true; OutBoxLength.Enabled = false; OutBoxLength.Enabled = false; pa_outboxcode.Enabled = false; thread = new Thread(NewPrint); SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序"); BaseUtil.SetFormCenter(stw); stw.ShowDialog(); dh = SystemInf.dh; StepCount.StepCode = User.CurrentStepCode; StepCount.Source = User.UserSourceCode; StepCount.LineCode = User.UserLineCode; StepCount.Dh = dh; StepCount.Start(); } private void Clean_Click(object sender, EventArgs e) { OperateResult.Clear(); } //大箱号Enter事件 private void palletcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { LoadGridData(); sql.Clear(); sql.Append("select pa_id,nvl(pa_standardqty,'0')pa_standardqty,pa_makecode,pa_prodcode,pa_id,pa_packageqty,pa_outboxcode,pa_totalqty,pa_currentqty, "); sql.Append("pa_salecode,pa_custcode from package where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type =2"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { BaseUtil.SetFormValue(Controls, dt); pa_id = dt.Rows[0]["pa_id"].ToString(); } if (CheckOutBoxLength()) { if (pa_standardqty.Text == "") pa_standardqty.Focus(); else outboxcode.Focus(); } } } //箱号Enter事件 private void outboxcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage)) { if (outboxcode.Text == "") { OperateResult.AppendText(">>卡通箱号不能为空\n", Color.Red); return; } sql.Clear(); sql.Append("select nvl(pa_iostatus,0)pa_iostatus,pa_outno, pd_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_salecode pd_salecode,"); sql.Append("pr_packrule,pa_id,pa_prodcode pd_prodcode,pa_status,pa_mothercode,pa_nextstep from packagedetail left "); sql.Append("join package on pd_paid=pa_id left join product on pd_prodcode=pr_code where pd_outboxcode='" + outboxcode.Text + "'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); //判断采集的卡通箱是否有明细 if (dt.Rows.Count > 0) { BaseUtil.SetFormValue(this.Controls, dt); pa_makecode.Text = dt.Rows[0]["pd_makecode"].ToString(); if (dt.Rows[0]["pa_downstatus"].ToString() != "0") { OperateResult.AppendText(">>箱号" + outboxcode.Text + "下地状态不允许采集\n", Color.Red, outboxcode); return; } if (dt.Rows[0]["pa_outno"].ToString() != "") { OperateResult.AppendText(">>箱号" + outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red, outboxcode); return; } if (dt.Rows[0]["pa_iostatus"].ToString() != "0") { OperateResult.AppendText(">>箱号" + outboxcode.Text + "已入库不允许采集\n", Color.Red, outboxcode); return; } //之前装过箱加载明细 if (dt.Rows[0]["pa_mothercode"].ToString() != "") { if (pa_outboxcode.Text == "") { pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString(); palletcode_KeyDown(sender, e); } } pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString(); if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "") { OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序,下一工序为" + pa_nextstep + "\n", Color.Red, outboxcode); return; } sql.Clear(); sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno,pa_mothercode,pa_type from package where pa_outboxcode='" + pa_outboxcode.Text + "'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { if (dt.Rows[0]["pa_type"].ToString() != "2") { OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "类型并非大箱,不允许操作\n", Color.Red); return; } if (dt.Rows[0]["pa_mothercode"].ToString() != "") { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被栈板" + dt.Rows[0]["pa_mothercode"].ToString() + "采集,不允许操作\n", Color.Red); return; } if (dt.Rows[0]["pa_outno"].ToString() != "") { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red); return; } if (dt.Rows[0]["pa_iostatus"].ToString() != "0") { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red); return; } } //为空表示线外 if (pa_nextstep == "") { //判断线外,必须已完工并且未入库 dt = (DataTable)dh.ExecuteSql("select wm_concat(ms_sncode) from mes_package_view left join makeserial on v_makecode=ms_makecode and ms_sncode=v_barcode where v_outboxcode='" + outboxcode.Text + "' and ms_status<>2", "select"); if (dt.Rows[0][0].ToString() != "") { ////判断箱未入库 //dt = (DataTable)dh.ExecuteSql("select count(1) from package where pa_outboxcode='" + outboxcode.Text + "' and nvl(pa_iostatus,0)<>0", "select"); //if (dt.Rows[0][0].ToString() != "0") //{ // OperateResult.AppendText(">>卡通箱" + outboxcode.Text + "已入库,不允许装箱\n", Color.Red); // return; //} OperateResult.AppendText(">>序列号" + dt.Rows[0][0].ToString() + "尚未完工\n", Color.Red); return; } } } else { OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "未采集内容或不存在,不允许装大箱\n", Color.Red, outboxcode); return; } if (!Cancel.Checked) { pa_status.Text = dh.getFieldDataByCondition("package", "nvl(pa_status,0)pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString(); if (pa_standardqty.Text == pa_totalqty.Text && pa_status.Text == "0") { dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); pa_status.Text = "1"; } //如果箱号为空的时候并且勾选了自动生成 if (pa_outboxcode.Text == "" && AutoOutBoxCode.Checked || pa_status.Text == "1") { //箱已采集满并且未勾选自动生成 if (pa_standardqty.Text == pa_totalqty.Text && !AutoOutBoxCode.Checked) { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已采集满\n", Color.Red, outboxcode); return; } else { pa_outboxcode.Text = LogicHandler.GetOutBoxCode("BIGBOX", pa_makecode.Text, pa_prodcode.Text, User.UserCode); } } else if (pa_outboxcode.Text == "") { OperateResult.AppendText(">>大箱号不能为空\n", Color.Red); return; } if (!CheckOutBoxLength()) { return; } //箱号不存在进行插入 DataTable dt = (DataTable)dh.ExecuteSql("select pa_id from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select"); if (dt.Rows.Count == 0) { pa_id = dh.GetSEQ("package_seq"); sql.Clear(); sql.Append("insert into package (pa_id,pa_outboxcode,pa_makecode,pa_indate,pa_packageqty,pa_type,pa_prodcode,pa_level,PA_STATUS,pa_standardqty,pa_sccode,pa_currentstep,pa_salecode)values"); sql.Append("(" + pa_id + ",'" + pa_outboxcode.Text + "','" + pd_makecode.Text + "',sysdate,'0',2,'" + pd_prodcode.Text + "',0,'','" + pa_standardqty.Text + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + pd_salecode.Text + "')"); dh.ExecuteSql(sql.GetString(), "insert"); } else { pa_id = dt.Rows[0]["pa_id"].ToString(); } palletcode_KeyDown(sender, e); string error; if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) > 0) { if (!LogicHandler.CheckPackRule(pr_packrule.Text, pa_outboxcode.Text, outboxcode.Text, pa_makecode.Text, pa_salecode.Text, pa_prodcode.Text, "大箱", out error)) { OperateResult.AppendText(">>" + error + "\n", Color.Red, outboxcode); return; } } dt = (DataTable)dh.ExecuteSql("select pa_totalqty,nvl(pa_status,0) pa_status,pa_mothercode from package where pa_outboxcode='" + outboxcode.Text + "' and pa_type=1", "select"); //采集的卡通箱号存在 if (dt.Rows.Count > 0) { int sonboxtotalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString()); if (dt.Rows[0]["pa_status"].ToString() == "1") { //判断是否已经装箱 if (dt.Rows[0]["pa_mothercode"].ToString() == "") { pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString(); if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) + sonboxtotalqty > int.Parse(pa_standardqty.Text == "" ? "0" : pa_standardqty.Text)) { OperateResult.AppendText(">>采集箱号" + outboxcode.Text + "后超出容量\n", Color.Red, outboxcode); return; } if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) == 0) { dh.ExecuteSql("update package set pa_prodcode='" + pd_prodcode.Text + "',pa_salecode='" + pd_salecode.Text + "',pa_makecode='" + pd_makecode.Text + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); } //插入大箱明细 List SQLS = new List(); sql.Clear(); sql.Append("insert into packagedetail(pd_id, pd_paid, pd_outboxcode,pd_innerboxcode, pd_innerqty,pd_makecode,pd_prodcode,pd_builddate)"); sql.Append("select packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + outboxcode.Text + "'"); sql.Append(",pa_packageqty,pa_makecode,'" + pd_prodcode.Text + "',sysdate from package where pa_outboxcode='" + outboxcode.Text + "'"); SQLS.Add(sql.GetString()); //箱内计数+1 SQLS.Add("update package set PA_CURRENTQTY=PA_CURRENTQTY+1,PA_PACKAGEQTY=PA_PACKAGEQTY+1,PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "') where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type=2"); //更新采集的子箱记录母箱号 SQLS.Add("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + outboxcode.Text + "'"); dh.ExecuteSQLTran(SQLS.ToArray()); if (dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "") { string carton_macode = dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + outboxcode.Text + "'").ToString(); pa_makecode.Text = carton_macode; dh.ExecuteSql("update package set pa_makecode='" + carton_macode + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); } //如果是线内并且下一工序等于当前岗位资源工序 if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode) { LogicHandler.OutBoxStepPass(outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集", out ErrorMessage); } //更新箱号的NextStepCode if (pa_totalqty.Text == "1") { string nextstepcode = dh.getFieldDataByCondition("mes_package_view left join makeserial on ms_sncode=v_barcode", "ms_nextstepcode", "v_outboxcode='" + outboxcode.Text + "'").ToString(); dh.UpdateByCondition("package", "pa_nextstep='" + nextstepcode + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'"); } //记录卡通箱所有序列号操作日志 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "大箱" + pa_outboxcode.Text + "采集卡通箱" + outboxcode.Text + "采集成功", outboxcode.Text, ""); OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "采集成功!\n", Color.Green, outboxcode); LoadCollectNum(); palletcode_KeyDown(sender, e); if (pa_standardqty.Text == pa_totalqty.Text) { dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); OperateResult.AppendText("大箱" + pa_outboxcode.Text + "已装满,封箱成功"); if (!AutoOutBoxCode.Checked) { pa_outboxcode.Focus(); pa_outboxcode.SelectAll(); } else { outboxcode.Focus(); outboxcode.SelectAll(); } if (AutoPrint.Checked) { OperateResult.AppendText(">>箱已装满,自动打印!\n", Color.Green); Printlab.PerformClick(); } } } else { if (dt.Rows[0]["pa_mothercode"].ToString() == pa_outboxcode.Text) OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已在本大箱内\n", Color.Red, outboxcode); else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已采集至大箱" + dt.Rows[0]["pa_mothercode"].ToString() + "\n", Color.Red, outboxcode); } } else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode); } else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "不存在\n", Color.Red, outboxcode); } else { sql.Clear(); sql.Append("select nvl(pa_iostatus,0)pa_iostatus from packagedetail left join package on pa_id =pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "' "); sql.Append("and pd_innerboxcode='" + outboxcode.Text + "'"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { if (dt.Rows[0]["pa_iostatus"].ToString() == "0") { List SQLS = new List(); //删除明细 SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "' and pd_innerboxcode='" + outboxcode.Text + "'"); //减少箱内容量 SQLS.Add("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-(select pa_totalqty from package where pa_outboxcode='" + outboxcode.Text + "'),pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'"); SQLS.Add("update package set pa_mothercode='' where pa_outboxcode='" + outboxcode.Text + "'"); dh.ExecuteSQLTran(SQLS.ToArray()); OperateResult.AppendText(">>箱号" + outboxcode.Text + "取消采集成功\n", Color.Green); LoadCollectNum(); palletcode_KeyDown(sender, e); outboxcode.Clear(); } else OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已入库,不允许取消采集\n", Color.Red); } else OperateResult.AppendText(">>箱号" + outboxcode.Text + "不在大箱" + pa_outboxcode.Text + "\n", Color.Red); } } else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, outboxcode); } } private void LoadGridData() { sql.Clear(); sql.Append("select pd_prodcode,nvl(pd_barcode,PD_INNERBOXCODE) code ,pd_innerqty,pa_salecode"); sql.Append(",pd_makecode,pa_custcode,pa_packageqty from packagedetail left join package on pd_paid=pa_id left "); sql.Append("join product on pr_code=pa_prodcode where pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=2"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count == 0 && dh.CheckExist("package", "pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=2")) { dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_makecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); } BaseUtil.FillDgvWithDataTable(PackageInf, dt); } private void FillPrintLabel() { DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='" + pa_prodcode.Text + "' and la_templatetype='大箱标' and la_statuscode='AUDITED' order by la_isdefault", "select"); if (_dt.Rows.Count == 0) { _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode is null and la_templatetype='大箱标' and la_statuscode='AUDITED' order by la_isdefault", "select"); } if (_dt.Rows.Count > 0) { string la_id = _dt.Rows[0]["la_id"].ToString(); _dt = (DataTable)dh.ExecuteSql("select fp_name la_url,'" + la_id + "' la_id from FILEPATH where fp_id in (select * from table(select parsestring(LA_SOFTTYPE,';') from label where la_id='" + la_id + "') where COLUMN_VALUE is not null)", "select"); PrintLabel.DataSource = _dt; PrintLabel.DisplayMember = "la_url"; PrintLabel.ValueMember = "la_id"; } } private void LoadCollectNum() { pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type=2").ToString(); } private void 栈板称重_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void NewPallet_Click(object sender, EventArgs e) { NewBigBox = new Packing_NewBigBox("BIGBOX", pa_makecode.Text); NewBigBox.Controls["Confirm"].Click += Make_BigBoxCollection_Click; BaseUtil.SetFormCenter(NewBigBox); NewBigBox.ShowDialog(); } private void Make_BigBoxCollection_Click(object sender, EventArgs e) { pa_outboxcode.Text = NewBigBox.OutBoxCode; palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter)); } private void Print_Click(object sender, EventArgs e) { if (PrintLabel.Items.Count != 0) { if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1") { if (Print.BarTenderS(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage)) { OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Black); } else { OperateResult.AppendText(ErrorMessage + "\n", Color.Red); } if (!AutoOutBoxCode.Checked) { pa_outboxcode.Focus(); pa_outboxcode.SelectAll(); } else { outboxcode.Focus(); outboxcode.SelectAll(); } } else OperateResult.AppendText(">>必须封箱才能进行打印\n", Color.Red); } else OperateResult.AppendText(">>产品" + pa_prodcode.Text + "未维护打印标签或者标签未审核\n", Color.Red); } private void ReleasePallet_Click(object sender, EventArgs e) { if (dh.getRowCount("packagedetail", "pd_outboxcode='" + pa_outboxcode.Text + "'") > 0) { string pa_mothercode = dh.getFieldDataByCondition("package", "pa_mothercode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString(); if (pa_mothercode == "") { string Delete = MessageBox.Show(this.ParentForm, "是否确认拆箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString(); if (Delete == "Yes") { sql.Clear(); sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno from package where pa_outboxcode='" + pa_outboxcode.Text + "'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { if (dt.Rows[0]["pa_outno"].ToString() != "") { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red); return; } if (dt.Rows[0]["pa_iostatus"].ToString() != "0") { OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red); return; } } if (dh.getFieldDataByCondition("package", "pa_nextstep", "pa_mothercode='" + pa_outboxcode.Text + "'").ToString() != "") LogicHandler.OutBoxDrawStepPass(pa_outboxcode.Text, pa_makecode.Text, User.UserSourceCode); else { List SQLS = new List(); SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'"); SQLS.Add("update package set pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'"); SQLS.Add("update package set pa_mothercode='' where pa_mothercode='" + pa_outboxcode.Text + "'"); dh.ExecuteSQLTran(SQLS.ToArray()); } //将子箱的母箱编号置成空 OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "解除成功\n", Color.Green); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "解除大箱" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, ""); palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter)); } } else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已装箱" + pa_mothercode + ",不能取消解除装箱\n", Color.Red); } else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "未采集箱\n", Color.Red); } private void Make_BigBoxCollection_FormClosed(object sender, FormClosedEventArgs e) { BaseUtil.ClosePrint(lbl); } private void Packing_Click(object sender, EventArgs e) { if (pa_outboxcode.Text != "") { sql.Clear(); sql.Append("select nvl(pa_status,0) pa_status from packagedetail left join package "); sql.Append("on pa_id=pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "'"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { if (dt.Rows[0]["pa_status"].ToString() == "0") { string Seal = MessageBox.Show(this.ParentForm, "是否确认封箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString(); if (Seal == "Yes") { OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "封大箱成功\n", Color.Green); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "大箱封箱" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, ""); dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update"); pa_status.Text = "1"; if (!AutoOutBoxCode.Checked) { pa_outboxcode.Focus(); pa_outboxcode.SelectAll(); } else { outboxcode.Focus(); outboxcode.SelectAll(); } } } else OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "已封大箱\n", Color.Red); } else OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "未采集内容\n", Color.Red); } else OperateResult.AppendText(">>大箱号不能为空\n", Color.Red); } private void PrintLabel_SelectedValueChanged(object sender, EventArgs e) { if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView") { string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString(); PrintNum.Text = (PrintNums == "" ? "1" : PrintNums); } } private void pa_prodcode_TextChanged(object sender, EventArgs e) { FillPrintLabel(); } private void ResetPackageQTY() { if (pa_outboxcode.Text != "") { DataTable dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_status from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select"); if (dt.Rows.Count > 0) { string total = dt.Rows[0]["pa_totalqty"].ToString(); if (int.Parse(pa_standardqty.Text) >= int.Parse(total)) { dh.UpdateByCondition("package", "pa_standardqty='" + pa_standardqty.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'"); OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "修改容量成功,已修改为" + pa_standardqty.Text + "\n", Color.Green); outboxcode.Focus(); return; } else OperateResult.AppendText(">>容量不能小于已装数量\n", Color.Red); } else OperateResult.AppendText(">>大箱板号不存在\n", Color.Red); pa_standardqty.Text = ""; } } private void pa_standardqty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ResetPackageQTY(); } } private bool CheckOutBoxLength() { //勾选了检验长度进行校验 if (OutBoxLength.Text != "") { try { int.Parse(OutBoxLength.Text); } catch (Exception) { MessageBox.Show("请填写正确的箱号长度"); return false; } if (pa_outboxcode.Text.Length != int.Parse(OutBoxLength.Text)) { OperateResult.AppendText(">>箱号长度错误,请重新输入箱号\n", Color.Red); return false; } else return true; } if (PalletPreFix.Text != "") { try { if (pa_outboxcode.Text.Substring(0, PalletPreFix.Text.Length) != PalletPreFix.Text) { OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red); return false; } } catch (Exception) { OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red); return false; } } return true; } private void AutoOutBoxCode_CheckedChanged(object sender, EventArgs e) { if (AutoOutBoxCode.Checked) { OutBoxLength.Enabled = false; OutBoxLength.Enabled = false; pa_outboxcode.Enabled = false; } else { OutBoxLength.Enabled = true; OutBoxLength.Enabled = true; pa_outboxcode.Enabled = true; } } private void AutoOutBoxCode_CheckStateChanged(object sender, EventArgs e) { } } }