|
|
@@ -394,7 +394,8 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
-
|
|
|
+ GetSingleBoxData();
|
|
|
+ AutoPrintSingleLabel(PIBID);
|
|
|
}
|
|
|
//采集后重新计数,自动跳到下一行
|
|
|
collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
|
|
|
@@ -405,47 +406,39 @@ namespace UAS_LabelMachine
|
|
|
if (dsc[0].Index + 1 < GridPrcode.Rows.Count)
|
|
|
{
|
|
|
GridPrcode.Rows[dsc[0].Index + 1].Selected = true;
|
|
|
- for (int i = 0; i < dsc.Count; i++)
|
|
|
- {
|
|
|
- dsc[i].Selected = false;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AutoPrintSingleLabel(string la_id, string LabelUrl)
|
|
|
+ private void AutoPrintSingleLabel(string[] pib_id)
|
|
|
{
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
string[] arg = SingleBoxArgument.ToArray();
|
|
|
StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ for (int i = 0; i < pib_id.Length; i++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
|
|
|
+ DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id[i]);
|
|
|
+ string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+ if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(ParamName).Name))
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ DataRow[] drow = SingleLabelParam.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:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
+ }
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
+ //保存参数打印
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ SingleDoc.PrintDocument();
|
|
|
}
|
|
|
- }
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
- //保存参数打印
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
- SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
- SingleDoc.PrintDocument();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -496,12 +489,20 @@ namespace UAS_LabelMachine
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
{
|
|
|
SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
|
|
|
- SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
- SingleLabelParam.Merge(Attach);
|
|
|
+ string ParamCondition = "";
|
|
|
for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
|
|
|
{
|
|
|
- SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
|
|
|
+ if (i != SingleDoc.Variables.FreeVariables.Count - 1)
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
|
|
|
+ }
|
|
|
}
|
|
|
+ SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
|
|
|
+ SingleLabelParam.Merge(Attach);
|
|
|
}
|
|
|
sql.Clear();
|
|
|
sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
|
|
|
@@ -526,7 +527,19 @@ namespace UAS_LabelMachine
|
|
|
if (MidLabelCombox.Text != "")
|
|
|
{
|
|
|
MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
|
|
|
- MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
+ string ParamCondition = "";
|
|
|
+ for (int i = 0; i < MidDoc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ if (i != MidDoc.Variables.FreeVariables.Count - 1)
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + MidDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + MidDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
|
|
|
MidLabelParam.Merge(Attach);
|
|
|
}
|
|
|
//缓存中盒参数
|
|
|
@@ -553,13 +566,23 @@ namespace UAS_LabelMachine
|
|
|
if (OutBoxCombox.Text != "")
|
|
|
{
|
|
|
OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
- OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
+ string ParamCondition = "";
|
|
|
+ for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ if (i != OutBoxDoc.Variables.FreeVariables.Count - 1)
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
|
|
|
OutLabelParam.Merge(Attach);
|
|
|
}
|
|
|
- Input.Focus();
|
|
|
//缓存外箱参数
|
|
|
ComBoxClickChangeLabelDoc = true;
|
|
|
- Parallel.Invoke(GetSingleBoxData, GetMidBoxData);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -661,10 +684,10 @@ namespace UAS_LabelMachine
|
|
|
return;
|
|
|
}
|
|
|
//打印的时候如果不存在数据开始缓存
|
|
|
- if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
- GetSingleBoxData();
|
|
|
- if (MidBoxCacheData.Rows.Count == 0)
|
|
|
- GetMidBoxData();
|
|
|
+ //if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
+ // GetSingleBoxData();
|
|
|
+ //if (MidBoxCacheData.Rows.Count == 0)
|
|
|
+ // GetMidBoxData();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (i + 1 < LabelInf.RowCount)
|
|
|
@@ -693,17 +716,18 @@ namespace UAS_LabelMachine
|
|
|
string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
+ string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+ if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(ParamName).Name))
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
+ DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
if (drow.Length > 0)
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
|
|
|
}
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
}
|
|
|
LogManager.DoLog(ParamLog.ToString());
|
|
|
//保存参数打印
|
|
|
@@ -754,6 +778,9 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void GetSingleBoxData()
|
|
|
{
|
|
|
+ SingleBoxArgument.Clear();
|
|
|
+ SingleBoxCacheData.Clear();
|
|
|
+ BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
if (SingleDoc == null)
|
|
|
return;
|
|
|
for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
@@ -1137,52 +1164,50 @@ namespace UAS_LabelMachine
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
dt.Merge(Attach);
|
|
|
string[] arg = MidBoxArgument.ToArray();
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
+ //名称相等的时候,取SQL进行值的查询
|
|
|
+ string ParamName = MidLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(ParamName).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == 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
|
|
|
{
|
|
|
- //获取对应行的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 (sql.IndexOf("{") == 0)
|
|
|
{
|
|
|
- //获取打印执行的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
|
|
|
+ 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
|
|
|
+ {
|
|
|
+ DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
|
|
|
+ if (arg.Contains(MidDoc.Variables.FreeVariables.Item(ParamName).Name))
|
|
|
{
|
|
|
- DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
|
|
|
- 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();
|
|
|
- }
|
|
|
- }
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
+ if (dr.Length > 0)
|
|
|
{
|
|
|
- DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][MidDoc.Variables.FreeVariables.Item(ParamName).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;
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ {
|
|
|
+ DataRow[] drow = MidLabelParam.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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
@@ -1195,75 +1220,70 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
{
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- 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
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
+ //获取打印执行的SQL
|
|
|
+ if (sql.IndexOf("{") == 0)
|
|
|
{
|
|
|
- //获取对应行的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
|
|
|
+ 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"))
|
|
|
{
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
+ 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"))
|
|
|
{
|
|
|
- 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);
|
|
|
+ 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
|
|
|
{
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
|
|
|
- {
|
|
|
- if (LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value != null)
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_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 (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(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- }
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ 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();
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
+ DataRow[] drow = MidLabelParam.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;
|
|
|
+ }
|
|
|
}
|
|
|
//保存参数打印
|
|
|
if (EnablePrint)
|
|
|
@@ -1278,53 +1298,36 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void OutBoxCodePrint(string la_id, int rowindex)
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
- //用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- dt.Merge(Attach);
|
|
|
try
|
|
|
{
|
|
|
- for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
+ //获取对应行的pib_id
|
|
|
+ string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
+ string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
+ string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
+ //获取打印执行的SQL
|
|
|
+ string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
+ try
|
|
|
{
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- string ExeSQL = "";
|
|
|
- ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
|
|
|
- ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] drow = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (drow.Length > 0)
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
|
|
|
- MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql, "提示");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
|
|
|
+ string ExeSQL = "";
|
|
|
+ ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
|
|
|
+ ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(ExeSQL).ToString();
|
|
|
+ if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- if (LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value != null)
|
|
|
- {
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value.ToString();
|
|
|
- }
|
|
|
+ DataRow[] drow = OutLabelParam.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 + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
|
|
|
+ MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql, "提示");
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
@@ -1387,11 +1390,11 @@ namespace UAS_LabelMachine
|
|
|
private void LoadGridData(object sender, EventArgs e)
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
|
|
|
- sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint");
|
|
|
- sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
|
|
|
- sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
|
|
|
- sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode2),pib_id,pd_prodcode");
|
|
|
+ sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,");
|
|
|
+ sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand,pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,");
|
|
|
+ sql.Append("pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join ");
|
|
|
+ sql.Append("prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode ");
|
|
|
+ sql.Append("left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode2),pib_id,pd_prodcode");
|
|
|
LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
|
|
|
//有数据的话默认取第一条的品牌去取采集策略
|
|
|
@@ -1674,7 +1677,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void LoadPrcodeData()
|
|
|
{
|
|
|
- GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_prodcode,pd_brand,pjd_zxbzs_user,pd_outqty,pd_pdno,pr_unit,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
|
|
|
+ GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_pdno,pd_prodcode,'0' CollectedNum,pd_outqty,pr_unit,pd_brand,pjd_zxbzs_user,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
|
|
|
if (GridPrcode.Rows.Count > 0)
|
|
|
{
|
|
|
CurrentPrCode = GridPrcode.Rows[0].Cells["pd_prodcode"].Value.ToString();
|
|
|
@@ -1687,21 +1690,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void GridPrcode_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
- {
|
|
|
- //用户在重新勾选后重置采集项目的索引
|
|
|
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
|
|
|
- {
|
|
|
- CurrentPrCode = GridPrcode.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
|
|
|
- CurrentZXBZ = GridPrcode.Rows[e.RowIndex].Cells["pjd_zxbzs_user"].Value.ToString();
|
|
|
- CurrentUnit = GridPrcode.Rows[e.RowIndex].Cells["pr_unit"].Value.ToString();
|
|
|
- CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
|
|
|
- CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
|
|
|
- CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
|
|
|
- GridPrcode.Rows[e.RowIndex].Selected = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private bool EnablePrint = true;
|
|
|
|
|
|
private void SetPrintStatus_Click(object sender, EventArgs e)
|
|
|
@@ -1828,5 +1816,27 @@ namespace UAS_LabelMachine
|
|
|
dh.ExecuteSql("delete from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno='" + CurrentPDNO + "' and pib_prodcode='" + CurrentPrCode + "'", "delete");
|
|
|
LoadGridData(sender, new EventArgs());
|
|
|
}
|
|
|
+
|
|
|
+ private void GridPrcode_SelectionChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (GridPrcode.SelectedRows.Count > 0)
|
|
|
+ {
|
|
|
+ DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
|
|
|
+ CurrentPrCode = GridPrcode.Rows[dsc[0].Index].Cells["pd_prodcode"].Value.ToString();
|
|
|
+ CurrentZXBZ = GridPrcode.Rows[dsc[0].Index].Cells["pjd_zxbzs_user"].Value.ToString();
|
|
|
+ CurrentUnit = GridPrcode.Rows[dsc[0].Index].Cells["pr_unit"].Value.ToString();
|
|
|
+ CurrentPDNO = GridPrcode.Rows[dsc[0].Index].Cells["pd_pdno"].Value.ToString();
|
|
|
+ CurrentPrCount = GridPrcode.Rows[dsc[0].Index].Cells["pd_outqty"].Value.ToString();
|
|
|
+ CurrentBrand = GridPrcode.Rows[dsc[0].Index].Cells["pd_brand"].Value.ToString();
|
|
|
+ GridPrcode.Rows[dsc[0].Index].Selected = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GridPrcode_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
|
|
|
+
|
|
|
+ private void GridPrcode_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
+ {
|
|
|
+ GridPrcode.Rows[e.RowIndex].Selected = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|