瀏覽代碼

生成条码小数处理

章政 6 年之前
父節點
當前提交
0ab26b9c5b
共有 2 個文件被更改,包括 77 次插入68 次删除
  1. 33 29
      UAS-出货标签管理/生成条码.Designer.cs
  2. 44 39
      UAS-出货标签管理/生成条码.cs

+ 33 - 29
UAS-出货标签管理/生成条码.Designer.cs

@@ -37,12 +37,10 @@
             this.MidCapacity_label = new System.Windows.Forms.Label();
             this.MidCapacity_label = new System.Windows.Forms.Label();
             this.ResetSerialNum = new UAS_LabelMachine.CustomControl.NormalButton();
             this.ResetSerialNum = new UAS_LabelMachine.CustomControl.NormalButton();
             this.SetMidCapacity = new UAS_LabelMachine.CustomControl.NormalButton();
             this.SetMidCapacity = new UAS_LabelMachine.CustomControl.NormalButton();
-            this.MidCapacity = new UAS_LabelMachine.CustomControl.NumOnlyTextBox();
             this.ChooseAll = new UAS_LabelMachine.CustomControl.ChooseAllButton();
             this.ChooseAll = new UAS_LabelMachine.CustomControl.ChooseAllButton();
             this.GenerateBarCode = new UAS_LabelMachine.CustomControl.NormalButton();
             this.GenerateBarCode = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Screen = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Screen = new UAS_LabelMachine.CustomControl.NormalButton();
             this.ProdIoInfDGV = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
             this.ProdIoInfDGV = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.pd_orderdetno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_orderdetno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -61,6 +59,8 @@
             this.mid_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_num = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_num = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_remain = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_remain = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
+            this.MidCapacity = new UAS_LabelMachine.CustomControl.EnterTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.ProdIoInfDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ProdIoInfDGV)).BeginInit();
             this.SuspendLayout();
             this.SuspendLayout();
             // 
             // 
@@ -129,7 +129,7 @@
             // ResetSerialNum
             // ResetSerialNum
             // 
             // 
             this.ResetSerialNum.Image = ((System.Drawing.Image)(resources.GetObject("ResetSerialNum.Image")));
             this.ResetSerialNum.Image = ((System.Drawing.Image)(resources.GetObject("ResetSerialNum.Image")));
-            this.ResetSerialNum.Location = new System.Drawing.Point(529, 78);
+            this.ResetSerialNum.Location = new System.Drawing.Point(661, 78);
             this.ResetSerialNum.Name = "ResetSerialNum";
             this.ResetSerialNum.Name = "ResetSerialNum";
             this.ResetSerialNum.Size = new System.Drawing.Size(64, 24);
             this.ResetSerialNum.Size = new System.Drawing.Size(64, 24);
             this.ResetSerialNum.TabIndex = 161;
             this.ResetSerialNum.TabIndex = 161;
@@ -148,14 +148,6 @@
             this.SetMidCapacity.UseVisualStyleBackColor = true;
             this.SetMidCapacity.UseVisualStyleBackColor = true;
             this.SetMidCapacity.Click += new System.EventHandler(this.SetMidCapacity_Click);
             this.SetMidCapacity.Click += new System.EventHandler(this.SetMidCapacity_Click);
             // 
             // 
-            // MidCapacity
-            // 
-            this.MidCapacity.Location = new System.Drawing.Point(787, 29);
-            this.MidCapacity.Name = "MidCapacity";
-            this.MidCapacity.Negative = false;
-            this.MidCapacity.Size = new System.Drawing.Size(121, 21);
-            this.MidCapacity.TabIndex = 159;
-            // 
             // ChooseAll
             // ChooseAll
             // 
             // 
             this.ChooseAll.Location = new System.Drawing.Point(1, 102);
             this.ChooseAll.Location = new System.Drawing.Point(1, 102);
@@ -168,7 +160,7 @@
             // GenerateBarCode
             // GenerateBarCode
             // 
             // 
             this.GenerateBarCode.Image = ((System.Drawing.Image)(resources.GetObject("GenerateBarCode.Image")));
             this.GenerateBarCode.Image = ((System.Drawing.Image)(resources.GetObject("GenerateBarCode.Image")));
-            this.GenerateBarCode.Location = new System.Drawing.Point(442, 78);
+            this.GenerateBarCode.Location = new System.Drawing.Point(574, 78);
             this.GenerateBarCode.Name = "GenerateBarCode";
             this.GenerateBarCode.Name = "GenerateBarCode";
             this.GenerateBarCode.Size = new System.Drawing.Size(64, 24);
             this.GenerateBarCode.Size = new System.Drawing.Size(64, 24);
             this.GenerateBarCode.TabIndex = 154;
             this.GenerateBarCode.TabIndex = 154;
