|
|
@@ -174,10 +174,11 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
RefreshDBConnect.Interval = 60000;
|
|
|
RefreshDBConnect.Start();
|
|
|
+ DataTable dt = (DataTable)adh.ExecuteSql("select * from cominfo", "select");
|
|
|
+ DataRow[] dr;
|
|
|
try
|
|
|
{
|
|
|
- DataTable dt = (DataTable)adh.ExecuteSql("select * from cominfo", "select");
|
|
|
- DataRow[] dr = dt.Select("comtype='FrontendCheck'");
|
|
|
+ dr = dt.Select("comtype='FrontendCheck'");
|
|
|
if (dr.Length > 0)
|
|
|
{
|
|
|
FrontendCheck.PortName = dr[0]["COM"].ToString();
|
|
|
@@ -191,6 +192,13 @@ namespace UAS_LabelMachine
|
|
|
FrontendCheck.DataReceived += Serial_DataReceived;
|
|
|
FrontendCheck.Open();
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageLog.AppendText(ex.Message);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
dr = dt.Select("comtype='BackendCheck'");
|
|
|
if (dr.Length > 0)
|
|
|
{
|
|
|
@@ -205,6 +213,13 @@ namespace UAS_LabelMachine
|
|
|
BackendCheck.DataReceived += Serial_DataReceived;
|
|
|
BackendCheck.Open();
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageLog.AppendText(ex.Message);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
dr = dt.Select("comtype='PLC1'");
|
|
|
if (dr.Length > 0)
|
|
|
{
|
|
|
@@ -224,6 +239,14 @@ namespace UAS_LabelMachine
|
|
|
LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart, adh);
|
|
|
MessageLog.AppendText("PLC启动成功\n", Color.Blue);
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageLog.AppendText(ex.Message);
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
dr = dt.Select("comtype='ManBackendCheck'");
|
|
|
if (dr.Length > 0)
|
|
|
{
|
|
|
@@ -446,6 +469,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
sql += "and pib_ifrecheck=0";
|
|
|
}
|
|
|
+ Console.WriteLine(adh.getRowCount("prodiobarcode","pib_ifrecheck=-1"));
|
|
|
DataTable pndt = (DataTable)adh.ExecuteSql(sql, "select");
|
|
|
if (pndt.Rows[0][0].ToString() != "")
|
|
|
{
|
|
|
@@ -514,6 +538,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ Console.WriteLine("行号"+rownum);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -737,142 +762,175 @@ namespace UAS_LabelMachine
|
|
|
DataTable dtt = LabelInf.DataSource as DataTable;
|
|
|
MessageLog.AppendText(msg + "\n");
|
|
|
string[] msgArr = msg.Split(back_sg_separator.Text.ToCharArray());
|
|
|
- //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
|
|
|
- List<string> CheckItem = new List<string>();
|
|
|
- string pibid = "";
|
|
|
- for (int i = 0; i < msgArr.Length; i++)
|
|
|
+ //如果包含则分隔符则需要解析,如果不包含则直接前端解析
|
|
|
+ if (msg.Contains(back_sg_separator.Text))
|
|
|
{
|
|
|
- if (RecheckCuprodcode.Checked)
|
|
|
+ //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
|
|
|
+ List<string> CheckItem = new List<string>();
|
|
|
+ string pibid = "";
|
|
|
+ for (int i = 0; i < msgArr.Length; i++)
|
|
|
{
|
|
|
- if (!CheckItem.Contains("客户料号") && !CheckItem.Contains("原厂型号"))
|
|
|
+ if (RecheckCuprodcode.Checked)
|
|
|
{
|
|
|
- CheckItem.Add("客户料号");
|
|
|
- CheckItem.Add("原厂型号");
|
|
|
+ if (!CheckItem.Contains("客户料号") && !CheckItem.Contains("原厂型号"))
|
|
|
+ {
|
|
|
+ CheckItem.Add("客户料号");
|
|
|
+ CheckItem.Add("原厂型号");
|
|
|
+ }
|
|
|
+ //直接验证两个值相等
|
|
|
+ if (Equal.Checked)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ CheckItem.Remove("客户料号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //验证正则匹配过之后相等
|
|
|
+ else if (Expression.Checked)
|
|
|
+ {
|
|
|
+ Regex re = new Regex(cu_print_regexpression.Text);
|
|
|
+ if (re.Match(msgArr[i]).Value == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
|
|
|
+ {
|
|
|
+ CheckItem.Remove("客户料号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (RegexMatch("BackCheck", msgArr[i], out ErrorMsg))
|
|
|
+ {
|
|
|
+ CheckItem.Remove("原厂型号");
|
|
|
+ }
|
|
|
}
|
|
|
- //直接验证两个值相等
|
|
|
- if (Equal.Checked)
|
|
|
+ else if (RecheckBarcode.Checked)
|
|
|
{
|
|
|
- pibid = back_adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pd_custprodcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
|
|
|
+ if (!CheckItem.Contains("唯一条码") && !CheckItem.Contains("原厂型号"))
|
|
|
+ {
|
|
|
+ CheckItem.Add("唯一条码");
|
|
|
+ CheckItem.Add("原厂型号");
|
|
|
+ }
|
|
|
+ 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;
|
|
|
- CheckItem.Remove("客户料号");
|
|
|
+ CheckItem.Remove("唯一条码");
|
|
|
}
|
|
|
- }
|
|
|
- //验证正则匹配过之后相等
|
|
|
- else if (Expression.Checked)
|
|
|
- {
|
|
|
- Regex re = new Regex(cu_print_regexpression.Text);
|
|
|
- if (re.Match(msgArr[i]).Value == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
|
|
|
+ else
|
|
|
{
|
|
|
- CheckItem.Remove("客户料号");
|
|
|
+ if (RegexMatch("BackCheck", msgArr[i], out ErrorMsg))
|
|
|
+ {
|
|
|
+ CheckItem.Remove("原厂型号");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (RegexMatch("BackCheck", msgArr[i], out ErrorMsg))
|
|
|
+ }
|
|
|
+ //如果是自动复核或者手动复核扫描了两次数据的话
|
|
|
+ if (CheckItem.Count == 0 || (type == "Manual" && CheckItem.Count == 1))
|
|
|
+ {
|
|
|
+ if (CheckItem.Count == 0 || (ManualCheckCount.Count == 1 && CheckItem.Count == 1))
|
|
|
{
|
|
|
- CheckItem.Remove("原厂型号");
|
|
|
+ string year = "0";
|
|
|
+ string month = "0";
|
|
|
+ string day = "0";
|
|
|
+ DataRow[] dr = LabelInfDataTable.Select("pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'");
|
|
|
+ if (dr.Length > 0)
|
|
|
+ {
|
|
|
+ dr[0]["pib_ifrecheck"] = -1;
|
|
|
+ dr[0]["pib_lotno"] = LotNo;
|
|
|
+ dr[0]["pib_datecode"] = DateCode;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
|
|
|
+ dr[0]["pib_year"] = year;
|
|
|
+ dr[0]["pib_month"] = month;
|
|
|
+ dr[0]["pib_day"] = day;
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorMsg = "未匹配到合适的原厂型号";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ back_adh.ExecuteSql("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_ifrecheck=-1,pib_datecode='" + DateCode + "',pib_lotno='" + LotNo + "' where pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'", "update");
|
|
|
}
|
|
|
}
|
|
|
- else if (RecheckBarcode.Checked)
|
|
|
+ else
|
|
|
{
|
|
|
- if (!CheckItem.Contains("唯一条码") && !CheckItem.Contains("原厂型号"))
|
|
|
+ string Item = "";
|
|
|
+ for (int i = 0; i < CheckItem.Count; i++)
|
|
|
{
|
|
|
- CheckItem.Add("唯一条码");
|
|
|
- CheckItem.Add("原厂型号");
|
|
|
+ Item += CheckItem[i].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 != "")
|
|
|
+ //如果通过正则校验,则不需要传递出来的错误信息了
|
|
|
+ if (!CheckItem.Contains("原厂型号"))
|
|
|
{
|
|
|
- pibid1 = pibid;
|
|
|
- CheckItem.Remove("唯一条码");
|
|
|
+ ErrorMsg = "";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (RegexMatch("BackCheck", msgArr[i], out ErrorMsg))
|
|
|
- {
|
|
|
- CheckItem.Remove("原厂型号");
|
|
|
- }
|
|
|
+ ErrorMsg = "【" + ErrorMsg + "】";
|
|
|
}
|
|
|
+ ErrorMsg += Item + "复核不通过";
|
|
|
+ return false;
|
|
|
}
|
|
|
- }
|
|
|
- //如果是自动复核或者手动复核扫描了两次数据的话
|
|
|
- if (CheckItem.Count == 0 || (type == "Manual" && CheckItem.Count == 1))
|
|
|
- {
|
|
|
if (CheckItem.Count == 0 || (ManualCheckCount.Count == 1 && CheckItem.Count == 1))
|
|
|
{
|
|
|
- string year = "0";
|
|
|
- string month = "0";
|
|
|
- string day = "0";
|
|
|
- DataRow[] dr = LabelInfDataTable.Select("pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'");
|
|
|
- if (dr.Length > 0)
|
|
|
+ LabelInf.Invalidate();
|
|
|
+ RefreshProcessData();
|
|
|
+ if (CurrentRowIndex - 10 > 0)
|
|
|
+ LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 5;
|
|
|
+ //如果成功上传了数据
|
|
|
+ if (LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum))
|
|
|
{
|
|
|
- dr[0]["pib_ifrecheck"] = -1;
|
|
|
- dr[0]["pib_lotno"] = LotNo;
|
|
|
- dr[0]["pib_datecode"] = DateCode;
|
|
|
- try
|
|
|
+ for (int i = 0; i < dtt.Rows.Count; i++)
|
|
|
{
|
|
|
- LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
|
|
|
- dr[0]["pib_year"] = year;
|
|
|
- dr[0]["pib_month"] = month;
|
|
|
- dr[0]["pib_day"] = day;
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
-
|
|
|
+ if (dtt.Rows[i]["pib_ifrecheck"].ToString() != "0" && dtt.Rows[i]["pib_ifupload"].ToString() == "0")
|
|
|
+ {
|
|
|
+ dtt.Rows[i]["pib_ifupload"] = -1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- ErrorMsg = "未匹配到合适的原厂型号";
|
|
|
- return false;
|
|
|
- }
|
|
|
- back_adh.ExecuteSql("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_ifrecheck=-1,pib_datecode='" + DateCode + "',pib_lotno='" + LotNo + "' where pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'", "update");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string Item = "";
|
|
|
- for (int i = 0; i < CheckItem.Count; i++)
|
|
|
- {
|
|
|
- Item += CheckItem[i].ToString() + " ";
|
|
|
- }
|
|
|
- //如果通过正则校验,则不需要传递出来的错误信息了
|
|
|
- if (!CheckItem.Contains("原厂型号"))
|
|
|
- {
|
|
|
- ErrorMsg = "";
|
|
|
+ return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ErrorMsg = "【" + ErrorMsg + "】";
|
|
|
+ if (type == "Manual" && CheckItem.Count == 1)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
- ErrorMsg += Item + "复核不通过";
|
|
|
- return false;
|
|
|
}
|
|
|
- if (CheckItem.Count == 0 || (ManualCheckCount.Count == 1 && CheckItem.Count == 1))
|
|
|
+ else
|
|
|
{
|
|
|
- LabelInf.Invalidate();
|
|
|
- RefreshProcessData();
|
|
|
- if (CurrentRowIndex - 10 > 0)
|
|
|
- LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 5;
|
|
|
- //如果成功上传了数据
|
|
|
- if (LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum))
|
|
|
+ if (RegexMatch("BackCheck", msg, out ErrorMsg))
|
|
|
{
|
|
|
- for (int i = 0; i < dtt.Rows.Count; i++)
|
|
|
+ string year = "0";
|
|
|
+ string month = "0";
|
|
|
+ string day = "0";
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
|
|
|
+ //解析DateCode,将值设置到年月日
|
|
|
+ try
|
|
|
{
|
|
|
- if (dtt.Rows[i]["pib_ifrecheck"].ToString() != "0" && dtt.Rows[i]["pib_ifupload"].ToString() == "0")
|
|
|
- {
|
|
|
- dtt.Rows[i]["pib_ifupload"] = -1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (type == "Manual" && CheckItem.Count == 1)
|
|
|
+ LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
|
|
|
+ }
|
|
|
+ catch (Exception){}
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_ifrecheck"].Value = true;
|
|
|
+ LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
|
|
|
+ back_adh.ExecuteSQLTran("update prodiobarcode set pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + ",pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifrecheck=-1 where pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
|
|
|
+ Console.WriteLine("勾选行数"+ back_adh.getRowCount("prodiobarcode", "pib_ifrecheck=-1"));
|
|
|
+ Console.WriteLine("勾选行数"+adh.getRowCount("prodiobarcode", "pib_ifrecheck=-1"));
|
|
|
+ LabelInf.Invalidate();
|
|
|
return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2355,7 +2413,12 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- adh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
|
|
|
+ string close = MessageBox.Show(this.ParentForm, "是否重新下载服务端条码,将会覆盖本地记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
+ if (close.ToString() == "Yes")
|
|
|
+ {
|
|
|
+ adh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
|
|
|
+ LoadGridData();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void LabelInf_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|