|
|
@@ -345,7 +345,6 @@ namespace UAS_LabelMachine
|
|
|
//获取ID
|
|
|
PIBID = dh.GetSEQ("prodiobarcode_seq", CodeCount);
|
|
|
string pib_outboxcode2 = "";
|
|
|
- string CustOutBoxCode = "";
|
|
|
if (OutBoxNum.Text == "新增")
|
|
|
{
|
|
|
string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
@@ -361,26 +360,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //如果不是新增插入当前外箱的自定义编号
|
|
|
- CustOutBoxCode = dh.getFieldDataByCondition("prodiobarcode", "pib_custoutboxcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + OutBoxNum.Text + "'").ToString();
|
|
|
- if (CustOutBoxCode == "")
|
|
|
- {
|
|
|
- string maxoutbox = dh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
|
|
|
- //如果没有则从开始插入
|
|
|
- if (maxoutbox == "")
|
|
|
- {
|
|
|
- pib_outboxcode2 = "1";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pib_outboxcode2 = (int.Parse(maxoutbox) + 1).ToString();
|
|
|
- }
|
|
|
- OutBoxNum.Text = "新增";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pib_outboxcode2 = OutBoxNum.Text;
|
|
|
- }
|
|
|
+ pib_outboxcode2 = OutBoxNum.Text;
|
|
|
}
|
|
|
//计算当前采集数量
|
|
|
string collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
|
|
|
@@ -391,8 +371,6 @@ namespace UAS_LabelMachine
|
|
|
return;
|
|
|
}
|
|
|
List<string> CustBarCode = new List<string>();
|
|
|
- List<string> CustMidBarCode = new List<string>();
|
|
|
- List<string> CustOutBarCode = new List<string>();
|
|
|
for (int i = 0; i < CodeCount; i++)
|
|
|
{
|
|
|
if (Radix > 0)
|
|
|
@@ -409,46 +387,16 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
CustBarCode.Add("");
|
|
|
}
|
|
|
- //添加外箱号
|
|
|
- if (Prefix != "")
|
|
|
- {
|
|
|
- if (OutBoxNum.Text == "新增")
|
|
|
- {
|
|
|
- string Outserialcode = BaseUtil.DToAny(MaxNum, Radix);
|
|
|
- for (int j = Outserialcode.ToString().Length; j < NumLength; j++)
|
|
|
- {
|
|
|
- Outserialcode = "0" + Outserialcode;
|
|
|
- }
|
|
|
- CustOutBarCode.Add(Prefix + Outserialcode + Suffix);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CustOutBarCode.Add(CustOutBoxCode);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CustOutBarCode.Add("");
|
|
|
- }
|
|
|
- }
|
|
|
- if (OutBoxNum.Text == "新增")
|
|
|
- {
|
|
|
- MaxNum = MaxNum + 1;
|
|
|
}
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
|
|
|
- sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,pib_datecode,pib_lotno,PIB_OUTBOXCODE2,pib_inman,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
|
|
|
+ sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,pib_datecode,pib_lotno,PIB_OUTBOXCODE2,pib_inman,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
|
|
|
sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
|
|
|
- sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["DATECODE"] + "','" + Data["LOTNO"] + "','" + pib_outboxcode2 + "','" + User.UserCode + "',:pib_custoutboxcode,'" + (EnablePrint ? 1 : 0).ToString() + "',pd_ordercode,pd_pocode ");
|
|
|
+ sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["DATECODE"] + "','" + Data["LOTNO"] + "','" + pib_outboxcode2 + "','" + User.UserCode + "','" + (EnablePrint ? 1 : 0).ToString() + "',pd_ordercode,pd_pocode ");
|
|
|
sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "' and pd_pdno='" + CurrentPDNO + "'");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE", "pib_custoutboxcode" }, PIBID, CustBarCode.ToArray(), CustOutBarCode.ToArray());
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE" }, PIBID, CustBarCode.ToArray());
|
|
|
//更新流水号
|
|
|
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + Prefix + "'");
|
|
|
- if (OutBoxNum.Text == "新增")
|
|
|
- {
|
|
|
- dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Out' and rmn_prefix='" + Prefix + "'");
|
|
|
- }
|
|
|
- OutBoxNum.Text = pib_outboxcode2;
|
|
|
+ dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'");
|
|
|
LoadGridData(new object(), new EventArgs());
|
|
|
//加载完数据之后进行容量的判断
|
|
|
int BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
|
|
|
@@ -506,7 +454,7 @@ namespace UAS_LabelMachine
|
|
|
for (int i = 0; i < PIBID.Length; i++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + PIBID[i] + "'"), "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.ToLower().Replace("{pib_id}", "'" + PIBID[i] + "'"), "select");
|
|
|
for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
@@ -851,7 +799,7 @@ namespace UAS_LabelMachine
|
|
|
try
|
|
|
{
|
|
|
string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id + "'"), "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'"), "select");
|
|
|
StringBuilder ParamLog = new StringBuilder();
|
|
|
for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
@@ -1135,10 +1083,10 @@ namespace UAS_LabelMachine
|
|
|
string ParamName = MidLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(MidSQL.Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(MidSQL.ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
|
|
|
//获取打印执行的SQL
|
|
|
MidDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
+ LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
}
|
|
|
//保存参数打印
|
|
|
MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
@@ -1155,60 +1103,14 @@ namespace UAS_LabelMachine
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
+ //名称相等的时候,取SQL进行值的查询
|
|
|
string ParamName = MidLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
- //获取对应行的pib_id
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(MidSQL.ToLower().Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
|
|
|
//获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(ParamName).Name.ToLower().Contains("datecode1"))
|
|
|
- {
|
|
|
- if (LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value != null)
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value.ToString();
|
|
|
- }
|
|
|
- else if (MidDoc.Variables.FreeVariables.Item(ParamName).Name.ToLower().Contains("lotno"))
|
|
|
- {
|
|
|
- if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
|
|
|
- }
|
|
|
- else if (MidDoc.Variables.FreeVariables.Item(ParamName).Name.ToLower().Contains("datecode"))
|
|
|
- {
|
|
|
- if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (sql.ToLower().Contains("pib_qty"))
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("=")) + "='" + pib_outboxcode1 + "' group by pib_outboxcode1";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'";
|
|
|
- }
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值" + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
}
|
|
|
//保存参数打印
|
|
|
|
|
|
@@ -1231,7 +1133,7 @@ namespace UAS_LabelMachine
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
|
|
|
for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
//获取对应行的pib_id
|
|
|
@@ -1338,31 +1240,6 @@ namespace UAS_LabelMachine
|
|
|
pi_inoutno_KeyDown(sender, e2);
|
|
|
}
|
|
|
|
|
|
- private void AutoPrintMidLabel()
|
|
|
- {
|
|
|
- bool FullBox = true;
|
|
|
- //判断所有盒号未该盒的是否勾选已采集
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- //if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
- //{
|
|
|
- // if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
|
|
|
- // FullBox = false;
|
|
|
- //}
|
|
|
- }
|
|
|
- //如果当前箱号已经装满了
|
|
|
- if (FullBox)
|
|
|
- {
|
|
|
- if (MidLabelCombox.SelectedValue != null)
|
|
|
- {
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id, 0);
|
|
|
- }
|
|
|
- else
|
|
|
- MessageBox.Show("未维护中盒模板", "提示");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 勾选的时候自动打印
|
|
|
/// </summary>
|
|
|
@@ -1831,5 +1708,64 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
LoadGridData(sender, e);
|
|
|
}
|
|
|
+
|
|
|
+ private void Pack_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_outboxcode2", "select");
|
|
|
+ string Prefix = "";
|
|
|
+ string Suffix = "";
|
|
|
+ int CurrentMaxNum = 0;
|
|
|
+ int Length = 0;
|
|
|
+ int Radix = 0;
|
|
|
+ GetBarCodeRule(out Prefix, out Suffix, out CurrentMaxNum, out Length, out Radix);
|
|
|
+ if (Radix > 0)
|
|
|
+ {
|
|
|
+ //生成中盒条码
|
|
|
+ int pib_outboxcode1 = 0;
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ List<string> MidBoxCode = new List<string>();
|
|
|
+ List<string> PIBID = new List<string>();
|
|
|
+ List<string> PIBOUTBOXCODE1 = new List<string>();
|
|
|
+ DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' order by to_number(pib_id)", "select");
|
|
|
+ //如果不是10的整数倍则为尾盒
|
|
|
+ for (int j = 0; j < dt1.Rows.Count; j++)
|
|
|
+ {
|
|
|
+ if (j % 10 == 0)
|
|
|
+ {
|
|
|
+ pib_outboxcode1 = pib_outboxcode1 + 1;
|
|
|
+ MaxNum = MaxNum + 1;
|
|
|
+ }
|
|
|
+ string serialcode = BaseUtil.DToAny(MaxNum, Radix);
|
|
|
+ for (int k = serialcode.ToString().Length; k < NumLength; k++)
|
|
|
+ {
|
|
|
+ serialcode = "0" + serialcode;
|
|
|
+ }
|
|
|
+ MidBoxCode.Add(Prefix + serialcode + Suffix);
|
|
|
+ PIBID.Add(dt1.Rows[j]["pib_id"].ToString());
|
|
|
+ PIBOUTBOXCODE1.Add(pib_outboxcode1.ToString());
|
|
|
+ }
|
|
|
+ dh.BatchInsert("update prodiobarcode set pib_custmidboxcode=:pib_custmidboxcode,pib_outboxcode1=:pib_outboxcode1 where pib_id=:pib_id and pib_custmidboxcode is null", new string[] { "pib_custmidboxcode", "pib_outboxcode1", "pib_id" }, MidBoxCode.ToArray(), PIBOUTBOXCODE1.ToArray(), PIBID.ToArray());
|
|
|
+ }
|
|
|
+ MaxNum = MaxNum + 1;
|
|
|
+ //生成外箱条码
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ List<string> OutBoxCode = new List<string>();
|
|
|
+ List<string> PIBOUTBOXCODE2 = new List<string>();
|
|
|
+ string serialcode = BaseUtil.DToAny(MaxNum, Radix);
|
|
|
+ for (int k = serialcode.ToString().Length; k < NumLength; k++)
|
|
|
+ {
|
|
|
+ serialcode = "0" + serialcode;
|
|
|
+ }
|
|
|
+ OutBoxCode.Add(Prefix + serialcode + Suffix);
|
|
|
+ PIBOUTBOXCODE2.Add(dt.Rows[i]["pib_outboxcode2"].ToString());
|
|
|
+ MaxNum = MaxNum + 1;
|
|
|
+ dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_outboxcode2=:pib_outboxcode2 and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBOUTBOXCODE2.ToArray());
|
|
|
+ }
|
|
|
+ dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'");
|
|
|
+ }
|
|
|
+ LoadGridData(sender, e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|