@@ -179,7 +171,7 @@
             // Screen
             // Screen
             // 
             // 
             this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
             this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
-            this.Screen.Location = new System.Drawing.Point(354, 78);
+            this.Screen.Location = new System.Drawing.Point(486, 78);
             this.Screen.Name = "Screen";
             this.Screen.Name = "Screen";
             this.Screen.Size = new System.Drawing.Size(64, 24);
             this.Screen.Size = new System.Drawing.Size(64, 24);
             this.Screen.TabIndex = 153;
             this.Screen.TabIndex = 153;
@@ -223,19 +215,6 @@
             this.ProdIoInfDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.ProdIoInfDGV_CellEndEdit);
             this.ProdIoInfDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.ProdIoInfDGV_CellEndEdit);
             this.ProdIoInfDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.ProdIoInfDGV_CellPainting);
             this.ProdIoInfDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.ProdIoInfDGV_CellPainting);
             // 
             // 
-            // pi_inoutno
-            // 
-            this.pi_inoutno.ID = null;
-            this.pi_inoutno.Location = new System.Drawing.Point(128, 29);
-            this.pi_inoutno.Name = "pi_inoutno";
-            this.pi_inoutno.Size = new System.Drawing.Size(121, 21);
-            this.pi_inoutno.Str = null;
-            this.pi_inoutno.Str1 = null;
-            this.pi_inoutno.Str2 = null;
-            this.pi_inoutno.TabIndex = 149;
-            this.pi_inoutno.Tag = "cu_name";
-            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bi_inoutno_KeyDown);
-            // 
             // Choose
             // Choose
             // 
             // 
             this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
             this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
@@ -249,7 +228,7 @@
             this.pd_orderdetno.DataPropertyName = "pd_orderdetno";
             this.pd_orderdetno.DataPropertyName = "pd_orderdetno";
             this.pd_orderdetno.HeaderText = "订单序号";
             this.pd_orderdetno.HeaderText = "订单序号";
             this.pd_orderdetno.Name = "pd_orderdetno";
             this.pd_orderdetno.Name = "pd_orderdetno";
-            this.pd_orderdetno.Width = 78;
+            this.pd_orderdetno.Width = 61;
             // 
             // 
             // pd_pdno
             // pd_pdno
             // 
             // 
@@ -360,14 +339,39 @@
             this.mid_remain.Name = "mid_remain";
             this.mid_remain.Name = "mid_remain";
             this.mid_remain.ReadOnly = true;
             this.mid_remain.ReadOnly = true;
             // 
             // 
+            // pi_inoutno
+            // 
+            this.pi_inoutno.ID = null;
+            this.pi_inoutno.Location = new System.Drawing.Point(128, 29);
+            this.pi_inoutno.Name = "pi_inoutno";
+            this.pi_inoutno.Size = new System.Drawing.Size(121, 21);
+            this.pi_inoutno.Str = null;
+            this.pi_inoutno.Str1 = null;
+            this.pi_inoutno.Str2 = null;
+            this.pi_inoutno.TabIndex = 149;
+            this.pi_inoutno.Tag = "cu_name";
+            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bi_inoutno_KeyDown);
+            // 
+            // MidCapacity
+            // 
+            this.MidCapacity.ID = null;
+            this.MidCapacity.Location = new System.Drawing.Point(783, 30);
+            this.MidCapacity.Name = "MidCapacity";
+            this.MidCapacity.Size = new System.Drawing.Size(121, 21);
+            this.MidCapacity.Str = null;
+            this.MidCapacity.Str1 = null;
+            this.MidCapacity.Str2 = null;
+            this.MidCapacity.TabIndex = 162;
+            this.MidCapacity.Tag = "cu_name";
+            // 
             // 生成条码
             // 生成条码
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1201, 554);
             this.ClientSize = new System.Drawing.Size(1201, 554);
+            this.Controls.Add(this.MidCapacity);
             this.Controls.Add(this.ResetSerialNum);
             this.Controls.Add(this.ResetSerialNum);
             this.Controls.Add(this.SetMidCapacity);
             this.Controls.Add(this.SetMidCapacity);
-            this.Controls.Add(this.MidCapacity);
             this.Controls.Add(this.MidCapacity_label);
             this.Controls.Add(this.MidCapacity_label);
             this.Controls.Add(this.pr_kind);
             this.Controls.Add(this.pr_kind);
             this.Controls.Add(this.pr_kind_label);
             this.Controls.Add(this.pr_kind_label);
