Browse Source

打印添加中盒封盒

章政 7 years ago
parent
commit
8ea3e83ab4

+ 34 - 18
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -28,6 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UAS_出货标签打印));
             this.pi_inoutno_label = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
@@ -37,7 +38,7 @@
             this.pi_cardcode = new System.Windows.Forms.Label();
             this.pi_cardcode_label = new System.Windows.Forms.Label();
             this.Fresh = new System.Windows.Forms.LinkLabel();
-            this.RefreshDBConnect = new System.Windows.Forms.Timer();
+            this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.GetGridOnly = new System.Windows.Forms.CheckBox();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -65,7 +66,7 @@
             this.dataGridViewTextBoxColumn21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.MidSource = new System.Windows.Forms.BindingSource();
+            this.MidSource = new System.Windows.Forms.BindingSource(this.components);
             this.ChooseAll = new System.Windows.Forms.Button();
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
             this.AttachInfo = new System.Windows.Forms.Button();
@@ -76,7 +77,7 @@
             this.SetPrintStatus_label = new System.Windows.Forms.Label();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
             this.label1 = new System.Windows.Forms.Label();
-            this.Pack = new System.Windows.Forms.Button();
+            this.PackOutBox = new System.Windows.Forms.Button();
             this.PrintStatus = new System.Windows.Forms.Button();
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
@@ -147,6 +148,7 @@
             this.OutboxCapacity = new System.Windows.Forms.NumericUpDown();
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
+            this.PackMidBox = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).BeginInit();
@@ -480,7 +482,7 @@
             // AttachInfo
             // 
             this.AttachInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.AttachInfo.Location = new System.Drawing.Point(388, 48);
+            this.AttachInfo.Location = new System.Drawing.Point(388, 80);
             this.AttachInfo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.AttachInfo.Name = "AttachInfo";
             this.AttachInfo.Size = new System.Drawing.Size(64, 26);
@@ -538,7 +540,7 @@
             this.SetPrintStatus_label.AutoSize = true;
             this.SetPrintStatus_label.Font = new System.Drawing.Font("微软雅黑", 12F);
             this.SetPrintStatus_label.ForeColor = System.Drawing.Color.Green;
-            this.SetPrintStatus_label.Location = new System.Drawing.Point(475, 170);
+            this.SetPrintStatus_label.Location = new System.Drawing.Point(475, 191);
             this.SetPrintStatus_label.Name = "SetPrintStatus_label";
             this.SetPrintStatus_label.Size = new System.Drawing.Size(58, 21);
             this.SetPrintStatus_label.TabIndex = 76;
@@ -547,7 +549,7 @@
             // pictureBox1
             // 
             this.pictureBox1.Image = global::UAS_LabelMachine.Properties.Resources.Status;
-            this.pictureBox1.Location = new System.Drawing.Point(411, 99);
+            this.pictureBox1.Location = new System.Drawing.Point(411, 120);
             this.pictureBox1.Name = "pictureBox1";
             this.pictureBox1.Size = new System.Drawing.Size(122, 64);
             this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
@@ -564,17 +566,17 @@
             this.label1.TabIndex = 95;
             this.label1.Text = "DC校验";
             // 
-            // Pack
+            // PackOutBox
             // 
-            this.Pack.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Pack.Location = new System.Drawing.Point(485, 48);
-            this.Pack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.Pack.Name = "Pack";
-            this.Pack.Size = new System.Drawing.Size(64, 26);
-            this.Pack.TabIndex = 96;
-            this.Pack.Text = "封箱";
-            this.Pack.UseVisualStyleBackColor = true;
-            this.Pack.Click += new System.EventHandler(this.Pack_Click);
+            this.PackOutBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.PackOutBox.Location = new System.Drawing.Point(485, 48);
+            this.PackOutBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PackOutBox.Name = "PackOutBox";
+            this.PackOutBox.Size = new System.Drawing.Size(64, 26);
+            this.PackOutBox.TabIndex = 96;
+            this.PackOutBox.Text = "封箱";
+            this.PackOutBox.UseVisualStyleBackColor = true;
+            this.PackOutBox.Click += new System.EventHandler(this.Pack_Click);
             // 
             // PrintStatus
             // 
