|
|
@@ -20,16 +20,24 @@ namespace UAS_MES.PublicMethod
|
|
|
|
|
|
public Print() { }
|
|
|
|
|
|
- public static void CodeSoft(string iCaller, Document doc, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum)
|
|
|
+ public static bool CodeSoft(string iCaller, Document doc, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum, string MakeCode, string ProdCode, string LabelType, string IfRePrint, out string ErrorMessage)
|
|
|
{
|
|
|
+ ErrorMessage = "";
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select lpl_id from labelprintlog where lpl_value='" + SnCode + "' and lpl_makecode='" + MakeCode + "' and lpl_type='" + LabelType + "' and lpl_stepcode='" + User.CurrentStepCode + "'", "select");
|
|
|
+ //如果已经打印过了,则不允许再打印
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ ErrorMessage = SnCode + LabelType + "已打印";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
//打开模板路径
|
|
|
//查询模板对应的取值SQL和参数名称
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_id='" + LaID + "'", "select");
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_id='" + LaID + "'", "select");
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
if (doc == null)
|
|
|
{
|
|
|
MessageBox.Show("打印文件不存在");
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
//执行全部的SQL
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
@@ -59,7 +67,7 @@ namespace UAS_MES.PublicMethod
|
|
|
doc.Variables.FormVariables.Item(k + 1).Value = Param.Rows[0][0].ToString();
|
|
|
}
|
|
|
//使用SN开头的参数赋值SN1,SN2,SN3等参数
|
|
|
- if (doc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper() + (j+1))
|
|
|
+ if (doc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper() + (j + 1))
|
|
|
{
|
|
|
doc.Variables.FormVariables.Item(k + 1).Value = Param.Rows[j][0].ToString();
|
|
|
}
|
|
|
@@ -90,6 +98,8 @@ namespace UAS_MES.PublicMethod
|
|
|
doc.Printer.SwitchTo(PrinterName);
|
|
|
doc.PrintDocument(PrintNum);
|
|
|
LogicHandler.DoCommandLog(iCaller, User.UserCode, "", User.UserLineCode, User.UserSourceCode, "打印", "成功打印", SnCode, "");
|
|
|
+ LogicHandler.doLabelPrintLog(SnCode, LabelType, MakeCode, ProdCode, User.UserSourceCode, User.CurrentStepCode, IfRePrint, User.UserCode);
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|