Browse Source

标签打印方法BUG处理

Hcsy 8 years ago
parent
commit
98347f03fd
1 changed files with 10 additions and 6 deletions
  1. 10 6
      UAS-MES/PublicMethod/Print.cs

+ 10 - 6
UAS-MES/PublicMethod/Print.cs

@@ -6,6 +6,7 @@ using System.IO;
 using UAS_MES.Entity;
 using System.Text.RegularExpressions;
 using System.Windows.Forms;
+using System;
 
 namespace UAS_MES.PublicMethod
 {
@@ -109,7 +110,7 @@ namespace UAS_MES.PublicMethod
             //doc.Save();
             doc.Printer.SwitchTo(PrinterName);
             doc.PrintDocument(PrintNum);
-          //doc.Close();
+            //doc.Close();
             LogicHandler.DoCommandLog(iCaller, User.UserCode, "", User.UserLineCode, User.UserSourceCode, "打印", "成功打印", SnCode, "");
             for (int k = 0; k < doc.Variables.FormVariables.Count; k++)
             {
@@ -128,7 +129,7 @@ namespace UAS_MES.PublicMethod
             {
                 if (LabelType == "卡通箱标" || LabelType == "大箱标" || LabelType == "栈板标")
                 {
-                    dt = (DataTable)dh.ExecuteSql("select lpl_id from labelprintlog where lpl_value='" + SnCode + "' and lpl_type='" + LabelType + "' and lpl_stepcode='" + User.CurrentStepCode + "'", "select");
+                       dt = (DataTable)dh.ExecuteSql("select lpl_id from labelprintlog where lpl_value='" + SnCode + "' and lpl_type='" + LabelType + "' and lpl_stepcode='" + User.CurrentStepCode + "'", "select");
                 }
                 else
                 {
@@ -141,7 +142,7 @@ namespace UAS_MES.PublicMethod
                     return false;
                 }
             }
-            string filelastwritetime = dh.getFieldDataByCondition("label", "la_lastwritetime", "la_id = '"+ LaID + "'").ToString();
+            string filelastwritetime = dh.getFieldDataByCondition("label", "la_lastwritetime", "la_id = '" + LaID + "'").ToString();
             FileInfo PrintFile = new FileInfo(LabelName);
             //打开模板路径
             //查询模板对应的取值SQL和参数名称
@@ -152,14 +153,17 @@ namespace UAS_MES.PublicMethod
                 MessageBox.Show("打印文件不存在");
                 return false;
             }
-            if (PrintFile.LastWriteTime.ToString() != filelastwritetime)
+            string filechangetime = PrintFile.LastWriteTime.ToString();
+            if (filechangetime != filelastwritetime)
             {
                 lbl.Quit();
                 lbl = new ApplicationClass();
                 BaseUtil.WriteLbl();
-                dh.UpdateByCondition("label", "la_lastwritetime = to_date('"+PrintFile.LastWriteTime.ToString()+"', 'yyyy-mm-dd hh24:mi:ss') ", "la_id = '"+ LaID + "'");
+                filechangetime = PrintFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss");
+                string update = "la_lastwritetime = to_date((regexp_substr('"+ filechangetime + "','\\d+.+\\d+')),'yyyy-mm-dd hh24:mi:ss')";
+                dh.UpdateByCondition("label", update, "la_id = '" + LaID + "'");
             }
-            doc = lbl.Documents.Open(LabelName,true);
+            doc = lbl.Documents.Open(LabelName, true);
             //执行全部的SQL
             for (int i = 0; i < dt.Rows.Count; i++)
             {