|
|
@@ -44,5 +44,31 @@ namespace UAS_MES.PublicMethod
|
|
|
doc.PrintDocument(PrintNum);
|
|
|
doc.Close();
|
|
|
}
|
|
|
+
|
|
|
+ public static void CodeSoft(ApplicationClass lbl, string LabelName, string LabelCode, string PrinterName, string SnCode)
|
|
|
+ {
|
|
|
+ //打开模板路径
|
|
|
+ doc = lbl.Documents.Open(ftpOperater.DownLoadTo + LabelName);
|
|
|
+ //查询模板对应的取值SQL和参数名称
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_code='" + LabelCode + "'", "select");
|
|
|
+ //比对模板维护的参数和在系统中维护的参数,名称对应进行SQL取值赋给变量
|
|
|
+ for (int i = 0; i < doc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < dt.Rows.Count; j++)
|
|
|
+ {
|
|
|
+ if (doc.Variables.FreeVariables.Item(i + 1).Name == dt.Rows[j]["lp_name"].ToString())
|
|
|
+ {
|
|
|
+ string sql = dt.Rows[j]["lp_sql"].ToString();
|
|
|
+ sql = sql.Substring(0, sql.IndexOf("{")) + "'" + SnCode + "'";
|
|
|
+ doc.Variables.FreeVariables.Item(i + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存本次赋值进行打印
|
|
|
+ doc.Save();
|
|
|
+ doc.Printer.SwitchTo(PrinterName);
|
|
|
+ doc.PrintDocument();
|
|
|
+ doc.Close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|