Переглянути джерело

标签下载修改最后写入时间

shim 8 роки тому
батько
коміт
8392ce4085

+ 4 - 1
UAS-MES/FunctionCode/Make/Make_ColorBoxLabelPrint.cs

@@ -16,6 +16,7 @@ namespace UAS_MES.Make
         DataTable dt;
         LogStringBuilder sql = new LogStringBuilder();
         AutoSizeFormClass asc = new AutoSizeFormClass();
+        System.DateTime[] indate;
         //保存StepProduct查询出来的数据
         DataTable ListA = new DataTable();
         //保存make left join makecraftdetail left join product的数据
@@ -100,7 +101,7 @@ namespace UAS_MES.Make
                         {
                             if (PrintLabel.SelectedValue != null && PrintNum.Text.Trim() != "")
                             {
-                                Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ma_code.Text, int.Parse(PrintNum.Text));
+                                Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ma_code.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
                                 if (LogicHandler.UpdateMakeMessage(sncode.Text, ma_code.Text, "彩盒打印", User.UserSourceCode, User.UserCode, "彩盒打印成功", out ErrorMessage))
                                 {
                                     ErrorMessage = "打印完成,执行更新";
@@ -148,9 +149,11 @@ namespace UAS_MES.Make
             PrintLabel.DisplayMember = "pl_labelname";
             PrintLabel.ValueMember = "pl_labelcode";
             ftpOperater ftp = new ftpOperater();
+            indate = new System.DateTime[dt.Rows.Count];
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
+                indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
             }
         }
 

+ 5 - 1
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.Designer.cs

@@ -143,7 +143,7 @@
             // 
             this.pr_code_label.AutoSize = true;
             this.pr_code_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pr_code_label.Location = new System.Drawing.Point(346, 29);
+            this.pr_code_label.Location = new System.Drawing.Point(346, 26);
             this.pr_code_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pr_code_label.Name = "pr_code_label";
             this.pr_code_label.Size = new System.Drawing.Size(110, 31);
@@ -203,9 +203,11 @@
             // ma_prodcode
             // 
             this.ma_prodcode.AutoSize = true;
+            this.ma_prodcode.CutLength = null;
             this.ma_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ma_prodcode.Location = new System.Drawing.Point(456, 32);
             this.ma_prodcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ma_prodcode.MaximumSize = new System.Drawing.Size(200, 0);
             this.ma_prodcode.Name = "ma_prodcode";
             this.ma_prodcode.Size = new System.Drawing.Size(0, 31);
             this.ma_prodcode.TabIndex = 175;
@@ -214,9 +216,11 @@
             // pr_detail
             // 
             this.pr_detail.AutoSize = true;
+            this.pr_detail.CutLength = null;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.pr_detail.Location = new System.Drawing.Point(793, 32);
             this.pr_detail.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail.MaximumSize = new System.Drawing.Size(200, 0);
             this.pr_detail.Name = "pr_detail";
             this.pr_detail.Size = new System.Drawing.Size(0, 31);
             this.pr_detail.TabIndex = 174;

+ 13 - 9
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -17,6 +17,7 @@ namespace UAS_MES.Make
         DataTable dt;
         LogStringBuilder sql = new LogStringBuilder();
         AutoSizeFormClass asc = new AutoSizeFormClass();
+        System.DateTime[] indate;
         //保存StepProduct查询出来的数据
         //        DataTable ListA = new DataTable();
         //保存make left join makecraftdetail left join product的数据
@@ -80,7 +81,7 @@ namespace UAS_MES.Make
                         {
                             //获取工单的其他信息
                             sql.Clear();
-                            sql.Append("select ma_code,nvl(mcd_okqty,0),ma_prodcode,pr_detail,");
+                            sql.Append("select ma_code,ma_prodcode,pr_detail,");
                             sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on ");
                             sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + oMakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                             mapB = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
@@ -105,17 +106,18 @@ namespace UAS_MES.Make
                         if (PrintLabel.SelectedValue != null)
                         {
                             //按照打印张数打印
-                            Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text));
+                            Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text),indate[PrintLabel.SelectedIndex]);
                             //提示用户打印成功
-                            OperateResult.AppendText(">>打印成功\n", Color.Green);
+                            OperateResult.AppendText(">>序列号"+sncode.Text+"打印成功\n", Color.Green);
                             //更新打印的数据
-                            LogicHandler.UpdateMakeMessage(sncode.Text, ma_code.Text, "机身标打印", User.UserSourceCode, User.UserName, "机身标打印成功", out oErrorMessage);
+                            LogicHandler.UpdateMakeMessage(sncode.Text, ma_code.Text, "机身标打印", User.UserSourceCode, User.UserCode, "机身标打印成功", out oErrorMessage);
                             //清空输入框的值,聚焦
                             sncode.Text = "";
                             sncode.Focus();
                             //刷新打印数量和剩余数量
-                            mcd_remainqty.Text = int.Parse(mcd_remainqty.Text) - 1 + "";
-                            mcd_okqty.Text = int.Parse(mcd_okqty.Text) + 1 + "";
+                            mcd_okqty.Text = int.Parse(mcd_okqty.Text) +1+ "";
+                            dt = (DataTable)dh.ExecuteSql("select ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on mcd_macode=ma_code where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
+                            BaseUtil.SetFormValue(Controls, dt);
 
                             //IF 剩余数=0,则清空form中的数据, 提示用户“工单:xx已经打印完成,>>请输入SN”, 清空mapB,listC 中的数据
                             if (int.Parse(mcd_remainqty.Text) == 0)
@@ -133,7 +135,7 @@ namespace UAS_MES.Make
                         //标签为空
                         else
                         {
-                            OperateResult.AppendText(">>无可用标签\n", Color.Red);
+                            OperateResult.AppendText(">>产品编号:"+ ma_prodcode .Text+ "未维护机身标签\n", Color.Red);
                             sncode.Text = "";
                         }
                     }
