Browse Source

修改自定义标签打印内容

shim 8 years ago
parent
commit
8becddb0be

+ 4 - 0
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.Designer.cs

@@ -86,6 +86,7 @@
             this.PrintLabel.Name = "PrintLabel";
             this.PrintLabel.Name = "PrintLabel";
             this.PrintLabel.Size = new System.Drawing.Size(190, 26);
             this.PrintLabel.Size = new System.Drawing.Size(190, 26);
             this.PrintLabel.TabIndex = 185;
             this.PrintLabel.TabIndex = 185;
+            this.PrintLabel.SelectedIndexChanged += new System.EventHandler(this.PrintLabel_SelectedIndexChanged);
             this.PrintLabel.TextChanged += new System.EventHandler(this.PrintLabel_TextChanged);
             this.PrintLabel.TextChanged += new System.EventHandler(this.PrintLabel_TextChanged);
             // 
             // 
             // label4
             // label4
@@ -199,6 +200,7 @@
             this.pr_code.Str2 = null;
             this.pr_code.Str2 = null;
             this.pr_code.TabIndex = 191;
             this.pr_code.TabIndex = 191;
             this.pr_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pr_code_KeyDown);
             this.pr_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pr_code_KeyDown);
+            this.pr_code.Leave += new System.EventHandler(this.pr_code_Leave);
             // 
             // 
             // inputText
             // inputText
             // 
             // 
@@ -262,7 +264,9 @@
             this.Name = "Make_CustomLabelPrint";
             this.Name = "Make_CustomLabelPrint";
             this.Tag = "Make!CustomLabelPrint";
             this.Tag = "Make!CustomLabelPrint";
             this.Text = "Make_CustomLabelPrint";
             this.Text = "Make_CustomLabelPrint";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Make_CustomLabelPrint_FormClosing);
             this.Load += new System.EventHandler(this.Make_CustomLablePrint_Load);
             this.Load += new System.EventHandler(this.Make_CustomLablePrint_Load);
+            this.SizeChanged += new System.EventHandler(this.Make_CustomLabelPrint_SizeChanged);
             this.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
             this.PerformLayout();
 
 

+ 61 - 25
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.cs

@@ -40,7 +40,7 @@ namespace UAS_MES.Make
 
 
         FileInfo info;
         FileInfo info;
 
 
-        ftpOperater ftp;
+        //ftpOperater ftp;
 
 
         System.DateTime[] indate;
         System.DateTime[] indate;
 
 
@@ -53,7 +53,7 @@ namespace UAS_MES.Make
         private void Make_CustomLablePrint_Load(object sender, EventArgs e)
         private void Make_CustomLablePrint_Load(object sender, EventArgs e)
         {
         {
             dh = new DataHelper();
             dh = new DataHelper();
-            inputText.Focus();
+            pr_code.Focus();
             asc.controllInitializeSize(this);
             asc.controllInitializeSize(this);
             OperateResult.AppendText(">>请输入产品代码\n", Color.Black);
             OperateResult.AppendText(">>请输入产品代码\n", Color.Black);
             InitPrint = new Thread(InPrint);
             InitPrint = new Thread(InPrint);
@@ -100,29 +100,15 @@ namespace UAS_MES.Make
                     //说明没有默认的模板,那就取pl_id最大的
                     //说明没有默认的模板,那就取pl_id最大的
                     listA = (DataTable)dh.ExecuteSql("select pl_labelcode ||':'||pl_labelname pl_name,pl_id,pl_labeltype,pl_labelcode,pl_labelurl,pl_isdefault,pl_detno,pl_labelsoft,pl_status,pl_statuscode,pl_labelname,pl_indate from  productlabel where pl_prodcode='" + pr_code.Text + "' and pl_labeltype='自定义' order by pl_id desc", "select");
                     listA = (DataTable)dh.ExecuteSql("select pl_labelcode ||':'||pl_labelname pl_name,pl_id,pl_labeltype,pl_labelcode,pl_labelurl,pl_isdefault,pl_detno,pl_labelsoft,pl_status,pl_statuscode,pl_labelname,pl_indate from  productlabel where pl_prodcode='" + pr_code.Text + "' and pl_labeltype='自定义' order by pl_id desc", "select");
                 }
                 }
