Browse Source

打印插件调整提交

caosy 4 years ago
parent
commit
9416cfd1fd

+ 29 - 1
UAS_PRINT/Form2.Designer.cs

@@ -34,6 +34,9 @@
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
             this.打开根目录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.FTPtoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.打印份数ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
+            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripTextBox();
             this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.contextMenuStrip1.SuspendLayout();
             this.SuspendLayout();
@@ -50,10 +53,11 @@
             this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
             this.打开根目录ToolStripMenuItem,
             this.FTPtoolStripMenuItem,
+            this.打印份数ToolStripMenuItem,
             this.退出ToolStripMenuItem});
             this.contextMenuStrip1.Name = "contextMenuStrip1";
             this.contextMenuStrip1.ShowCheckMargin = true;
-            this.contextMenuStrip1.Size = new System.Drawing.Size(175, 92);
+            this.contextMenuStrip1.Size = new System.Drawing.Size(175, 114);
             // 
             // 打开根目录ToolStripMenuItem
             // 
@@ -70,6 +74,27 @@
             this.FTPtoolStripMenuItem.Text = "是否启动FTP";
             this.FTPtoolStripMenuItem.Click += new System.EventHandler(this.FTPtoolStripMenuItem_Click);
             // 
+            // 打印份数ToolStripMenuItem
+            // 
+            this.打印份数ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.toolStripMenuItem2,
+            this.toolStripMenuItem1});
+            this.打印份数ToolStripMenuItem.Name = "打印份数ToolStripMenuItem";
+            this.打印份数ToolStripMenuItem.Size = new System.Drawing.Size(174, 22);
+            this.打印份数ToolStripMenuItem.Text = "打印份数";
+            // 
+            // toolStripMenuItem2
+            // 
+            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
+            this.toolStripMenuItem2.Size = new System.Drawing.Size(249, 6);
+            // 
+            // toolStripMenuItem1
+            // 
+            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
+            this.toolStripMenuItem1.Size = new System.Drawing.Size(192, 23);
+            this.toolStripMenuItem1.Text = "1";
+            this.toolStripMenuItem1.TextChanged += new System.EventHandler(this.toolStripMenuItem1_TextChanged);
+            // 
             // 退出ToolStripMenuItem
             // 
             this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
@@ -101,5 +126,8 @@
         private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem 打开根目录ToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem FTPtoolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem 打印份数ToolStripMenuItem;
+        private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
+        private System.Windows.Forms.ToolStripTextBox toolStripMenuItem1;
     }
 }

+ 18 - 1
UAS_PRINT/Form2.cs

@@ -40,11 +40,12 @@ namespace UAS_PRINT
             提示.ShowBalloonTip(30, "提示", "程序启动", ToolTipIcon.Info);
 
             FTPtoolStripMenuItem.Checked = Settings.Default.ifuseftp;
+            toolStripMenuItem1.Text = Settings.Default.Printnum.ToString();
 
             //string req = File.ReadAllText(@"C:\Users\Hcsy\Documents\Tencent Files\814802334\FileRecv\4.txt", Encoding.UTF8);
             //if (req.Contains("\"" + "chooseprintername" + "\""))
             //{
-            //    req = req.Remove(req.IndexOf("device"), req.IndexOf("data") - 3);
+            //    req = req.Remove(req.IndexOf("device"), req.IndexOf("data") - 2);
             //    lock ("A")
             //    {
             //        PrintHandler.vendorZplPrint(req);
@@ -190,5 +191,21 @@ namespace UAS_PRINT
             Settings.Default.ifuseftp = FTPtoolStripMenuItem.Checked;
             Settings.Default.Save();
         }
+
+        private void toolStripMenuItem1_TextChanged(object sender, EventArgs e)
+        {
+            try
+            {
+                int a = int.Parse(toolStripMenuItem1.Text);
+                Settings.Default.Printnum = a;
+                Settings.Default.Save();
+            }
+            catch {
+                MessageBox.Show("录入数量须为整数");
+                Settings.Default.Printnum = 1;
+                Settings.Default.Save();
+                toolStripMenuItem1.Text = "1";
+            }
+        }
     }
 }

+ 37 - 33
UAS_PRINT/PrintHandler.cs