@@ -151,19 +153,21 @@ namespace UAS_MES.Make
         }
         private void pr_code_TextChanged(object sender, EventArgs e)
         {
-            dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode,to_char(nvl(pl_indate,sysdate),'YYYY-MM-DD HH24:Mi:SS') pl_indate,pl_labelurl from productlabel where pl_prodcode='" + ma_prodcode.Text + "'and PL_LABELTYPE='机身标' order by pl_isdefault desc", "select");
+            dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode,pl_indate,pl_labelurl from productlabel where pl_prodcode='" + ma_prodcode.Text + "'and PL_LABELTYPE='机身标' order by pl_isdefault desc", "select");
             if (dt.Rows.Count == 0)
             {
-                OperateResult.AppendText(">>该序列号对应的产品未维护机身标标签模板\n", Color.Red);
+                OperateResult.AppendText(">>产品编号:"+ma_prodcode.Text+"未维护机身标标签模板\n", Color.Red);
             }
             PrintLabel.DataSource = dt;
             PrintLabel.DisplayMember = "pl_labelname";
             PrintLabel.ValueMember = "pl_labelcode";
             ftpOperater ftp = new ftpOperater();
+            indate = new System.DateTime[dt.Rows.Count];
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 //ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
                 BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
+                indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
             }
         }
 

+ 1 - 1
UAS-MES/PublicMethod/BaseUtil.cs

@@ -234,7 +234,7 @@ namespace UAS_MES.PublicMethod
             if (URL.Contains("ftp:"))
             {
                 ftpOperater ftp = new ftpOperater();
-                return ftp.Download(LabelName, time);
+                return ftp.Download(LabelName);
             }
             else
             {

+ 7 - 1
UAS-MES/PublicMethod/Print.cs

@@ -2,6 +2,7 @@
 using LabelManager2;
 using System.Data;
 using System.Text;
+using System.IO;
 
 namespace UAS_MES.PublicMethod
 {
@@ -12,6 +13,7 @@ namespace UAS_MES.PublicMethod
         static Document doc;
         ////CodeSoft的打印机
         //string CodeSpft_Printer;
+        static FileInfo info;
 
         public Print() { }
 
@@ -20,7 +22,7 @@ namespace UAS_MES.PublicMethod
         /// </summary>
         /// <param name="Url"></param>
         /// <param name="LabelCode"></param>
-        public static void CodeSoft(ApplicationClass lbl, string LabelName, string LabelCode, string PrinterName, string SnCode,int PrintNum)
+        public static void CodeSoft(ApplicationClass lbl, string LabelName, string LabelCode, string PrinterName, string SnCode,int PrintNum,System.DateTime intime)
         {
             //打开模板路径
             doc = lbl.Documents.Open(ftpOperater.DownLoadTo + LabelName);
@@ -47,6 +49,10 @@ namespace UAS_MES.PublicMethod
             doc.Printer.SwitchTo(PrinterName);
             doc.PrintDocument(PrintNum);
             doc.Close();
+            //讲文件最后写入时间改成数据库中拿到的时间
+            info = new FileInfo(ftpOperater.DownLoadTo + LabelName);
+            info.LastWriteTime = intime;
+            
         }
 
         public static void CodeSoft(ApplicationClass lbl, string LabelName, string LabelCode, string PrinterName, string SnCode)

+ 2 - 42
UAS-MES/PublicMethod/ftpOperater.cs

@@ -181,7 +181,7 @@ namespace UAS_MES.PublicMethod
         /// 实现ftp下载操作
         /// </summary>
         /// <param name="fileName">远程文件名</param>
-        public string Download(string fileName,DateTime time)
+        public string Download(string fileName)
         {
             FtpWebRequest reqFTP;
             try
@@ -208,9 +208,6 @@ namespace UAS_MES.PublicMethod
                 ftpStream.Close();
                 outputStream.Close();
                 response.Close();
-                //设置最后修改文件时间为服务器时间
-                FileInfo f = new FileInfo(DownLoadTo + @"\" + fileName);
-                f.LastWriteTime = time;
                 return DownLoadTo + @"\" + fileName;
             }
             catch (Exception ex)
@@ -220,43 +217,6 @@ namespace UAS_MES.PublicMethod
             }
         }
 
-        /// <summary>
-        /// 实现ftp下载操作
-        /// </summary>
-        /// <param name="fileName">远程文件名</param>
-        public string Download(string fileName)
-        {
-            FtpWebRequest reqFTP;
-            try
-            {
-                FileStream outputStream = new FileStream(DownLoadTo + @"\" + fileName, FileMode.Create);
-                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + fileName));
-                reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
-                reqFTP.UseBinary = true;
-                reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
-                Stream ftpStream = response.GetResponseStream();
-                long cl = response.ContentLength;
-                int bufferSize = 2048;
-                int readCount;
-                byte[] buffer = new byte[bufferSize];
-
-                readCount = ftpStream.Read(buffer, 0, bufferSize);
-                while (readCount > 0)
-                {
-                    outputStream.Write(buffer, 0, readCount);
-                    readCount = ftpStream.Read(buffer, 0, bufferSize);
-                }
-                ftpStream.Close();
-                outputStream.Close();
-                response.Close();
-                return DownLoadTo + @"\" + fileName;
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.Message);
-                return "";
-            }
-        }
+       
     }
 }