|
|
@@ -23,9 +23,13 @@ namespace UAS_LabelMachine
|
|
|
AutoSizeFormClass asc = new AutoSizeFormClass();
|
|
|
|
|
|
DataHelper dh;
|
|
|
-
|
|
|
+
|
|
|
AccessDBHelper adh;
|
|
|
|
|
|
+ AccessDBHelper front_adh;
|
|
|
+
|
|
|
+ AccessDBHelper back_adh;
|
|
|
+
|
|
|
DataTable dt;
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
@@ -135,6 +139,8 @@ namespace UAS_LabelMachine
|
|
|
LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
|
|
|
dh = SystemInf.dh;
|
|
|
adh = SystemInf.adh;
|
|
|
+ front_adh = SystemInf.front_adh;
|
|
|
+ back_adh = SystemInf.back_adh;
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
pi_inoutno.Focus();
|
|
|
|
|
|
@@ -214,7 +220,7 @@ namespace UAS_LabelMachine
|
|
|
PLC1.DataReceived += Serial_DataReceived;
|
|
|
PLC1.Open();
|
|
|
}
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart, adh);
|
|
|
MessageLog.AppendText("PLC启动成功\n", Color.Blue);
|
|
|
}
|
|
|
RefreshPLCInstruct();
|
|
|
@@ -268,7 +274,7 @@ namespace UAS_LabelMachine
|
|
|
FrontCollect.Text = msg;
|
|
|
if (!FrontCheckFunction(msg, out ErrorMsg))
|
|
|
{
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataDelete);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataDelete, adh);
|
|
|
BaseUtil.PlaySound("Scan.Error.wav");
|
|
|
MessageLog.AppendText(">>" + ErrorMsg + "\n", Color.Red);
|
|
|
}
|
|
|
@@ -292,7 +298,7 @@ namespace UAS_LabelMachine
|
|
|
//勾选了中盒自动打印
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
AutoPrintMidLabel();
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataPass);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataPass,adh);
|
|
|
LabelInf.Invalidate();
|
|
|
}
|
|
|
break;
|
|
|
@@ -300,12 +306,12 @@ namespace UAS_LabelMachine
|
|
|
BackCheck.Text = msg;
|
|
|
if (BackendCheckFunction(msg, out ErrorMsg))
|
|
|
{
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataPass);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataPass, adh);
|
|
|
BaseUtil.PlaySound("Confirm.Finish.wav");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataDelete);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.BackDataDelete, adh);
|
|
|
BaseUtil.PlaySound("Confirm.Error.wav");
|
|
|
MessageLog.AppendText(">>" + ErrorMsg + "\n", Color.Red);
|
|
|
}
|
|
|
@@ -477,20 +483,20 @@ namespace UAS_LabelMachine
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
|
|
|
- string boxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
+ string boxcode = front_adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
|
|
|
- boxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
+ boxcode = front_adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
|
|
|
string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
|
|
|
//如果满容量获取过箱号就不再重复获取了
|
|
|
bool GetBarcode = false;
|
|
|
//超过中盒容量中盒号+1
|
|
|
- if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
|
|
|
+ if (front_adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
|
|
|
{
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
GetBarcode = true;
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
|
|
|
}
|
|
|
//获取当前的行号
|
|
|
int CurrentRowNum = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["rownum"].Value.ToString());
|
|
|
@@ -498,7 +504,7 @@ namespace UAS_LabelMachine
|
|
|
DataTable LastRowData = null;
|
|
|
if (CurrentRowNum - 1 > 0)
|
|
|
{
|
|
|
- LastRowData = (DataTable)adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
|
|
|
+ LastRowData = (DataTable)front_adh.ExecuteSql("select pib_lotno,pib_custmidboxcode,pib_custoutboxcode,pd_pocode,pd_custprodcode,pd_custprodspec,pib_datecode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and rownum=" + (CurrentRowNum - 1), "select");
|
|
|
//或者不符合合并条件中盒号+1
|
|
|
if (cu_print_midlotno.Checked)
|
|
|
{
|
|
|
@@ -506,7 +512,7 @@ namespace UAS_LabelMachine
|
|
|
if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
|
|
|
{
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
}
|
|
|
@@ -517,7 +523,7 @@ namespace UAS_LabelMachine
|
|
|
if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
|
|
|
{
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
}
|
|
|
@@ -528,7 +534,7 @@ namespace UAS_LabelMachine
|
|
|
if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
|
|
|
{
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray,front_adh);
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
}
|
|
|
@@ -539,7 +545,7 @@ namespace UAS_LabelMachine
|
|
|
if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
|
|
|
{
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
}
|
|
|
@@ -550,7 +556,7 @@ namespace UAS_LabelMachine
|
|
|
if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
|
|
|
{
|
|
|
LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, front_adh);
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
outboxcode1 = outboxcode1 + 1;
|
|
|
}
|
|
|
@@ -566,7 +572,7 @@ namespace UAS_LabelMachine
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
|
|
|
}
|
|
|
GetBarcode = false;
|
|
|
- if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
|
|
|
+ if (front_adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
|
|
|
{
|
|
|
GetBarcode = true;
|
|
|
outboxcode2 = outboxcode2 + 1;
|
|
|
@@ -635,7 +641,7 @@ namespace UAS_LabelMachine
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
|
|
|
string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- adh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1 where pib_id=" + pib_id, "update");
|
|
|
+ front_adh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1 where pib_id=" + pib_id, "update");
|
|
|
LabelInf.Invalidate();
|
|
|
return true;
|
|
|
}
|
|
|
@@ -669,7 +675,7 @@ namespace UAS_LabelMachine
|
|
|
//直接验证两个值相等
|
|
|
if (Equal.Checked)
|
|
|
{
|
|
|
- pibid = adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pd_custprodcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
|
|
|
+ pibid = back_adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pd_custprodcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
|
|
|
if (pibid != "")
|
|
|
{
|
|
|
pibid1 = pibid;
|
|
|
@@ -700,7 +706,7 @@ namespace UAS_LabelMachine
|
|
|
CheckItem.Add("唯一条码");
|
|
|
CheckItem.Add("原厂型号");
|
|
|
}
|
|
|
- pibid = adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_custbarcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
|
|
|
+ pibid = back_adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_custbarcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
|
|
|
if (pibid != "")
|
|
|
{
|
|
|
pibid1 = pibid;
|
|
|
@@ -731,7 +737,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
dr[0]["pib_ifrecheck"] = -1;
|
|
|
}
|
|
|
- adh.ExecuteSql("update prodiobarcode set pib_ifrecheck=-1 where pib_id=" + pibid1, "update");
|
|
|
+ back_adh.ExecuteSql("update prodiobarcode set pib_ifrecheck=-1 where pib_id=" + pibid1, "update");
|
|
|
}
|
|
|
LabelInf.Invalidate();
|
|
|
RefreshProcessData();
|
|
|
@@ -1434,7 +1440,7 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void OutBoxCodePrint(int rowindex)
|
|
|
{
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray, adh);
|
|
|
//获取对应行的pib_id
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
@@ -2001,7 +2007,7 @@ namespace UAS_LabelMachine
|
|
|
PLC1.DataReceived += Serial_DataReceived;
|
|
|
PLC1.Open();
|
|
|
}
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart, adh);
|
|
|
MessageLog.AppendText("PLC启动成功\n", Color.Blue);
|
|
|
}
|
|
|
adh.ExecuteSql("update prodiobarcode set pib_ifpick=0,pib_ifprint=0,pib_ifmodify=0 where pib_ifrecheck=0 and pib_inoutno='" + pi_inoutno.Text + "'", "update");
|
|
|
@@ -2017,7 +2023,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void PLCStop_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStop);
|
|
|
+ LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStop, adh);
|
|
|
MessageLog.AppendText("PLC暂停成功\n", Color.Blue);
|
|
|
}
|
|
|
|