|
@@ -14,6 +14,9 @@ using System.IO.Ports;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using System.Diagnostics;
|
|
|
|
|
+using Seagull.BarTender.Print;
|
|
|
|
|
+using HslCommunication;
|
|
|
|
|
|
|
|
namespace UAS_MES_NEW.Packing
|
|
namespace UAS_MES_NEW.Packing
|
|
|
{
|
|
{
|
|
@@ -23,8 +26,7 @@ namespace UAS_MES_NEW.Packing
|
|
|
DataTable dt;
|
|
DataTable dt;
|
|
|
LogStringBuilder sql = new LogStringBuilder();
|
|
LogStringBuilder sql = new LogStringBuilder();
|
|
|
AutoSizeFormClass asc = new AutoSizeFormClass();
|
|
AutoSizeFormClass asc = new AutoSizeFormClass();
|
|
|
- Document doc;
|
|
|
|
|
- ApplicationClass lbl;
|
|
|
|
|
|
|
+ BarTender.Application engine;
|
|
|
Thread thread;
|
|
Thread thread;
|
|
|
DataTable Dbfind;
|
|
DataTable Dbfind;
|
|
|
string ErrorMessage = "";
|
|
string ErrorMessage = "";
|
|
@@ -65,17 +67,27 @@ namespace UAS_MES_NEW.Packing
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- lbl = new ApplicationClass();
|
|
|
|
|
- BaseUtil.WriteLbl();
|
|
|
|
|
|
|
+ engine = new BarTender.Application();
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
- OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
|
|
|
|
|
|
|
+ OperateResult.AppendText("未正确安装打印软件\n" + ex.Message, Color.Red);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void Make_PackageCollectionWeigh_Load(object sender, EventArgs e)
|
|
private void Make_PackageCollectionWeigh_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();
|
|
|
|
|
+ }
|
|
|
ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
|
|
ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
|
|
|
Baurate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
|
|
Baurate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
|
|
|
//设置DbFind的必须的数据
|
|
//设置DbFind的必须的数据
|
|
@@ -235,7 +247,7 @@ namespace UAS_MES_NEW.Packing
|
|
|
{
|
|
{
|
|
|
dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
|
|
dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
|
|
|
//doc = lbl.Documents.Open(PrintLabel.Text);
|
|
//doc = lbl.Documents.Open(PrintLabel.Text);
|
|
|
- if (Print.CodeSoft(Tag.ToString(), ref lbl, 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))
|
|
|
|
|
|
|
+ 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.Black);
|
|
OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
|
|
|
}
|
|
}
|
|
@@ -494,6 +506,8 @@ namespace UAS_MES_NEW.Packing
|
|
|
OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "满箱封箱成功\n", Color.Green);
|
|
OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "满箱封箱成功\n", Color.Green);
|
|
|
LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
|
|
LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
|
|
|
LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
|
|
LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
|
|
|
|
|
+ if (AutoPrint.Checked)
|
|
|
|
|
+ Print_Click(new object(), new EventArgs());
|
|
|
if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + pa_outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
|
|
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 + "'");
|
|
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 + "'");
|
|
@@ -591,7 +605,9 @@ namespace UAS_MES_NEW.Packing
|
|
|
|
|
|
|
|
private void Make_PackageCollectionWeigh_FormClosing(object sender, FormClosingEventArgs e)
|
|
private void Make_PackageCollectionWeigh_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
{
|
|
|
- BaseUtil.ClosePrint(lbl);
|
|
|
|
|
|
|
+ if (engine != null)
|
|
|
|
|
+ engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
|
|
|
|
|
+ dh.Dispose();
|
|
|
if (serialPort1.IsOpen)
|
|
if (serialPort1.IsOpen)
|
|
|
{
|
|
{
|
|
|
GetData = false;
|
|
GetData = false;
|
|
@@ -629,6 +645,8 @@ namespace UAS_MES_NEW.Packing
|
|
|
LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
|
|
LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
|
|
|
LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
|
|
LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
|
|
|
string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
|
|
string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
|
|
|
|
|
+ if (AutoPrint.Checked)
|
|
|
|
|
+ Print_Click(new object(), new EventArgs());
|
|
|
if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + pa_outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
|
|
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 + "'");
|
|
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 + "'");
|