12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112 |
- using LabelManager2;
- using System;
- using System.Data;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- using System.Drawing;
- using System.Threading;
- using UAS_MES_NEW.PublicForm;
- using System.Collections.Generic;
- using System.Diagnostics;
- //using Seagull.BarTender.Print;
- namespace UAS_MES_NEW.Packing
- {
- public partial class Packing_PackageCollection : Form
- {
- DataHelper dh;
- DataTable dt;
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- ApplicationClass lbl;
- BarTender.Application engine;
- Thread thread;
- DataTable Dbfind;
- string ErrorMessage = "";
- string oMakeCode = "";
- string oMsID = "";
- string oMsStatus = "";
- string oOutBoxCode = "";
- decimal StandardQTY = 0;
- string LastSncode;
- Document doc;
- string PR_CHECKCARTONW = "0";
- ModeBusTCPServer md;
- public Packing_PackageCollection()
- {
- InitializeComponent();
- }
- //创建打印进程
- private void NewPrint()
- {
- try
- {
- engine = new BarTender.Application();
- //lbl = new ApplicationClass();
- //BaseUtil.WriteLbl();
- }
- catch (Exception ex)
- {
- OperateResult.AppendText("未正确安装打印软件\n" + ex.Message, Color.Red);
- }
- }
- private void PackCollection_Load(object sender, EventArgs e)
- {
- // 杀死之前全部未关闭的进程
- Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
- Process[] processes1 = System.Diagnostics.Process.GetProcessesByName("bartend");
- for (int i = 0; i < processes1.Length; i++)
- {
- processes1[i].Kill();
- }
- for (int i = 0; i < processes.Length; i++)
- {
- processes[i].Kill();
- }
- IP.Text = BaseUtil.GetCacheData("IP").ToString();
- Port.Text = BaseUtil.GetCacheData("IPPort").ToString();
- //设置DbFind的必须的数据
- PrintNum.Text = "1";
- asc.controllInitializeSize(this);
- thread = new Thread(NewPrint);
- SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
- BaseUtil.SetFormCenter(stw);
- md = new ModeBusTCPServer();
- stw.ShowDialog();
- try
- {
- OutBoxLength.Text = BaseUtil.GetCacheData("OutBoxLength").ToString();
- PreFix.Text = BaseUtil.GetCacheData("PreFix").ToString();
- Remark_PreFix.Text = BaseUtil.GetCacheData("Remark_PreFix").ToString();
- }
- catch (Exception) { }
- sn_code.Focus();
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- private void PackCollection_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void PackCollection_Activated(object sender, EventArgs e)
- {
- pa_outboxcode.Focus();
- }
- //刷新表单的数据的数据
- private void LoadData()
- {
- //加载表单数据
- sql.Clear();
- sql.Append("select pr_code,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype,pa_remark,pa_outboxcode,pa_prodcode,pa_salecode,pa_makecode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,pa_status,pr_packrule,nvl(PR_CHECKCARTONW,'0') PR_CHECKCARTONW,pr_detail||'-'||pr_orispeccode pr_detail,pa_packageqty,nvl(pa_standardqty,0) pa_standardqty,nvl(pr_outboxinnerqty,0)pr_outboxinnerqty,pa_currentqty,pa_endremark from package left join product on pa_prodcode=");
- sql.Append("pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- //记录该数据保证在修改不被允许的前提下能偶回复之前的值
- StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
- if (dt.Rows[0]["pa_salecode"].ToString() != "")
- {
- ms_salecode.Text = dt.Rows[0]["pa_salecode"].ToString();
- }
- BaseUtil.SetFormValue(this.Controls, dt);
- if (pa_standardqty.Text != "0")
- {
- pr_outboxinnerqty.Text = pa_standardqty.Text;
- }
- }
- else
- {
- pa_makecode.Text = "";
- }
- LoadCollectedNum();
- LoadCheckQTY();
- }
- private void LoadGridData()
- {
- //加载Grid数据
- dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pa_prodcode,pd_barcode,pd_innerqty,pd_makecode,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
- BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
- if (dt.Rows.Count > 0)
- {
- string choose_pd_barcode = dt.Rows[0]["pd_barcode"].ToString();
- string choose_pd_makecode = dt.Rows[0]["pd_makecode"].ToString();
- PR_CHECKCARTONW = dh.getFieldDataByCondition("craftdetail left join craft on cr_id=cd_crid left join makeserial on ms_craftcode =cr_code and cr_prodcode = ms_prodcode", "nvl(cd_ifweigh,'0') cd_ifweigh", "ms_sncode='" + choose_pd_barcode + "' and ms_makecode='" + choose_pd_makecode + "' and cd_stepcode = '" + User.CurrentStepCode + "'").ToString();
- }
- //更新界面的采集数量
- pa_currentqty.Text = dh.getFieldDataByCondition("package", "pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
- }
- 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")
- {
- dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
- //for (int i = 0; i < _dt.Rows.Count; i++)
- //{
- if (Print.SinglePrint(Tag.ToString(), engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), oMakeCode == "" ? pa_makecode.Text : oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
- {
- OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Aqua);
- }
- else
- {
- OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
- }
- //}
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- sn_code.SelectAll();
- }
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "尚未封箱,请封箱后执行打印\n", Color.Red);
- }
- else OperateResult.AppendText(">>产品" + pr_code.Text + "未维护打印标签\n", Color.Red);
- }
- //加载工单信息和装箱明细信息
- private void pa_code_KeyDown(object sender, KeyEventArgs e)
- {
- //try
- //{
- if (e.KeyCode == Keys.Enter)
- {
- LoadData();
- LoadGridData();
- // if (CheckOutBoxLength())
- // {
- sn_code.Focus();
- // }
- }
- //}
- //catch (Exception ex)
- //{
- // MessageBox.Show(ex.Message);
- //}
- }
- //输入序列号的回车事件
- private void barcode_KeyDown(object sender, KeyEventArgs e)
- {
- //当用户输入回车键的时候
- if (e.KeyCode == Keys.Enter)
- {
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
- {
- dt = (DataTable)dh.ExecuteSql("select ms_status,ms_id,ms_makecode,ms_nextstepcode,ms_craftcode,ms_prodcode from makeserial where ms_sncode ='" + sn_code.Text + "' order by ms_id desc", "select");
- if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sn_code.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage) || (dt.Rows.Count > 0 && dt.Rows[0]["ms_status"].ToString() == "2"))
- {
- if (oMsID == "" || oMsID == "null" || oMsID == "0")
- {
- oMsID = dt.Rows[0]["ms_id"].ToString();
- oMsStatus = dt.Rows[0]["ms_status"].ToString();
- oMakeCode = dt.Rows[0]["ms_makecode"].ToString();
- }
- //如果是已完工序列号验证装箱工序是否存在于途程中
- if (oMsStatus == "2")
- {
- string prodcode = dt.Rows[0]["ms_prodcode"].ToString();
- string craftcode = dt.Rows[0]["ms_craftcode"].ToString();
- string craftstepcode = dh.getFieldDataByCondition("craft left join craftdetail on cr_id =cd_crid", "(cd_stepcode)", "cr_prodcode='" + prodcode + "' and cr_code='" + craftcode + "' and cd_stepcode='" + User.CurrentStepCode + "'").ToString();
- if (craftstepcode == "")
- {
- OperateResult.AppendText("工序" + User.CurrentStepCode + "不在途程" + craftcode + "内,不允许采集\n", Color.Red);
- return;
- }
- }
- string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
- if (nextstepcode != "" && nextstepcode != User.CurrentStepCode)
- {
- OperateResult.AppendText("当前序列号下一道工序" + nextstepcode + ",当前资源不允许采集\n", Color.Red);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- return;
- }
- PR_CHECKCARTONW = dh.getFieldDataByCondition("craftdetail left join craft on cr_id=cd_crid left join makeserial on ms_craftcode =cr_code and cr_prodcode = ms_prodcode", "nvl(cd_ifweigh,'0') cd_ifweigh", "ms_sncode='" + sn_code.Text + "' and ms_makecode='" + oMakeCode + "' and cd_stepcode = '" + User.CurrentStepCode + "'").ToString();
- //获取序列号信息
- sql.Clear();
- sql.Append("select nvl(ms_iostatus,0) ms_iostatus,pa_salecode,ms_salecode,ms_outno,ms_makecode,ms_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,");
- sql.Append("nvl(pr_outboxinnerqty,0)pr_outboxinnerqty,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype,pr_code,ms_endremark from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
- sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- string ms_makecode = "";
- string ms_prodcode = "";
- string ms_iostatus = "";
- string ms_outno = "";
- string ms_salecode_text = "";
- if (dt.Rows.Count > 0)
- {
- StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
- ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
- ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
- ms_iostatus = dt.Rows[0]["ms_iostatus"].ToString();
- ms_outno = dt.Rows[0]["ms_outno"].ToString();
- ms_salecode_text = dt.Rows[0]["ms_salecode"].ToString();
- //if (locksalecode.Checked && ms_salecode.Text != "" && ms_salecode.Text != ms_salecode_text)
- //{
- // OperateResult.AppendText(">>序列号" + sn_code.Text + "所属订单号" + ms_salecode_text + "与界面订单号" + ms_salecode.Text + "不同,无法采集\n", Color.Red, sn_code);
- // if (md.IsOpen)
- // {
- // md.SendOrder("M502_ON");
- // }
- // return;
- //}
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- if (dt.Rows[0]["ms_outno"].ToString() != "")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "已被出货单" + dt.Rows[0]["ms_outno"].ToString() + "采集,不允许操作\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- return;
- }
- if (dt.Rows[0]["ms_iostatus"].ToString() != "0")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "已入库不允许采集\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- return;
- }
- //保证箱内容量不会被重置
- if (pa_standardqty.Text != "0" && pa_standardqty.Text != "")
- {
- pr_outboxinnerqty.Text = pa_standardqty.Text;
- }
- if (pa_outboxcode.Text == "")
- {
- string boxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
- //序列号存在箱号的情况下获取所有的装箱数据
- if (boxcode != "")
- {
- pa_outboxcode.Text = boxcode;
- pa_makecode.Text = "";
- LoadGridData();
- }
- else
- {
- //如果勾选了自动生成箱号,在封箱或者首次
- if (AutoGenBoxCode.Checked && (pa_status.Text == "1" || pa_status.Text == "" || pa_status.Text == "0"))
- {
- string autoout = LogicHandler.GetOutBoxCode("PACKAGE", ms_makecode, pr_code.Text, User.UserCode);
- if (autoout == " ")
- {
- OperateResult.AppendText(">>未维护箱号规则,无法生成箱号\n", Color.Red, sn_code);
- return;
- }
- pa_outboxcode.Text = autoout;
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "自动生成", sn_code.Text, PreFix.Text + ":" + OutBoxLength.Text);
- }
- }
- }
- if (pa_outboxcode.Text == "")
- {
- OperateResult.AppendText(">>箱号不能为空\n", Color.Red, sn_code);
- return;
- }
- //判断箱内总数必须大于0
- if (pr_outboxinnerqty.Text == "" || pr_outboxinnerqty.Text == "0")
- {
- OperateResult.AppendText(">>箱内容量必须大于0\n", Color.Red);
- 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");
- string MotherBoxCode = "";
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["pa_mothercode"].ToString() != "")
- {
- MotherBoxCode = dt.Rows[0]["pa_mothercode"].ToString();
- }
- if (dt.Rows[0]["pa_outno"].ToString() != "")
- {
- OperateResult.AppendText(">>卡通箱" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- return;
- }
- if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
- {
- OperateResult.AppendText(">>卡通箱" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- return;
- }
- }
- //如果未勾选了取消录入
- if (!Cancel.Checked)
- {
- //判断序列号是否已经装箱
- string ms_outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
- if (ms_outboxcode != "")
- {
- if (ms_outboxcode == pa_outboxcode.Text)
- {
- if (md.IsOpen)
- {
- md.SendOrder("M501_ON");
- }
- OperateResult.AppendText(">>序列号" + sn_code.Text + "已在本箱内\n", Color.Red, sn_code);
- }
- else
- {
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- OperateResult.AppendText(">>序列号" + sn_code.Text + "已采集至箱" + ms_outboxcode + "\n", Color.Red, sn_code);
- }
- LoadData();
- }
- else
- {
- //满箱之后采集下一个之前自动清除内容,生成新的箱号
- if ((AutoGenBoxCode.Checked && pa_currentqty.Text != "" && pr_outboxinnerqty.Text == pa_currentqty.Text) || (AutoGenBoxCode.Checked && pa_status.Text == "1"))
- {
- pa_currentqty.Text = "";
- pa_outboxcode.Text = "";
- pa_status.Text = "0";
- BaseUtil.CleanDGVData(PackageDetail);
- string autoout = LogicHandler.GetOutBoxCode("PACKAGE", ms_makecode, pr_code.Text, User.UserCode);
- if (autoout == " ")
- {
- OperateResult.AppendText(">>未维护箱号规则,无法生成箱号\n", Color.Red, sn_code);
- return;
- }
- pa_outboxcode.Text = autoout;
- //pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PACKAGE", ms_makecode, pr_code.Text, User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "自动生成", sn_code.Text, PreFix.Text + ":" + OutBoxLength.Text);
- }
- //if (!CheckOutBoxLength(ms_salecode_text))
- //{
- // return;
- //}
- ////箱号不存在的情况
- if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "标准", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
- {
- if (md.IsOpen)
- {
- md.SendOrder("M501_ON");
- }
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n");
- LastSncode = sn_code.Text;
- OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成功!\n", Color.Green);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "采集成功", sn_code.Text, "");
- //满箱更新状态为1
- LoadData();
- LoadGridData();
- LoadCheckQTY();
- dh.ExecuteSql("update packagedetail set pd_innerqty=(select pa_packageqty from package where pa_outboxcode='" + pa_outboxcode.Text + "') where pd_innerboxcode='" + pa_outboxcode.Text + "'", "update");
- if (MotherBoxCode != "")
- {
- dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
- //如果母箱号不为空,需要更新总数
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["pa_type"].ToString() == "2")
- {
- string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
- //更新大箱数量
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
- //外层有栈板则更新栈板数量
- if (MotherCode2 != "")
- {
- dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
- }
- }
- if (dt.Rows[0]["pa_type"].ToString() == "3")
- {
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
- }
- }
- }
- //采集完后如果是第一个装的序列号,把序列号的NextStepCode赋值给箱号
- if (pa_currentqty.Text == "1")
- {
- dh.UpdateByCondition("package", "pa_nextstep='" + User.CurrentStepCode + "', PA_CURRENTSTEP = '" + User.CurrentStepCode + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- }
- if (int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text) == int.Parse(pr_outboxinnerqty.Text))
- {
- dh.UpdateByCondition("package", "pa_status=1,pa_packageqty=pa_currentqty,pa_totalqty=pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "满箱采集完成,封箱成功\n", Color.ForestGreen);
- pa_status.Text = "1";
- pa_standardqty.Text = "";
- if (!CollecRemark.Checked)
- {
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- sn_code.SelectAll();
- }
- }
- else
- {
- pa_remark.SelectAll();
- pa_remark.Focus();
- }
- if (PR_CHECKCARTONW != "0")
- {
- OperateResult.AppendText(">>卡通箱" + pa_outboxcode.Text + "满箱处于称重工序,请在卡通箱称重界面进行称重打印\n", Color.Black, sn_code);
- return;
- }
- if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, 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 + "'");
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- if (AutoPrint.Checked)
- Print_Click(new object(), new EventArgs());
- LoadCollectedNum();
- LoadCheckQTY();
- }
- sn_code.Clear();
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
- }
- }
- //勾选了取消箱号先验证箱号存不存在,存在的话移除掉,重新加载一次数据
- else
- {
- if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "标准", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
- {
- dh.UpdateByCondition("makeserial", "ms_outboxcode=''", "ms_id='" + oMsID + "'");
- dh.ExecuteSql("update packagedetail set pd_innerqty=(select pa_packageqty from package where pa_outboxcode='" + pa_outboxcode.Text + "') where pd_innerboxcode='" + pa_outboxcode.Text + "'", "update");
- //如果母箱号不为空,需要更新总数
- if (MotherBoxCode != "")
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["pa_type"].ToString() == "2")
- {
- string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
- //更新大箱数量
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
- //外层有栈板则更新栈板数量
- if (MotherCode2 != "")
- {
- dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
- }
- }
- if (dt.Rows[0]["pa_type"].ToString() == "3")
- {
- dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
- }
- }
- }
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "取消采集成功", sn_code.Text, "");
- LoadGridData();
- pa_status.Text = "0";
- OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green, sn_code);
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- }
- }
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
- if (md.IsOpen)
- {
- md.SendOrder("M502_ON");
- }
- }
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
- }
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- DataTable _dt;
- private void pr_code_TextChanged(object sender, EventArgs e)
- {
- LoadCheckQTY();
- _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + pr_code.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 PackCollection_FormClosing(object sender, FormClosingEventArgs e)
- {
- BaseUtil.ClosePrint(lbl);
- if (engine != null)
- engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
- dh.Dispose();
- }
- private void Packing_Click(object sender, EventArgs e)
- {
- if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "' and nvl(pa_status,0)=0"))
- {
- string Seal = MessageBox.Show(this.ParentForm, "是否确认封箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (Seal == "Yes")
- {
- OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "采集完成,手动封箱成功\n", Color.ForestGreen);
- dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- pa_status.Text = "1";
- pa_standardqty.Text = "";
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "装箱采集", "卡通箱" + pa_outboxcode.Text + "封箱成功", pa_outboxcode.Text, "");
- if (!CollecRemark.Checked)
- {
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- sn_code.SelectAll();
- }
- }
- else
- {
- pa_remark.SelectAll();
- pa_remark.Focus();
- }
- if (PR_CHECKCARTONW != "0")
- {
- OperateResult.AppendText(">>卡通箱" + pa_outboxcode.Text + "处于称重工序,请在卡通箱称重界面进行操作\n", Color.Black, sn_code);
- return;
- }
- string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
- if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, 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 + "'");
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- if (AutoPrint.Checked)
- Print_Click(new object(), new EventArgs());
- LoadCheckQTY();
- }
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "错误或者已封箱\n", Color.Red);
- }
- private void SendCheck_Click(object sender, EventArgs e)
- {
- if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select wm_concat(pa_outboxcode) pa_outboxcode from package where pa_checkno='" + ob_checkno.Text + "' and pa_status=0 ", "select");
- if (dt.Rows[0][0].ToString() != "")
- {
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "存在箱号" + dt.Rows[0][0].ToString() + "未封箱,请先进行封箱\n", Color.Red);
- return;
- }
- sql.Clear();
- sql.Append("update oqcbatch set ob_status='UNCHECK',ob_breakingdate=sysdate where ob_checkno ='" + ob_checkno.Text + "'");
- dh.ExecuteSql(sql.GetString(), "select");
- ob_nowcheckqty.Text = "";
- ob_batchqty.Text = "";
- ob_nowcheckqty.ForeColor = Color.Black;
- SendCheck.Enabled = false;
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
- LogicHandler.InsertMakeProcess(LastSncode, oMakeCode, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
- //记录操作日志
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
- ob_checkno.Text = "";
- }
- else OperateResult.AppendText(">>必须封箱才能送检\n", Color.Red);
- }
- bool AutoCut;
- private void LoadCheckQTY()
- {
- sql.Clear();
- string condition = "";
- int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
- int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
- if (nowcheckqty + 1 == batchqty && AutoCut)
- {
- condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
- }
- else
- {
- condition = "and ob_status='ENTERING' ";
- }
- if (pr_sendchecktype.Text == "SaleCode")
- {
- condition += " and ob_salecode='" + ms_salecode.Text + "'";
- }
- sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
- sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + pr_code.Text + "' and ");
- sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
- ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
- ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
- nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
- batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
- if (nowcheckqty >= batchqty)
- {
- ob_nowcheckqty.ForeColor = Color.Red;
- OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
- if (AutoCut)
- {
- OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
- }
- }
- }
- else
- {
- ob_batchqty.Text = "";
- ob_nowcheckqty.Text = "";
- ob_checkno.Text = "";
- SendCheck.Enabled = false;
- }
- if (ob_batchqty.Text != "" && PR_CHECKCARTONW == "0")
- {
- SendCheck.Enabled = true;
- }
- else
- {
- SendCheck.Enabled = false;
- }
- }
- private void ob_checkno_TextChanged(object sender, EventArgs e)
- {
- if (ob_checkno.Text != "")
- {
- string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
- if (Cut == "" || Cut == "0")
- AutoCut = false;
- else
- AutoCut = true;
- SendCheck.Enabled = true;
- }
- }
- //private void pr_outboxinnerqty_KeyDown(object sender, KeyEventArgs e)
- //{
- // if (e.KeyCode == Keys.Enter)
- // ResetPackQTY();
- //}
- //private void pr_outboxinnerqty_Leave(object sender, EventArgs e)
- //{
- // ResetPackQTY();
- //}
- //private void ResetPackQTY()
- //{
- // //数据不符合限制的时候保持原有值
- // int curretnqty = int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text);
- // if (!(int.Parse(pr_outboxinnerqty.Text) >= curretnqty))
- // {
- // pr_outboxinnerqty.Text = StandardQTY.ToString();
- // }
- // else
- // {
- // if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
- // {
- // string checknostatus = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno='" + pa_checkno.Text + "'").ToString();
- // if (checknostatus == "" || checknostatus == "ENTERING")
- // {
- // if (pa_downstatus.Text == "0")
- // {
- // if (dh.CheckExist("source", "sc_code='" + pa_sccode.Text + "' and sc_stepcode='" + User.CurrentStepCode + "'"))
- // {
- // dh.UpdateByCondition("package", "pa_standardqty='" + pr_outboxinnerqty.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "修改箱内容量", "原容量" + StandardQTY + ",修改为" + pr_outboxinnerqty.Text + "'", pa_outboxcode.Text, pa_checkno.Text);
- // return;
- // }
- // else
- // OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "当前所在工序不是登录岗位资源所在工序,不允许修改数量\n", Color.Red);
- // }
- // else
- // OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "处于下地状态,不允许修改标准容量\n", Color.Red);
- // }
- // else
- // OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "处于送检中,不允许修改标准容量\n", Color.Red);
- // }
- // else
- // OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "不存在,修改容量无效\n", Color.Red);
- // pr_outboxinnerqty.Text = StandardQTY.ToString();
- // }
- //}
- 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 DeleteAll_Click(object sender, EventArgs e)
- {
- if (pa_outboxcode.Text == "")
- {
- OperateResult.AppendText(">>箱号不能为空\n", Color.Red);
- return;
- }
- string Delete = MessageBox.Show(this.ParentForm, "是否确认拆箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (Delete == "Yes")
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_checkno,ob_status,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus from package left join oqcbatch on pa_checkno=ob_checkno where pa_outboxcode='" + pa_outboxcode.Text + "'", "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 (dt.Rows[0]["pa_mothercode"].ToString() == "")
- {
- if (dt.Rows[0]["pa_downstatus"].ToString() == "0")
- {
- string ob_status = dt.Rows[0]["ob_status"].ToString();
- string pa_checkno = dt.Rows[0]["pa_checkno"].ToString();
- //不存在抽检批次或者还未检验可以拆解
- if (ob_status == "" || ob_status == "ENTERING" || ob_status == "UNCHECK")
- {
- sql.Clear();
- sql.Append("select pd_makecode,count(1) num from packagedetail left join makeserial ");
- sql.Append("on ms_sncode=pd_barcode and ms_makecode=pd_makecode where pd_outboxcode='" + pa_outboxcode.Text + "' group by pd_makecode");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- List<string> SQLS1 = new List<string>();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- string ma_code = dt.Rows[i]["pd_makecode"].ToString();
- string num = dt.Rows[i]["num"].ToString();
- SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and mp_makecode='" + ma_code + "' and mp_stepcode='" + User.CurrentStepCode + "'");
- SQLS1.Add("delete from steppassed where sp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "') and sp_makecode='" + ma_code + "' and sp_stepcode='" + User.CurrentStepCode + "'");
- SQLS1.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + num + ",mcd_outqty=mcd_outqty-" + num + ",mcd_okqty=mcd_okqty-" + num + " where mcd_macode='" + ma_code + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- //扣减已完工数
- SQLS1.Add("update make set ma_madeqty=ma_madeqty-(select count(1) from makeserial where ms_outboxcode='" + pa_outboxcode.Text + "' and ms_makecode='" + ma_code + "' and ms_status=2) where ma_code='" + ma_code + "'");
- }
- if (pa_checkno != "")
- {
- SQLS1.Add("update makeserial set ms_checkno='' where ms_outboxcode='" + pa_outboxcode.Text + "'");
- SQLS1.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-(select count(1) from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "') where ob_checkno='" + pa_checkno + "'");
- SQLS1.Add("delete from oqcbatchdetail where obd_outboxcode='" + pa_outboxcode.Text + "'");
- }
- //更新序列号状态
- SQLS1.Add("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= '" + User.CurrentStepCode + "',ms_paststep=replace(ms_paststep,'," + User.CurrentStepCode + "','') where ms_outboxcode='" + pa_outboxcode.Text + "'");
- //抽检批次不为空的时候进行移除
- dh.ExecuteSQLTran(SQLS1.ToArray());
- string prcode = dh.getFieldDataByCondition("packagedetail", "pd_prodcode", "pd_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
- string standqty = dh.getFieldDataByCondition("product", "pr_outboxinnerqty", "pr_code = '" + prcode + "'").ToString();
- if (standqty != "")
- {
- //置空原箱
- dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0,PA_STANDARDQTY = '" + standqty + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
- }
- else
- //置空原箱
- dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
- pa_status.Text = "0";
- //删除箱的明细
- dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'", "delete");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱拆解", "成功", pa_outboxcode.Text, ob_checkno.Text);
- OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "成功拆解!\n", Color.Green, pa_outboxcode);
- LoadGridData();
- LoadCheckQTY();
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已送检,不允许解除\n", Color.Red);
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已下地,不允许解除\n", Color.Red);
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已装箱" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许解除\n", Color.Red);
- }
- else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "不存在\n", Color.Red);
- }
- }
- private void OutBoxLength_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- try
- {
- if (OutBoxLength.Text != "")
- {
- int.Parse(OutBoxLength.Text);
- }
- BaseUtil.SetCacheData("OutBoxLength", OutBoxLength.Text);
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- }
- }
- catch (Exception)
- {
- OutBoxLength.Clear();
- MessageBox.Show("请输入正确的长度");
- }
- }
- }
- 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;
- }
- }
- if (PreFix.Text != "")
- {
- try
- {
- if (pa_outboxcode.Text.Substring(0, PreFix.Text.Length) != PreFix.Text)
- {
- OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
- return false;
- }
- }
- catch (Exception)
- {
- OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
- return false;
- }
- }
- return true;
- }
- private void LoadCollectedNum()
- {
- dt = (DataTable)dh.ExecuteSql("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty from make left join makecraftdetail_view on mcd_macode=ma_code where ma_code='" + ms_makecode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
- BaseUtil.SetFormValue(Controls, dt);
- }
- private void pa_remark_KeyDown(object sender, KeyEventArgs e)
- {
- if (Keys.Enter == e.KeyCode)
- {
- if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
- {
- if (Remark_PreFix.Text != "")
- {
- try
- {
- if (pa_remark.Text.Substring(0, Remark_PreFix.Text.Length) != Remark_PreFix.Text)
- {
- OperateResult.AppendText(">>备注前缀不匹配,请重新输入备注信息\n", Color.Red);
- return;
- }
- }
- catch (Exception)
- {
- OperateResult.AppendText(">>备注前缀不匹配,请重新输入备注信息\n", Color.Red);
- return;
- }
- }
- if (!AllowRepeat.Checked)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select pa_outboxcode from package where pa_remark='" + pa_remark.Text.ToUpper() + "'", "select");
- if (dt.Rows.Count > 0)
- {
- OperateResult.AppendText(">>箱号" + dt.Rows[0][0].ToString() + "已采集关联信息" + pa_remark.Text + "\n", Color.Red);
- return;
- }
- }
- dh.UpdateByCondition("package", "pa_remark='" + pa_remark.Text.ToUpper() + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
- OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "关联信息" + pa_remark.Text + "采集成功\n", Color.Green);
- pa_remark.Text = "";
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- }
- }
- else OperateResult.AppendText(">>请先采集箱内数据\n", Color.Red);
- }
- }
- private void PreFix_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- BaseUtil.SetCacheData("PreFix", PreFix.Text);
- if (!AutoGenBoxCode.Checked)
- {
- pa_outboxcode.SelectAll();
- pa_outboxcode.Focus();
- }
- else
- {
- sn_code.Focus();
- sn_code.SelectAll();
- }
- }
- }
- private void BuildServer_Click(object sender, EventArgs e)
- {
- if (!md.IsOpen)
- {
- md.IP = IP.Text;
- md.Port = Port.Text;
- if (md.Open())
- {
- BaseUtil.SetCacheData("IP", IP.Text);
- BaseUtil.SetCacheData("IPPort", Port.Text);
- OperateResult.AppendText(">>服务开启成功\n");
- }
- }
- else
- OperateResult.AppendText(">>服务已经开启\n");
- }
- private void CloseServer_Click(object sender, EventArgs e)
- {
- if (md.IsOpen)
- {
- md.Close();
- OperateResult.AppendText(">>服务关闭成功\n");
- }
- else
- OperateResult.AppendText(">>服务尚未开启\n");
- }
- private void Remark_PreFix_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- BaseUtil.SetCacheData("Remark_PreFix", Remark_PreFix.Text);
- if (CollecRemark.Checked)
- {
- pa_remark.SelectAll();
- pa_remark.Focus();
- }
- }
- }
- private bool CheckOutBoxLength(string ms_salecode_text)
- {
- if (AutoGenBoxCode.Checked)
- {
- if (ms_salecode_text != "")
- {
- DataTable dt = (DataTable)dh.ExecuteSql(" select pn_number,pn_id,pn_caller,pn_numberlength,pn_leadcode from PACKAGENUMBER where pn_caller='" + pr_code.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- string pn_leadcode = dt.Rows[0]["pn_leadcode"].ToString();
- int pn_numberlength = int.Parse(dt.Rows[0]["pn_numberlength"].ToString());
- if (OutBoxLength.Text != (pn_leadcode.Length + pn_numberlength).ToString())
- {
- OutBoxLength.Text = (pn_leadcode.Length + pn_numberlength).ToString();
- BaseUtil.SetCacheData("OutBoxLength", OutBoxLength.Text);
- }
- if (PreFix.Text != pn_leadcode)
- {
- PreFix.Text = pn_leadcode;
- BaseUtil.SetCacheData("PreFix", PreFix.Text);
- }
- }
- else
- {
- OperateResult.AppendText(">>产品" + pr_code.Text + "未维护箱号规则\n", Color.Black);
- }
- }
- return true;
- }
- return CheckOutBoxLength();
- }
- private void AutoGenBoxCode_CheckedChanged(object sender, EventArgs e)
- {
- if (AutoGenBoxCode.Checked)
- {
- OutBoxLength.Enabled = false;
- PreFix.Enabled = false;
- }
- else
- {
- OutBoxLength.Enabled = true;
- PreFix.Enabled = true;
- }
- }
- }
- }
|