@@ -402,7 +406,6 @@
         private System.Windows.Forms.Label pr_kind_label;
         private System.Windows.Forms.Label pr_kind_label;
         private System.Windows.Forms.ComboBox pr_kind;
         private System.Windows.Forms.ComboBox pr_kind;
         private System.Windows.Forms.Label MidCapacity_label;
         private System.Windows.Forms.Label MidCapacity_label;
-        private CustomControl.NumOnlyTextBox MidCapacity;
         private CustomControl.NormalButton SetMidCapacity;
         private CustomControl.NormalButton SetMidCapacity;
         private CustomControl.NormalButton ResetSerialNum;
         private CustomControl.NormalButton ResetSerialNum;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
@@ -423,5 +426,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_num;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_num;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_remain;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_remain;
+        private CustomControl.EnterTextBox MidCapacity;
     }
     }
 }
 }

+ 44 - 39
UAS-出货标签管理/生成条码.cs

@@ -191,11 +191,11 @@ namespace UAS_LabelMachine
                     string pr_brand = ProdIoInfDGV.Rows[i].Cells["pr_brand"].FormattedValue.ToString();
                     string pr_brand = ProdIoInfDGV.Rows[i].Cells["pr_brand"].FormattedValue.ToString();
                     string pr_madein = ProdIoInfDGV.Rows[i].Cells["pr_madein"].FormattedValue.ToString();
                     string pr_madein = ProdIoInfDGV.Rows[i].Cells["pr_madein"].FormattedValue.ToString();
                     //总数
                     //总数
-                    int pd_totalqty = int.Parse(ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].FormattedValue.ToString());
+                    double pd_totalqty = double.Parse(ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].FormattedValue.ToString());
                     //本次数量
                     //本次数量
-                    int pd_qty = int.Parse(ProdIoInfDGV.Rows[i].Cells["pd_qty"].FormattedValue.ToString());
+                    double pd_qty = double.Parse(ProdIoInfDGV.Rows[i].Cells["pd_qty"].FormattedValue.ToString());
                     //最小包装数
                     //最小包装数
-                    int pr_zxbzs = int.Parse(ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].FormattedValue.ToString());
+                    double pr_zxbzs = double.Parse(ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].FormattedValue.ToString());
                     //中盒容量
                     //中盒容量
                     int mid_qty;
                     int mid_qty;
                     try
                     try
@@ -210,7 +210,7 @@ namespace UAS_LabelMachine
                     //如果中盘盒数量为1且有尾数则表示一箱未装满
                     //如果中盘盒数量为1且有尾数则表示一箱未装满
                     int mid_num = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_num"].FormattedValue.ToString());
                     int mid_num = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_num"].FormattedValue.ToString());
                     //中盒尾数
                     //中盒尾数
-                    int mid_remain = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_remain"].FormattedValue.ToString());
+                    double mid_remain = double.Parse(ProdIoInfDGV.Rows[i].Cells["mid_remain"].FormattedValue.ToString());
                     string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                     string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                     //中盒数量*中盒容量=需要打印的单盘标签
                     //中盒数量*中盒容量=需要打印的单盘标签
                     ArrayList<string> midcode = new ArrayList<string>();
                     ArrayList<string> midcode = new ArrayList<string>();