+                //下载标签
+                getLabels();
                 //标签显示
                 //标签显示
                 PrintLabel.DataSource = listA;
                 PrintLabel.DataSource = listA;
                 PrintLabel.DisplayMember = "pl_name";
                 PrintLabel.DisplayMember = "pl_name";
                 PrintLabel.ValueMember = "pl_labelcode";
                 PrintLabel.ValueMember = "pl_labelcode";
-                //下载标签
-                getLabels();
                 //有值,填充界面
                 //有值,填充界面
                 BaseUtil.SetFormValue(this.Controls, dt);
                 BaseUtil.SetFormValue(this.Controls, dt);
                 //paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='"+ listA.Rows[0]["pl_labelcode"].ToString() + "' order by lp_detno asc", "select");
                 //paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='"+ listA.Rows[0]["pl_labelcode"].ToString() + "' order by lp_detno asc", "select");
-                if (paramsInfo.Rows.Count > 0)
-                {
-                    //根据查询出来的参数,一次提示用户, “<<SN001 “, 
-                    //“>> 请输入自定义模板的(XXXX参数名称)lp_name”
-                    OperateResult.AppendText("<<" + listA.Rows[0]["pl_labelcode"].ToString() + "\n", Color.Black);
-                    OperateResult.AppendText(">>请输入自定义模板参数名为:" + paramsInfo.Rows[0]["lp_name"].ToString() + "的值\n", Color.Green);
-                    //打开模板路径
-                    doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text.Split(':')[1]);
-                    currentIndex = 1;
-                }
-                else
-                {
-                    OperateResult.AppendText("<<标签编号:" + listA.Rows[0]["pl_labelcode"].ToString() + "无标签参数\n", Color.Red);
-                }
             }
             }
         }
         }
 
 
@@ -142,14 +128,16 @@ namespace UAS_MES.Make
                     OperateResult.AppendText("<<输入不能为空\n", Color.Red);
                     OperateResult.AppendText("<<输入不能为空\n", Color.Red);
                     return;
                     return;
                 }
                 }
+                OperateResult.AppendText(">>"+inputText.Text+"\n", Color.Black);
                 if (paramsInfo == null || paramsInfo.Rows.Count == 0)
                 if (paramsInfo == null || paramsInfo.Rows.Count == 0)
                 {
                 {
-                    OperateResult.AppendText("<<未维护标签参数\n", Color.Red);
+                    OperateResult.AppendText("<<无可用标签\n", Color.Red,inputText);
+                    return;
                 }
                 }
                 else
                 else
                 {
                 {
                     if (doc==null) {
                     if (doc==null) {
-                        OperateResult.AppendText(">>标签无效\n", Color.Red);
+                        OperateResult.AppendText(">>无可用标签\n", Color.Red,inputText);
                         return;
                         return;
                     }
                     }
                     //将值赋到doc对应的变量
                     //将值赋到doc对应的变量
@@ -175,7 +163,7 @@ namespace UAS_MES.Make
                     }
                     }
                     if (currentIndex == paramsInfo.Rows.Count)
                     if (currentIndex == paramsInfo.Rows.Count)
                     {
                     {
-                        OperateResult.AppendText("<<输入完成,正在打印\n", Color.Black);
+                        OperateResult.AppendText("<<输入完成,正在打印\n", Color.Black,inputText);
                         //打印
                         //打印
                         LogManager.DoLog(sb.ToString());
                         LogManager.DoLog(sb.ToString());
                         //保存本次赋值进行打印
                         //保存本次赋值进行打印
@@ -190,12 +178,13 @@ namespace UAS_MES.Make
                         OperateResult.AppendText("<<打印成功\n", Color.Green);
                         OperateResult.AppendText("<<打印成功\n", Color.Green);
                         //重置currenIndex为1
                         //重置currenIndex为1
                         currentIndex = 1;
                         currentIndex = 1;
-                        OperateResult.AppendText(">>请输入自定义模板参数名为:" + paramsInfo.Rows[0]["lp_name"].ToString() + "的值\n", Color.Green);
+                        OperateResult.AppendText(">>请输入自定义模板的" + paramsInfo.Rows[0]["lp_name"].ToString() + "\n", Color.Black);
+                        doc=lbl.Documents.Open(ftpOperater.DownLoadTo + listA.Rows[PrintLabel.SelectedIndex]["pl_labelname"].ToString());
                     }
                     }
                     else
                     else
                     {
                     {
                         currentIndex++;
                         currentIndex++;
-                        OperateResult.AppendText("<<请输入模板参数名为:" + paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString() + "的值\n", Color.Green);
+                        OperateResult.AppendText("<<请输入自定义模板的" + paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString() + "\n", Color.Green,inputText);
                     }
                     }
                 }
                 }
             }
             }
