|
|
@@ -57,10 +57,6 @@ namespace UAS_LabelMachine
|
|
|
/// 当前品牌
|
|
|
/// </summary>
|
|
|
string PI_ID;
|
|
|
- /// <summary>
|
|
|
- /// 当前扫描的所在行
|
|
|
- /// </summary>
|
|
|
- int CurrentRowIndex = 0;
|
|
|
|
|
|
bool logout = false;
|
|
|
|
|
|
@@ -133,6 +129,16 @@ namespace UAS_LabelMachine
|
|
|
int OutNumLength = 0;
|
|
|
int OutRadix = 0;
|
|
|
|
|
|
+ string SingleSQL = "";
|
|
|
+
|
|
|
+ string MidSQL = "";
|
|
|
+
|
|
|
+ string OutSQL = "";
|
|
|
+
|
|
|
+ DataTable Attach;
|
|
|
+
|
|
|
+ private bool EnablePrint = true;
|
|
|
+
|
|
|
public UAS_出货标签打印(string Master)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -252,6 +258,21 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void CollectInputData()
|
|
|
{
|
|
|
+ if (Input.Text == "SC")
|
|
|
+ {
|
|
|
+ EnablePrint = !EnablePrint;
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ SetPrintStatus_label.ForeColor = Color.Green;
|
|
|
+ SetPrintStatus_label.Text = "可打印";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetPrintStatus_label.ForeColor = Color.Red;
|
|
|
+ SetPrintStatus_label.Text = "暂停打印";
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
Dictionary<string, string> Data = new Dictionary<string, string>();
|
|
|
string[] SplitData = Input.Text.Split('*');
|
|
|
if (SplitData.Length < 6)
|
|
|
@@ -380,8 +401,8 @@ namespace UAS_LabelMachine
|
|
|
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_custoutboxcode,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["LOTNO"] + "','" + Data["DATECODE"] + "','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,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 + "'");
|
|
|
+ sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["DATECODE"] + "','" + Data["LOTNO"] + "','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,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.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (SingleMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + SinglePrefix + "'");
|
|
|
@@ -394,7 +415,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- GetSingleBoxData();
|
|
|
AutoPrintSingleLabel(PIBID);
|
|
|
}
|
|
|
//采集后重新计数,自动跳到下一行
|
|
|
@@ -402,12 +422,24 @@ namespace UAS_LabelMachine
|
|
|
CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
|
|
|
if (CollectQty == int.Parse(CurrentPrCount))
|
|
|
{
|
|
|
+ for (int i = 0; i < GridPrcode.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString() == CurrentPrCode)
|
|
|
+ {
|
|
|
+ if (int.Parse(GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString()) > int.Parse(CurrentPDNO))
|
|
|
+ {
|
|
|
+ GridPrcode.Rows[i].Selected = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
|
|
|
if (dsc[0].Index + 1 < GridPrcode.Rows.Count)
|
|
|
{
|
|
|
GridPrcode.Rows[dsc[0].Index + 1].Selected = true;
|
|
|
}
|
|
|
}
|
|
|
+ OutBoxNum_Click(new object(), new EventArgs());
|
|
|
}
|
|
|
|
|
|
private void AutoPrintSingleLabel(string[] pib_id)
|
|
|
@@ -418,19 +450,19 @@ namespace UAS_LabelMachine
|
|
|
for (int i = 0; i < pib_id.Length; i++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id[i] + "'"), "select");
|
|
|
for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- 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();
|
|
|
+
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ 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:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",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());
|
|
|
//保存参数打印
|
|
|
@@ -465,7 +497,6 @@ namespace UAS_LabelMachine
|
|
|
private void GetInOutInfAndLabelFile()
|
|
|
{
|
|
|
ComBoxClickChangeLabelDoc = false;
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
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 ");
|
|
|
sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
|
|
|
@@ -501,8 +532,16 @@ namespace UAS_LabelMachine
|
|
|
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);
|
|
|
+ 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 + ") order by lp_detno", "select");
|
|
|
+ //SingleLabelParam.Merge(Attach);
|
|
|
+ SingleSQL = "select * from ";
|
|
|
+ for (int i = 0; i < SingleLabelParam.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (i != SingleLabelParam.Rows.Count - 1)
|
|
|
+ SingleSQL += "(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + "),";
|
|
|
+ else
|
|
|
+ SingleSQL += "(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + ")";
|
|
|
+ }
|
|
|
}
|
|
|
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 ");
|
|
|
@@ -539,7 +578,16 @@ namespace UAS_LabelMachine
|
|
|
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 = (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 + ") order by lp_detno", "select");
|
|
|
+ MidSQL = "select * from ";
|
|
|
+ for (int i = 0; i < MidLabelParam.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (i != MidLabelParam.Rows.Count - 1)
|
|
|
+ MidSQL += "(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),";
|
|
|
+ else
|
|
|
+ MidSQL += "(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")";
|
|
|
+ }
|
|
|
+
|
|
|
MidLabelParam.Merge(Attach);
|
|
|
}
|
|
|
//缓存中盒参数
|
|
|
@@ -578,8 +626,15 @@ namespace UAS_LabelMachine
|
|
|
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);
|
|
|
+ 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 + ") order by lp_detno", "select");
|
|
|
+ OutSQL = "select * from ";
|
|
|
+ for (int i = 0; i < OutLabelParam.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (i != OutLabelParam.Rows.Count - 1)
|
|
|
+ OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
|
|
|
+ else
|
|
|
+ OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
|
|
|
+ }
|
|
|
}
|
|
|
//缓存外箱参数
|
|
|
ComBoxClickChangeLabelDoc = true;
|
|
|
@@ -618,7 +673,7 @@ namespace UAS_LabelMachine
|
|
|
SingleID.Clear();
|
|
|
Input.Focus();
|
|
|
//获取外箱数据
|
|
|
- OutBoxNum_Click(sender, new EventArgs());
|
|
|
+ Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
thread = new Thread(GetInOutInfAndLabelFile);
|
|
|
stw = new SetLoadingWindow(thread, "正在获取打印标签");
|
|
|
BaseUtil.SetFormCenter(stw);
|
|
|
@@ -651,11 +706,6 @@ namespace UAS_LabelMachine
|
|
|
MessageBox.Show("中盘标签未维护参数", "提示");
|
|
|
}
|
|
|
}
|
|
|
- string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- string cl_labelname = SingleLabelCombox.Text;
|
|
|
- string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
- //查询该模板维护的所有参数
|
|
|
- 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");
|
|
|
if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
{
|
|
|
//每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
@@ -709,52 +759,51 @@ namespace UAS_LabelMachine
|
|
|
if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
|
|
|
{
|
|
|
CheckedRowCount = CheckedRowCount + 1;
|
|
|
- CurrentRowIndex = i;
|
|
|
//以标签模板的参数为基准,循环取数
|
|
|
- //try
|
|
|
- //{
|
|
|
- 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 k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ try
|
|
|
{
|
|
|
- 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[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++)
|
|
|
{
|
|
|
- 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();
|
|
|
+ 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);
|
|
|
}
|
|
|
- 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();
|
|
|
- }
|
|
|
- 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())
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
+ //保存参数打印
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ SingleDoc.PrintDocument();
|
|
|
+ }
|
|
|
+ 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, CurrentRowIndex);
|
|
|
+ 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());
|
|
|
@@ -762,8 +811,6 @@ namespace UAS_LabelMachine
|
|
|
BaseUtil.CleanDataTable(MidBoxCacheData);
|
|
|
if (CheckedRowCount == 0)
|
|
|
MessageBox.Show("未勾选打印明细!", "提示");
|
|
|
- else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
|
|
|
- CurrentRowIndex = CurrentRowIndex + 1;
|
|
|
outboxcode1.Clear();
|
|
|
}
|
|
|
else
|
|
|
@@ -1154,60 +1201,49 @@ 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");
|
|
|
- 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);
|
|
|
string[] arg = MidBoxArgument.ToArray();
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
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())
|
|
|
+ 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
|
|
|
{
|
|
|
- //获取对应行的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(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
|
|
|
+ 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(ParamName).Name))
|
|
|
- {
|
|
|
- if (dr.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][MidDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
+ if (dr.Length > 0)
|
|
|
{
|
|
|
- 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();
|
|
|
+ MidDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][MidDoc.Variables.FreeVariables.Item(ParamName).Name].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;
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
@@ -1220,7 +1256,6 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
{
|
|
|
-
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
@@ -1272,7 +1307,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
|
|
|
+ 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();
|
|
|
}
|
|
|
@@ -1301,34 +1336,21 @@ namespace UAS_LabelMachine
|
|
|
try
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ 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++)
|
|
|
{
|
|
|
//获取对应行的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
|
|
|
- {
|
|
|
- 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 == "")
|
|
|
- {
|
|
|
- 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)
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
+ if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
|
|
|
{
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
|
|
|
- MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql, "提示");
|
|
|
- return;
|
|
|
+ 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);
|
|
|
}
|
|
|
//保存参数打印
|
|
|
if (EnablePrint)
|
|
|
@@ -1417,33 +1439,6 @@ namespace UAS_LabelMachine
|
|
|
pi_inoutno_KeyDown(sender, e2);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 采集明细切换
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void griddetno_KeyDown(object sender, KeyEventArgs e)
|
|
|
- {
|
|
|
- if (Keys.Enter == e.KeyData)
|
|
|
- {
|
|
|
- bool FindDetno = false;
|
|
|
- for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
- {
|
|
|
- if (LabelInf.Rows[i].Cells["pib_pdno"].Value.ToString() == griddetno.Text)
|
|
|
- {
|
|
|
- FindDetno = true;
|
|
|
- CurrentRowIndex = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!FindDetno)
|
|
|
- {
|
|
|
- MessageBox.Show("不存在未采集的明细序号" + griddetno.Text, "提示");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void AutoPrintMidLabel()
|
|
|
{
|
|
|
bool FullBox = true;
|
|
|
@@ -1462,7 +1457,7 @@ namespace UAS_LabelMachine
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id, CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(la_id, 0);
|
|
|
}
|
|
|
else
|
|
|
MessageBox.Show("未维护中盒模板", "提示");
|
|
|
@@ -1690,22 +1685,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private bool EnablePrint = true;
|
|
|
|
|
|
- private void SetPrintStatus_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- EnablePrint = !EnablePrint;
|
|
|
- if (EnablePrint)
|
|
|
- {
|
|
|
- SetPrintStatus_label.ForeColor = Color.Green;
|
|
|
- SetPrintStatus_label.Text = "可打印";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SetPrintStatus_label.ForeColor = Color.Red;
|
|
|
- SetPrintStatus_label.Text = "暂停打印";
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private void OutBoxNum_Click(object sender, EventArgs e)
|
|
|
{
|