@@ -187,49 +187,53 @@ namespace UAS_PRINT
             }
             foreach (var item in barcode)
             {
-                DataRow dr = dt.NewRow();
-                foreach (var itemc in item)
+                int number = Settings.Default.Printnum;
+                for (int i = 0; i < number; i++)
                 {
-                    Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
-                    if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
+                    DataRow dr = dt.NewRow();
+                    foreach (var itemc in item)
                     {
-                        string itemstr = "";
-                        if (itemc.Value != null)
+                        Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
+                        if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
                         {
-                            itemstr = itemc.Value.ToString();
-                            while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
-                            {
-                                itemstr = itemstr.Remove(0, 2);
-                            }
-                            if (itemstr.StartsWith("\""))
-                            {
-                                itemstr = itemstr.Remove(0, 1);
-                            }
-                            while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
-                            {
-                                itemstr = itemstr.Remove(itemstr.Length - 2);
-                            }
-                            if (itemstr.EndsWith("\""))
-                            {
-                                itemstr = itemstr.Remove(itemstr.Length - 1);
-                            }
-                            if (itemstr.Contains("\\\""))
+                            string itemstr = "";
+                            if (itemc.Value != null)
                             {
-                                itemstr = itemstr.Replace("\\\"", "\"");
+                                itemstr = itemc.Value.ToString();
+                                while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
+                                {
+                                    itemstr = itemstr.Remove(0, 2);
+                                }
+                                if (itemstr.StartsWith("\""))
+                                {
+                                    itemstr = itemstr.Remove(0, 1);
+                                }
+                                while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
+                                {
+                                    itemstr = itemstr.Remove(itemstr.Length - 2);
+                                }
+                                if (itemstr.EndsWith("\""))
+                                {
+                                    itemstr = itemstr.Remove(itemstr.Length - 1);
+                                }
+                                if (itemstr.Contains("\\\""))
+                                {
+                                    itemstr = itemstr.Replace("\\\"", "\"");
+                                }
                             }
+                            dr[itemc.Key] = itemstr;
+                        }
+                        else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
+                        {
+                            dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
                         }
-                        dr[itemc.Key] = itemstr;
-                    }
-                    else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
-                    {
-                        dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
                     }
+                    dt.Rows.Add(dr);
                 }
-                dt.Rows.Add(dr);
             }
             try
             {
-                string logout_confirm = MessageBox.Show("打印"+dt.Rows.Count+"张条码,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
+                string logout_confirm = MessageBox.Show("打印" + dt.Rows.Count + "张条码,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
                 if (logout_confirm == "Yes")
                 {
                     Report.PrintSettings.ShowDialog = false;
@@ -247,7 +251,7 @@ namespace UAS_PRINT
                     Report.RegisterData(dt, label_type);
                     Report.GetDataSource(label_type).Enabled = true;
                     Report.Print();
-                }
+               }
                
             }
             catch(Exception ex)

+ 14 - 2
UAS_PRINT/Properties/Settings.Designer.cs

@@ -25,7 +25,7 @@ namespace UAS_PRINT.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("ftp://172.16.0.20")]
+        [global::System.Configuration.DefaultSettingValueAttribute("ftp://192.168.1.105")]
         public string ftpaddress {
             get {
                 return ((string)(this["ftpaddress"]));
@@ -49,7 +49,7 @@ namespace UAS_PRINT.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("shenaftp")]
+        [global::System.Configuration.DefaultSettingValueAttribute("vsftpd")]
         public string ftppassword {
             get {
                 return ((string)(this["ftppassword"]));
@@ -70,5 +70,17 @@ namespace UAS_PRINT.Properties {
                 this["ifuseftp"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("1")]
+        public int Printnum {
+            get {
+                return ((int)(this["Printnum"]));
+            }
+            set {
+                this["Printnum"] = value;
+            }
+        }
     }
 }

+ 5 - 2
UAS_PRINT/Properties/Settings.settings

@@ -3,16 +3,19 @@
   <Profiles />
   <Settings>
     <Setting Name="ftpaddress" Type="System.String" Scope="User">
-      <Value Profile="(Default)">ftp://172.16.0.20</Value>
+      <Value Profile="(Default)">ftp://192.168.1.105</Value>
     </Setting>
     <Setting Name="ftpuser" Type="System.String" Scope="User">
       <Value Profile="(Default)">vsftpd</Value>
     </Setting>
     <Setting Name="ftppassword" Type="System.String" Scope="User">
-      <Value Profile="(Default)">shenaftp</Value>
+      <Value Profile="(Default)">vsftpd</Value>
     </Setting>
     <Setting Name="ifuseftp" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">False</Value>
     </Setting>
+    <Setting Name="Printnum" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">1</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 5 - 2
UAS_PRINT/app.config

@@ -8,17 +8,20 @@
     <userSettings>
         <UAS_PRINT.Properties.Settings>
             <setting name="ftpaddress" serializeAs="String">
-                <value>ftp://172.16.0.20</value>
+                <value>ftp://192.168.1.105</value>
             </setting>
             <setting name="ftpuser" serializeAs="String">
                 <value>vsftpd</value>
             </setting>
             <setting name="ftppassword" serializeAs="String">
-                <value>shenaftp</value>
+                <value>vsftpd</value>
             </setting>
             <setting name="ifuseftp" serializeAs="String">
                 <value>False</value>
             </setting>
+            <setting name="Printnum" serializeAs="String">
+                <value>1</value>
+            </setting>
         </UAS_PRINT.Properties.Settings>
     </userSettings>
 </configuration>