@@ -203,7 +192,7 @@ namespace UAS_MES.Make
 
 
         private void getLabels()
         private void getLabels()
         {
         {
-            ftp = new ftpOperater();
+            //ftp = new ftpOperater();
             indate = new System.DateTime[listA.Rows.Count];
             indate = new System.DateTime[listA.Rows.Count];
             for (int i = 0; i < listA.Rows.Count; i++)
             for (int i = 0; i < listA.Rows.Count; i++)
             {
             {
@@ -214,7 +203,54 @@ namespace UAS_MES.Make
 
 
         private void PrintLabel_TextChanged(object sender, EventArgs e)
         private void PrintLabel_TextChanged(object sender, EventArgs e)
         {
         {
-            paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='" + PrintLabel.SelectedValue.ToString() + "' order by lp_detno asc", "select");
+            if (PrintLabel.Text.StartsWith("System")) {
+                return;
+            }
+            paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='" + listA.Rows[PrintLabel.SelectedIndex]["pl_labelcode"].ToString() + "' order by lp_detno asc", "select");
+            if (paramsInfo.Rows.Count > 0)
+            {
+                //根据查询出来的参数,一次提示用户, “<<SN001 “, 
+                //“>> 请输入自定义模板的(XXXX参数名称)lp_name”
+                OperateResult.AppendText("<<" + listA.Rows[PrintLabel.SelectedIndex]["pl_labelcode"].ToString() + "\n", Color.Black);
+                OperateResult.AppendText(">>请输入自定义模板" + paramsInfo.Rows[0]["lp_name"].ToString() + "的值\n", Color.Green);
+                //打开模板路径
+                //doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.SelectedText.Split(':')[1]);
+                if (doc != null)
+                {
+                    doc.Close();
+                }
+                doc = lbl.Documents.Open(ftpOperater.DownLoadTo + listA.Rows[PrintLabel.SelectedIndex]["pl_labelname"].ToString());
+                currentIndex = 1;
+                //聚焦输入框
+                inputText.Focus();
+            }
+            else
+            {
+                OperateResult.AppendText("<<标签编号:" + listA.Rows[0]["pl_labelcode"].ToString() + "无标签参数\n", Color.Red);
+            }
+        }
+
+        private void Make_CustomLabelPrint_SizeChanged(object sender, EventArgs e)
+        {
+            asc.controlAutoSize(this);
+        }
+
+        private void PrintLabel_SelectedIndexChanged(object sender, EventArgs e)
+        {
+           
+        }
+
+        private void Make_CustomLabelPrint_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (doc!=null)
+            {
+                doc.Close();
+            }
+        }
+
+        private void pr_code_Leave(object sender, EventArgs e)
+        {
+            pr_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
         }
         }
     }
     }
 }
 }