@@ -223,11 +223,19 @@ namespace UAS_LabelMachine
                         string mid_code = dh.getFieldDataByCondition("PRODIOBARCODE", "nvl(max(to_number(PIB_OUTBOXCODE1)),0)+" + (j + 1), "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                         string mid_code = dh.getFieldDataByCondition("PRODIOBARCODE", "nvl(max(to_number(PIB_OUTBOXCODE1)),0)+" + (j + 1), "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                         //如果尾数不为0,并且已经遍历到了最后一箱(未装满的箱)
                         //如果尾数不为0,并且已经遍历到了最后一箱(未装满的箱)
                         int count = 0;
                         int count = 0;
-                        int AddNum = pr_zxbzs;
+                        double AddNum = pr_zxbzs;
                         if (mid_remain != 0 && j + 1 == mid_num)
                         if (mid_remain != 0 && j + 1 == mid_num)
                         {
                         {
                             //剩下的尾数刚好够整数的最小包或者加上一个未装满的最小包
                             //剩下的尾数刚好够整数的最小包或者加上一个未装满的最小包
-                            count = mid_remain % pr_zxbzs == 0 ? mid_remain / pr_zxbzs : (mid_remain / pr_zxbzs) + 1;
+                            int num = 0;
+                            if (int.TryParse((mid_remain % pr_zxbzs).ToString(), out num))
+                            {
+                                count = int.Parse(Math.Floor(mid_remain / pr_zxbzs).ToString());
+                            }
+                            else
+                            {
+                                count = int.Parse(Math.Ceiling(mid_remain / pr_zxbzs).ToString());
+                            }
                         }
                         }
                         else
                         else
                         {
                         {
@@ -251,7 +259,7 @@ namespace UAS_LabelMachine
                         sql.Clear();
                         sql.Clear();
                         sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_MADEIN,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
                         sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_MADEIN,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
                         sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
                         sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
-                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'"+ pr_madein + "','" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
+                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'" + pr_madein + "','" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
                         sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
                         sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
                         dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty", "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                         dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty", "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                         //更新最大流水号
                         //更新最大流水号
@@ -369,37 +377,30 @@ namespace UAS_LabelMachine
         /// <param name="e"></param>
         /// <param name="e"></param>
         private void ProdIoInfDGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         private void ProdIoInfDGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         {
         {
+
             object pr_zxbzs = ProdIoInfDGV.Rows[e.RowIndex].Cells["pr_zxbzs"].Value;
             object pr_zxbzs = ProdIoInfDGV.Rows[e.RowIndex].Cells["pr_zxbzs"].Value;
             object pd_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_qty"].Value;
             object pd_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_qty"].Value;
             object mid_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_qty"].Value;
             object mid_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_qty"].Value;
             object pd_totalqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_totalqty"].Value;
             object pd_totalqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_totalqty"].Value;
             if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
             if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
             {
             {
-                int 最小包装量 = int.Parse(pr_zxbzs.ToString());
-                int 中盘容量 = int.Parse(mid_qty.ToString());
-                int 本次数量 = int.Parse(pd_qty.ToString());
-                int 总数 = int.Parse(pd_totalqty.ToString());
-                if (最小包装量 > 0)
+                double 最小包装量 = double.Parse(pr_zxbzs.ToString());
+                double 中盘容量 = double.Parse(mid_qty.ToString());
+                double 本次数量 = double.Parse(pd_qty.ToString());
+                double 总数 = double.Parse(pd_totalqty.ToString());
+                //计算中盘数量
+                double mid_num = 本次数量 / (最小包装量 * 中盘容量);
+                int num = 0;
+                if (int.TryParse(mid_num.ToString(), out num))
                 {
                 {
-                    if (本次数量 > 总数)
-                    {
-                        MessageBox.Show("本次数量不能大于总数");
-                        return;
-                    }
-                    if (中盘容量 <= 0 || 最小包装量 <= 0)
-                    {
-                        MessageBox.Show("中盘容量和单盘数量必须是正整数");
-                        return;
-                    }
-                    //计算中盘数量
-                    int mid_num = 本次数量 / (最小包装量 * 中盘容量);
-                    //计算中盘尾数
-                    if (本次数量 % (最小包装量 * 中盘容量) == 0)
-                        ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num;
-                    else
-                        ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num + 1;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num;
                     ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
                     ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
                 }
                 }
+                else
+                {
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = Math.Floor(mid_num) + 1;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - Math.Floor(mid_num) * 最小包装量 * 中盘容量;
+                }
             }
             }
         }
         }
 
 
@@ -417,18 +418,23 @@ namespace UAS_LabelMachine
                     object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
                     object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
                     if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
                     if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
                     {
                     {
-                        int 最小包装量 = int.Parse(pr_zxbzs.ToString());
-                        int 中盘容量 = int.Parse(mid_qty.ToString());
-                        int 本次数量 = int.Parse(pd_qty.ToString());
-                        int 总数 = int.Parse(pd_totalqty.ToString());
+                        double 最小包装量 = double.Parse(pr_zxbzs.ToString());
+                        double 中盘容量 = double.Parse(mid_qty.ToString());
+                        double 本次数量 = double.Parse(pd_qty.ToString());
+                        double 总数 = double.Parse(pd_totalqty.ToString());
                         //计算中盘数量
                         //计算中盘数量
-                        int mid_num = 本次数量 / (最小包装量 * 中盘容量);
-                        //计算中盘尾数
-                        if (本次数量 % (最小包装量 * 中盘容量) == 0)
+                        double mid_num = 本次数量 / (最小包装量 * 中盘容量);
+                        int num = 0;
+                        if (int.TryParse(mid_num.ToString(), out num))
+                        {
                             ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
                             ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
+                            ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
+                        }
                         else
                         else
-                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num + 1;
-                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
+                        {
+                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = Math.Floor(mid_num) + 1;
+                            ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - Math.Floor(mid_num) * 最小包装量 * 中盘容量;
+                        }
                     }
                     }
                 }
                 }
             }
             }
@@ -469,7 +475,6 @@ namespace UAS_LabelMachine
                     default:
                     default:
                         break;
                         break;
                 }
                 }
-
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }
             }