|
|
@@ -376,7 +376,7 @@ namespace UAS_LabelMachine
|
|
|
int CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
|
|
|
if (CollectQty + CollectNum > int.Parse(CurrentPrCount))
|
|
|
{
|
|
|
- MessageBox.Show("物料" + Data["PRCODE"] + "采集后【超出】数量", "提示");
|
|
|
+ MessageBox.Show("物料" + Data["PRCODE"] + "采集后数量为" + (CollectQty + CollectNum) + ",【超出】本行出货数量" + CurrentPrCount, "提示");
|
|
|
return;
|
|
|
}
|
|
|
List<string> CustBarCode = new List<string>();
|
|
|
@@ -431,9 +431,10 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
LoadGridData(new object(), new EventArgs());
|
|
|
//加载完数据之后进行容量的判断
|
|
|
- if (LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length > OutboxCapacity.Value)
|
|
|
+ int BoxNum = LabelInfDataTable.Select("pib_outboxcode2='" + OutBoxNum.Text + "'").Length;
|
|
|
+ if (BoxNum > OutboxCapacity.Value)
|
|
|
{
|
|
|
- MessageBox.Show("箱号" + OutBoxNum.Text + "超出容量", "提示");
|
|
|
+ MessageBox.Show("箱号【" + OutBoxNum.Text + "】超出容量,当前已采集" + BoxNum, "提示");
|
|
|
}
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
@@ -469,30 +470,31 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void AutoPrintSingleLabel(string[] pib_id)
|
|
|
{
|
|
|
- //用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- string[] arg = SingleBoxArgument.ToArray();
|
|
|
- StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int i = 0; i < pib_id.Length; i++)
|
|
|
+ if (EnablePrint)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id[i] + "'"), "select");
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ //用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
+ string[] arg = SingleBoxArgument.ToArray();
|
|
|
+ StringBuilder ParamLog = new StringBuilder();
|
|
|
+ for (int i = 0; i < pib_id.Length; i++)
|
|
|
{
|
|
|
- string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
-
|
|
|
- SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id[i] + "'"), "select");
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ if (drow.Length > 0)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ ParamLog.AppendLine("pib_id:" + pib_id[i] + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
}
|
|
|
- ParamLog.AppendLine("pib_id:" + pib_id[i] + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
- }
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
+ //保存参数打印
|
|
|
+
|
|
|
SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleDoc.PrintDocument();
|
|
|
Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
|
|
|
@@ -720,131 +722,131 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void SingleBoxPrint()
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- if (SingleDoc.Variables.FreeVariables.Count == 0) { }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- MessageBox.Show("单盘标签未维护参数", "提示");
|
|
|
- }
|
|
|
- if (MidLabelAutoPrint.Checked)
|
|
|
+ if (EnablePrint)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (MidDoc.Variables.FreeVariables.Count == 0) { }
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Count == 0) { }
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
- MessageBox.Show("中盘标签未维护参数", "提示");
|
|
|
+ MessageBox.Show("单盘标签未维护参数", "提示");
|
|
|
}
|
|
|
- }
|
|
|
- if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
- {
|
|
|
- //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
- MidIDAndOutboxcode.Clear();
|
|
|
- SingleID.Clear();
|
|
|
- //获取全部的中盒号
|
|
|
- Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
|
|
|
- //判断所有盒号为该盒的是否勾选已采集
|
|
|
- outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
+ if (MidLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
- SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "true")
|
|
|
+ try
|
|
|
{
|
|
|
- //如果不存在中盒号则进行添加
|
|
|
- if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- {
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- }
|
|
|
+ if (MidDoc.Variables.FreeVariables.Count == 0) { }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ MessageBox.Show("中盘标签未维护参数", "提示");
|
|
|
}
|
|
|
}
|
|
|
- if (SingleID.ToArray().Length == 0)
|
|
|
- {
|
|
|
- MessageBox.Show("选择的行未勾选采集或者已打印", "提示");
|
|
|
- return;
|
|
|
- }
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
+ if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
{
|
|
|
- if (i + 1 < LabelInf.RowCount)
|
|
|
+ //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
+ MidIDAndOutboxcode.Clear();
|
|
|
+ SingleID.Clear();
|
|
|
+ //获取全部的中盒号
|
|
|
+ Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
|
|
|
+ //判断所有盒号为该盒的是否勾选已采集
|
|
|
+ outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
+ for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
{
|
|
|
- //如果本行的中盒号和下一行不相等的话
|
|
|
- if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
+ if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
+ SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
+ if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "true")
|
|
|
{
|
|
|
- if (!outboxcode1.ContainsKey(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- outboxcode1.Add(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
+ //如果不存在中盒号则进行添加
|
|
|
+ if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
+ {
|
|
|
+ MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //用于判断用户是否勾选了行
|
|
|
- int CheckedRowCount = 0;
|
|
|
- string[] arg = SingleBoxArgument.ToArray();
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- //勾选了并且未打印
|
|
|
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString().ToLower() != "true")
|
|
|
+ if (SingleID.ToArray().Length == 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("选择的行未勾选采集或者已打印", "提示");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
- CheckedRowCount = CheckedRowCount + 1;
|
|
|
- //以标签模板的参数为基准,循环取数
|
|
|
- try
|
|
|
+ if (i + 1 < LabelInf.RowCount)
|
|
|
{
|
|
|
- string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id + "'"), "select");
|
|
|
- StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ //如果本行的中盒号和下一行不相等的话
|
|
|
+ if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString())
|
|
|
{
|
|
|
- string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
-
|
|
|
- SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
- {
|
|
|
- DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- ParamLog.AppendLine("pib_id:" + pib_id + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
+ if (!outboxcode1.ContainsKey(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
+ outboxcode1.Add(LabelInf.Rows[i + 1].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
}
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //用于判断用户是否勾选了行
|
|
|
+ int CheckedRowCount = 0;
|
|
|
+ string[] arg = SingleBoxArgument.ToArray();
|
|
|
+ for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
+ {
|
|
|
+ //勾选了并且未打印
|
|
|
+ if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString().ToLower() != "true")
|
|
|
+ {
|
|
|
+ CheckedRowCount = CheckedRowCount + 1;
|
|
|
+ //以标签模板的参数为基准,循环取数
|
|
|
+ try
|
|
|
{
|
|
|
+ string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id + "'"), "select");
|
|
|
+ StringBuilder ParamLog = new StringBuilder();
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ {
|
|
|
+ string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ if (drow.Length > 0)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ ParamLog.AppendLine("pib_id:" + pib_id + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
+ }
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
+ //保存参数打印
|
|
|
SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleDoc.PrintDocument();
|
|
|
Properties.Settings.Default.SPrinter = SingleLabelPrinter.Text;
|
|
|
Properties.Settings.Default.Save();
|
|
|
- }
|
|
|
- if (MidLabelAutoPrint.Checked)
|
|
|
- {
|
|
|
- //判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
- 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())
|
|
|
+ if (MidLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
|
|
|
+ //判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
+ 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())
|
|
|
{
|
|
|
- if (MidLabelCombox.SelectedValue != null)
|
|
|
+ if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
|
|
|
{
|
|
|
- string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id_mid, i);
|
|
|
+ if (MidLabelCombox.SelectedValue != null)
|
|
|
+ {
|
|
|
+ string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
+ MidBoxCodePrint(la_id_mid, i);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //勾选为已打印
|
|
|
+ LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
|
|
|
}
|
|
|
- //勾选为已打印
|
|
|
- LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
|
|
|
+ catch (Exception ex) { LogManager.DoLog(ex.StackTrace); }
|
|
|
}
|
|
|
- catch (Exception ex) { LogManager.DoLog(ex.StackTrace); }
|
|
|
}
|
|
|
+ dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
|
|
|
+ if (CheckedRowCount == 0)
|
|
|
+ MessageBox.Show("未勾选打印明细!", "提示");
|
|
|
+ outboxcode1.Clear();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("此模板尚未维护参数或不存在打印明细", "提示");
|
|
|
+ return;
|
|
|
}
|
|
|
- dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
|
|
|
- if (CheckedRowCount == 0)
|
|
|
- MessageBox.Show("未勾选打印明细!", "提示");
|
|
|
- outboxcode1.Clear();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("此模板尚未维护参数或不存在打印明细", "提示");
|
|
|
- return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1069,37 +1071,37 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex)
|
|
|
{
|
|
|
- string[] arg = MidBoxArgument.ToArray();
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- 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");
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ string[] arg = MidBoxArgument.ToArray();
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ //名称相等的时候,取SQL进行值的查询
|
|
|
+ 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");
|
|
|
+ //获取打印执行的SQL
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
+ try
|
|
|
{
|
|
|
- DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ if (drow.Length > 0)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_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;
|
|
|
}
|
|
|
- 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;
|
|
|
}
|
|
|
- }
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
+ //保存参数打印
|
|
|
MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
MidDoc.PrintDocument();
|
|
|
Properties.Settings.Default.MPrinter = MidLabelPrinter.Text;
|
|
|
@@ -1109,73 +1111,74 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- 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();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
+ 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();
|
|
|
//获取打印执行的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
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
+ try
|
|
|
{
|
|
|
- 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"))
|
|
|
+ //获取打印执行的SQL
|
|
|
+ if (sql.IndexOf("{") == 0)
|
|
|
{
|
|
|
- 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();
|
|
|
+ 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 (sql.ToLower().Contains("pib_qty"))
|
|
|
+ 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"))
|
|
|
{
|
|
|
- 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";
|
|
|
+ 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
|
|
|
{
|
|
|
- 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 + "'";
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ if (drow.Length > 0)
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
}
|
|
|
- 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);
|
|
|
}
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
- {
|
|
|
- DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_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;
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
+ //保存参数打印
|
|
|
+
|
|
|
MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
MidDoc.PrintDocument();
|
|
|
Properties.Settings.Default.MPrinter = MidLabelPrinter.Text;
|
|
|
@@ -1188,36 +1191,36 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void OutBoxCodePrint(string la_id, int rowindex)
|
|
|
{
|
|
|
- try
|
|
|
+ if (EnablePrint)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- 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");
|
|
|
- for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
+ try
|
|
|
{
|
|
|
- //获取对应行的pib_id
|
|
|
- string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ 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");
|
|
|
+ for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- DataRow[] drow = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ //获取对应行的pib_id
|
|
|
+ string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ if (drow.Length > 0)
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
}
|
|
|
- LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
- }
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
+ //保存参数打印
|
|
|
OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
OutBoxDoc.PrintDocument();
|
|
|
Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
|
|
|
Properties.Settings.Default.Save();
|
|
|
+ LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
}
|
|
|
- LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
+ catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
|
|
|
}
|
|
|
- catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
|
|
|
}
|
|
|
|
|
|
private void CleanDetail_Click(object sender, EventArgs e)
|