|
|
@@ -1233,7 +1233,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
catch (Exception ex) { LogManager.DoLog(ex.Message); }
|
|
|
}
|
|
|
- if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue !=null&& LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
|
|
|
+ if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue != null && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
|
|
|
{
|
|
|
//判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
@@ -1437,6 +1437,9 @@ namespace UAS_LabelMachine
|
|
|
//中盒号所在的行
|
|
|
int MidLabelRowIndex = 0;
|
|
|
//查找是否存在该中盒号
|
|
|
+ List<int> MidRowIndex = new List<int>();
|
|
|
+ //缓存中盒数据
|
|
|
+ List<string> MidBoxCode = new List<string>();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (MidLabelNum.Text == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
@@ -1444,12 +1447,17 @@ namespace UAS_LabelMachine
|
|
|
//找到了输入的中盒号停止循环
|
|
|
FindMidLabel = true;
|
|
|
MidLabelRowIndex = i;
|
|
|
- break;
|
|
|
+ }
|
|
|
+ //设置所有的中盒号的索引
|
|
|
+ if (!MidBoxCode.Contains(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
+ {
|
|
|
+ MidBoxCode.Add(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
+ MidRowIndex.Add(i);
|
|
|
}
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- MidBoxCodePrint(la_id, MidLabelRowIndex);
|
|
|
+ MidBoxCodePrint(la_id, MidLabelRowIndex, MidRowIndex.ToArray());
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该中盒号!");
|
|
|
}
|
|
|
@@ -1543,6 +1551,11 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex)
|
|
|
{
|
|
|
+ if (MidBoxCacheData.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ MidIDAndOutboxcode.Add(LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
+ GetMidBoxData();
|
|
|
+ }
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
string[] arg = MidBoxArgument.ToArray();
|
|
|
for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
@@ -1608,6 +1621,82 @@ namespace UAS_LabelMachine
|
|
|
MidDoc.PrintDocument();
|
|
|
}
|
|
|
|
|
|
+ private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
+ {
|
|
|
+ if (MidBoxCacheData.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ MidIDAndOutboxcode.Clear();
|
|
|
+ for (int i = 0; i < midindex.Length; i++)
|
|
|
+ {
|
|
|
+ MidIDAndOutboxcode.Add(LabelInf.Rows[midindex[i]].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[midindex[i]].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
+ }
|
|
|
+ GetMidBoxData();
|
|
|
+ }
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
+ string[] arg = MidBoxArgument.ToArray();
|
|
|
+ for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ {
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ //名称相等的时候,取SQL进行值的查询
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.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();
|
|
|
+ //获取打印执行的SQL
|
|
|
+ string sql = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //获取打印执行的SQL
|
|
|
+ if (sql.IndexOf("{") == 0)
|
|
|
+ {
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
+ LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1=" + pib_outboxcode1);
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
|
|
|
+ }
|
|
|
+ else if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
+ {
|
|
|
+ if (dr.Length > 0)
|
|
|
+ {
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存参数打印
|
|
|
+ MidDoc.Save();
|
|
|
+ MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
+ MidDoc.PrintDocument();
|
|
|
+ }
|
|
|
+
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex, string HandPrint)
|
|
|
{
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|