@@ -1344,18 +1346,31 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
+            // PackMidBox
+            // 
+            this.PackMidBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.PackMidBox.Location = new System.Drawing.Point(388, 48);
+            this.PackMidBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PackMidBox.Name = "PackMidBox";
+            this.PackMidBox.Size = new System.Drawing.Size(64, 26);
+            this.PackMidBox.TabIndex = 102;
+            this.PackMidBox.Text = "封中盒";
+            this.PackMidBox.UseVisualStyleBackColor = true;
+            this.PackMidBox.Click += new System.EventHandler(this.PackMidBox_Click);
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1257, 729);
+            this.Controls.Add(this.PackMidBox);
             this.Controls.Add(this.pib_inman);
             this.Controls.Add(this.bi_inman);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.PrintStatus);
-            this.Controls.Add(this.Pack);
+            this.Controls.Add(this.PackOutBox);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.DCCheck);
             this.Controls.Add(this.pictureBox1);
@@ -1496,7 +1511,7 @@
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.NumericUpDown MidboxCapacity;
         private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Button Pack;
+        private System.Windows.Forms.Button PackOutBox;
         private System.Windows.Forms.Button PrintStatus;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
@@ -1530,5 +1545,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
+        private System.Windows.Forms.Button PackMidBox;
     }
 }

+ 51 - 34
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -635,7 +635,7 @@ namespace UAS_LabelMachine
                         {
                             SingleReport.Print();
                         }
-                        catch (Exception e) 
+                        catch (Exception e)
                         {
                             MessageBox.Show(e.Message);
                             return;
@@ -1273,15 +1273,15 @@ namespace UAS_LabelMachine
         /// <param name="Type"></param>
         /// <param name="Prefix"></param>
         /// <param name="Suffix"></param>
-        /// <param name="CurrentMaxNum"></param>
+        /// <param name="MaxNum"></param>
         /// <param name="SerialNumLength"></param>
         /// <param name="Radix"></param>
-        private void GetBarCodeRule(out string Prefix, out string Suffix, out int CurrentMaxNum, out int SerialNumLength, out int Radix)
+        private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix)
         {
             //获取编码规则
             Prefix = "";
             Suffix = "";
-            CurrentMaxNum = 0;
+            MaxNum = 0;
             SerialNumLength = 0;
             Radix = 0;
             DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + pi_cardcode.Text + "'  order by nrd_detno", "select");
@@ -1334,11 +1334,11 @@ namespace UAS_LabelMachine
                         if (maxnum == "")
                         {
                             dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + pi_cardcode.Text + "','" + Prefix + "','1')", "insert");
-                            CurrentMaxNum = 1;
+                            MaxNum = 1;
                         }
                         else
                         {
-                            CurrentMaxNum = int.Parse(maxnum);
+                            MaxNum = int.Parse(maxnum);
                         }
                         SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
                         Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
@@ -1501,34 +1501,66 @@ namespace UAS_LabelMachine
         }
 
         private void Pack_Click(object sender, EventArgs e)
