瀏覽代碼

修改打印不能重复

章政 8 年之前
父節點
當前提交
5385d32d30

+ 10 - 3
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -142,11 +142,18 @@ namespace UAS_MES.Make
                                 OperateResult.AppendText(">>请输入SN\n", Color.Black);
                                 return;
                             }
+                            OperateResult.AppendText("<<序列号:" + sncode.Text + "\n", Color.Black);
                             //按照打印张数打印
                             doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
-                            Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text));
-                            //提示用户打印成功
-                            OperateResult.AppendText(">>序列号:" + sncode.Text + "打印成功\n", Color.Green);
+                            if (Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, ma_prodcode.Text, "机身标", "0", out oErrorMessage))
+                            {
+                                //提示用户打印成功
+                                OperateResult.AppendText(">>序列号:" + sncode.Text + "打印成功\n", Color.Green);
+                            }
+                            else
+                            {
+                                OperateResult.AppendText(oErrorMessage + "\n", Color.Red);
+                            }
                             //记录日志
                             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "机身标打印", "机身标打印成功", sncode.Text, "");
                             //更新打印的数据

+ 8 - 2
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -123,9 +123,15 @@ namespace UAS_MES.Make
                 if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
                 {
                     dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
-                    OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
-                    Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text));
+                    if (Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+                    {
+                        OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
+                    }
+                    else
+                    {
+                        OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
+                    }
                     pa_outboxcode.SelectAll();
                     pa_outboxcode.Focus();
                 }

+ 14 - 4
UAS-MES/PublicMethod/Print.cs

@@ -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;
         }
     }
 }