using LabelManager2; using Seagull.BarTender.Print; using System; using System.Collections.Generic; using System.ComponentModel; 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_PalletCollection : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; DataTable dt; LogStringBuilder sql = new LogStringBuilder(); Packing_NewPallet NewPallet; string pa_nextstep = ""; //箱类型 string pa_type; //物料编号 string pr_code; //Package表的主键 string pa_id; Engine engine; Document doc; Thread thread; string ErrorMessage = ""; public Packing_PalletCollection() { InitializeComponent(); } //创建打印进程 private void NewPrint() { try { engine = new Engine(true); } catch { OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red); } } private void Make_PalletCollection_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); thread = new Thread(NewPrint); SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序"); BaseUtil.SetFormCenter(stw); stw.ShowDialog(); OutBoxLength.Text = BaseUtil.GetCacheData("PalletLength").ToString(); PalletPreFix.Text = BaseUtil.GetCacheData("PalletPreFix").ToString(); 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(); } private void palletcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { LoadGridData(); sql.Clear(); sql.Append("select pa_makecode,pa_id,pa_status,nvl(pa_standardqty,PR_PALLETQTY)pa_standardqty,pa_prodcode,pa_packageqty,pa_totalqty,pa_salecode,pa_currentqty,pr_code pa_prodcode,pa_outboxcode,pa_totalqty,pa_custcode "); sql.Append("from package left join packagedetail on pa_id =pd_paid left join product on pr_code=pd_prodcode where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type =3"); 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,pa_makecode,pa_makecode pd_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_salecode pd_salecode,pr_packrule,pa_id,pa_prodcode pd_prodcode,pa_status,pa_mothercode,pa_nextstep "); sql.Append("from packagedetail left 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); 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); 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); } } string unfinpack = dh.getFieldDataByCondition("Line", "nvl(li_allowUnFinPack,0)", "li_code='" + User.UserLineCode + "'").ToString(); pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString(); if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "" && (unfinpack == "0" || unfinpack == "")) { OperateResult.AppendText(">>箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序\n", Color.Red, outboxcode); return; } sql.Clear(); sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno,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() != "3") { OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "类型并非栈板,不允许操作\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_barcode=ms_sncode and v_makecode = ms_makecode where v_outboxcode='" + outboxcode.Text + "' and ms_status<>2", "select"); if (dt.Rows[0][0].ToString() != "" && (unfinpack != "0" || unfinpack == "")) { 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_outboxcode.Text == "" && AutoOutBoxCode.Checked) { //箱已采集满并且未勾选自动生成 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("PALLET", pa_makecode.Text, pd_prodcode.Text, User.UserCode); } } else if (pa_outboxcode.Text != "" && pa_status.Text == "1" && AutoOutBoxCode.Checked) { pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", pa_makecode.Text, pd_prodcode.Text, User.UserCode); } else if (pa_outboxcode.Text == "") { OperateResult.AppendText(">>栈板号不能为空\n", Color.Red); return; } if (!CheckOutBoxLength()) { return; } 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_STANDARDQTY,pa_makecode,pa_indate,pa_packageqty,pa_type,pa_prodcode,pa_level,PA_STATUS,pa_sccode,pa_currentstep,pa_salecode)values"); sql.Append("(" + pa_id + ",'" + pa_outboxcode.Text + "','" + pa_standardqty.Text + "','" + pd_makecode.Text + "',sysdate,'0',3,'" + pd_prodcode.Text + "',0,0,'" + 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); 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 ErrorMessage)) { OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, outboxcode); return; } } dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_mothercode,nvl(pa_status,0) pa_status from package where pa_outboxcode='" + outboxcode.Text + "'", "select"); if (dt.Rows.Count > 0) { //判断是否已经装箱 int sonboxtotalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString()); if (dt.Rows[0]["pa_mothercode"].ToString() == "") { if (dt.Rows[0]["pa_status"].ToString() == "1") { 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_makecode,pd_prodcode,pd_innerboxcode, pd_innerqty,pd_builddate)"); sql.Append("select packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + pd_makecode.Text + "','" + pd_prodcode.Text + "','" + outboxcode.Text + "' "); sql.Append(",(select nvl(sum(pd_innerqty),0) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode="); sql.Append("'" + outboxcode.Text + "'),sysdate from package where pa_outboxcode='" + outboxcode.Text + "'"); SQLS.Add(sql.GetString()); //如果采集完这个超出了容量提示 SQLS.Add("update package set PA_CURRENTQTY=nvl(PA_CURRENTQTY,0)+1,PA_PACKAGEQTY=nvl(PA_PACKAGEQTY,0)+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=3"); 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); } 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, "", User.UserLineCode, User.UserSourceCode, "栈板采集", "栈板" + pa_outboxcode.Text + "采集箱" + outboxcode.Text + "成功", pa_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 + "已装满,封栈板成功\n"); if (!AutoOutBoxCode.Checked) { pa_outboxcode.Focus(); pa_outboxcode.SelectAll(); } else { outboxcode.Focus(); outboxcode.SelectAll(); } if (AutoPrint.Checked) { OperateResult.AppendText(">>打印栈板" + pa_outboxcode.Text + ",自动打印!\n", Color.Green); Printlab.PerformClick(); } } } else OperateResult.AppendText(">>箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode); } 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 { 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); } } } } 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_prodcode,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=3"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count == 0 && dh.CheckExist("package", "pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=3")) { 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,substr(la_url,instr(la_url,'\\',-1)+1)la_name,la_url,la_isdefault from label where la_prodcode='" + pa_prodcode.Text + "' and la_templatetype='栈板标' and la_statuscode='AUDITED' order by la_isdefault", "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=3").ToString(); } private void Make_PalletCollection_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void NewPallet_Click(object sender, EventArgs e) { NewPallet = new Packing_NewPallet("PALLET", pa_makecode.Text); NewPallet.Controls["Confirm"].Click += Make_PalletCollection_Click; BaseUtil.SetFormCenter(NewPallet); NewPallet.ShowDialog(); } private void Make_PalletCollection_Click(object sender, EventArgs e) { pa_outboxcode.Text = NewPallet.OutBoxCode; palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter)); NewPallet.Close(); } 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 (!AutoOutBoxCode.Checked) { pa_outboxcode.Focus(); pa_outboxcode.SelectAll(); } else { outboxcode.Focus(); outboxcode.SelectAll(); } //doc = lbl.Documents.Open(PrintLabel.Text); if (Print.BarTender(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); } } 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 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 + "' and pa_type=3"); 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; } } else { 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()); } LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "栈板采集", "解除栈板" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, ""); OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "解除成功\n", Color.Green); palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter)); } } else OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "未采集箱\n", Color.Red); } private void Make_PalletCollection_FormClosing(object sender, FormClosingEventArgs 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 + "成功", 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 pa_standardqty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ResetPackageQTY(); } } 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 outboxcode.Focus(); } } 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 OutBoxLength_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { if (OutBoxLength.Text != "") { int.Parse(OutBoxLength.Text); } BaseUtil.SetCacheData("PalletLength", OutBoxLength.Text); pa_outboxcode.Focus(); } catch (Exception) { OutBoxLength.Clear(); MessageBox.Show("请输入正确的长度"); } } } private void PalletPreFix_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { BaseUtil.SetCacheData("PalletPreFix", PalletPreFix.Text); pa_outboxcode.Focus(); } } } }