+        {
+            if (LabelInf.Rows.Count > 0)
+            {
+                DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_outboxcode2", "select");
+                string pibcustoutboxcode = dh.getFieldDataByCondition("prodiobarcode", "pib_custoutboxcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode2"].Value.ToString() + "' and pib_custoutboxcode is not null").ToString();
+                GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
+                if (Radix > 0)
+                {
+                    //生成外箱条码
+                    for (int i = 0; i < dt.Rows.Count; i++)
+                    {
+                        List<string> OutBoxCode = new List<string>();
+                        List<string> PIBOUTBOXCODE2 = new List<string>();
+                        string serialcode = BaseUtil.DToAny(MaxNum, Radix);
+                        for (int k = serialcode.ToString().Length; k < NumLength; k++)
+                        {
+                            serialcode = "0" + serialcode;
+                        }
+                        if (pibcustoutboxcode == "")
+                        {
+                            OutBoxCode.Add(Prefix + serialcode + Suffix);
+                            MaxNum = MaxNum + 1;
+                        }
+                        else
+                        {
+                            OutBoxCode.Add(pibcustoutboxcode);
+                        }
+                        PIBOUTBOXCODE2.Add(dt.Rows[i]["pib_outboxcode2"].ToString());
+                        dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_outboxcode2=:pib_outboxcode2 and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBOUTBOXCODE2.ToArray());
+                    }
+                    dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'");
+                }
+                LoadGridData(sender, e);
+            }
+        }
+
+        private void PackMidBox_Click(object sender, EventArgs e)
         {
             DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_outboxcode2", "select");
-            string Prefix = "";
-            string Suffix = "";
-            int CurrentMaxNum = 0;
-            int Length = 0;
-            int Radix = 0;
-            GetBarCodeRule(out Prefix, out Suffix, out CurrentMaxNum, out Length, out Radix);
+            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix);
             if (Radix > 0)
             {
                 //生成中盒条码
-                int pib_outboxcode1 = 0;
-                CurrentMaxNum = CurrentMaxNum - 1;
+                int pib_outboxcode1 = int.Parse(dh.getFieldDataByCondition("prodiobarcode", "nvl(max(pib_outboxcode1),0)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString());
+                MaxNum = MaxNum - 1;
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     List<string> MidBoxCode = new List<string>();
                     List<string> PIBID = new List<string>();
                     List<string> PIBOUTBOXCODE1 = new List<string>();
-                    DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' order by  to_number(pib_id)", "select");
+                    DataTable dt1 = (DataTable)dh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + dt.Rows[i]["pib_outboxcode2"].ToString() + "' and pib_outboxcode1 is null order by  to_number(pib_id)", "select");
                     //如果不是10的整数倍则为尾盒
                     for (int j = 0; j < dt1.Rows.Count; j++)
                     {
                         if (j % 10 == 0)
                         {
                             pib_outboxcode1 = pib_outboxcode1 + 1;
-                            CurrentMaxNum = CurrentMaxNum + 1;
+                            MaxNum = MaxNum + 1;
                         }
-                        string serialcode = BaseUtil.DToAny(CurrentMaxNum, Radix);
+                        string serialcode = BaseUtil.DToAny(MaxNum, Radix);
                         for (int k = serialcode.ToString().Length; k < NumLength; k++)
                         {
                             serialcode = "0" + serialcode;
@@ -1539,23 +1571,8 @@ namespace UAS_LabelMachine
                     }
                     dh.BatchInsert("update prodiobarcode set pib_custmidboxcode=:pib_custmidboxcode,pib_outboxcode1=:pib_outboxcode1 where pib_id=:pib_id and pib_custmidboxcode is null", new string[] { "pib_custmidboxcode", "pib_outboxcode1", "pib_id" }, MidBoxCode.ToArray(), PIBOUTBOXCODE1.ToArray(), PIBID.ToArray());
                 }
-                CurrentMaxNum = CurrentMaxNum + 1;
-                //生成外箱条码
-                for (int i = 0; i < dt.Rows.Count; i++)
-                {
-                    List<string> OutBoxCode = new List<string>();
-                    List<string> PIBOUTBOXCODE2 = new List<string>();
-                    string serialcode = BaseUtil.DToAny(CurrentMaxNum, Radix);
-                    for (int k = serialcode.ToString().Length; k < NumLength; k++)
-                    {
-                        serialcode = "0" + serialcode;
-                    }
-                    OutBoxCode.Add(Prefix + serialcode + Suffix);
-                    PIBOUTBOXCODE2.Add(dt.Rows[i]["pib_outboxcode2"].ToString());
-                    CurrentMaxNum = CurrentMaxNum + 1;
-                    dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_outboxcode2=:pib_outboxcode2 and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBOUTBOXCODE2.ToArray());
-                }
-                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + CurrentMaxNum + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'");
+                MaxNum = MaxNum + 1;
+                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + MaxNum + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_prefix='" + Prefix + "'");
             }
             LoadGridData(sender, e);
         }