Ver Fonte

生成条码添加小数

章政 há 6 anos atrás
pai
commit
d4b3ac3bcb

+ 2 - 2
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -1459,7 +1459,7 @@ namespace UAS_LabelMachine
             if (PrintMethod == "CodeSoft")
                 Print.CodeSoft.MidPrint(MidDoc, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
             else
-                Print.BarTender.MidPrint(MidDoc, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
+                Print.BarTender.MidPrint(MidFormat, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
         }
 
         private void OutBoxCodePrint(int rowindex)
@@ -1470,7 +1470,7 @@ namespace UAS_LabelMachine
             if (PrintMethod == "CodeSoft")
                 Print.CodeSoft.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
             else
-                Print.BarTender.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
+                Print.BarTender.OutPrint(OutFormat, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
         }
 
         private void CleanDetail_Click(object sender, EventArgs e)

+ 49 - 47
UAS-出货标签管理(贸易版)/生成条码.cs

@@ -195,11 +195,11 @@ namespace UAS_LabelMachine
                     string pd_orderdetno = ProdIoInfDGV.Rows[i].Cells["pd_orderdetno"].FormattedValue.ToString();
                     string pr_brand = ProdIoInfDGV.Rows[i].Cells["pr_brand"].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;
                     try
@@ -214,7 +214,7 @@ namespace UAS_LabelMachine
                     //如果中盘盒数量为1且有尾数则表示一箱未装满
                     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();
                     //中盒数量*中盒容量=需要打印的单盘标签
                     ArrayList<string> midcode = new ArrayList<string>();
@@ -241,11 +241,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();
                         //如果尾数不为0,并且已经遍历到了最后一箱(未装满的箱)
                         int count = 0;
-                        int AddNum = pr_zxbzs;
+                        double AddNum = pr_zxbzs;
                         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
                         {
@@ -404,30 +412,22 @@ namespace UAS_LabelMachine
             }
             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 = (本次数量 - restqty1) / (最小包装量 * 中盘容量);
-                    //计算中盘尾数
-                    if (((本次数量 - restqty1)) % (最小包装量 * 中盘容量) == 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_remain"].Value = 本次数量 - restqty1 - mid_num * 最小包装量 * 中盘容量;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].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) * 最小包装量 * 中盘容量;
                 }
             }
         }
@@ -437,6 +437,7 @@ namespace UAS_LabelMachine
         {
             for (int i = 0; i < ProdIoInfDGV.Rows.Count; i++)
             {
+                ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value = MidCapacity.Text;
                 int restqty1 = 0;
                 if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
                 {
@@ -448,27 +449,28 @@ namespace UAS_LabelMachine
                         restqty1 += qty;
                     }
                 }
-                ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value = MidCapacity.Text;
+                object pr_zxbzs = ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value;
+                object pd_qty = ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value;
+                object mid_qty = ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value;
+                object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
                 if (ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value.ToString() != "0")
                 {
-                    object pr_zxbzs = ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value;
-                    object pd_qty = ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value;
-                    object mid_qty = ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value;
-                    object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
-                    if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
+                    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))
                     {
-                        int 最小包装量 = int.Parse(pr_zxbzs.ToString());
-                        int 中盘容量 = int.Parse(mid_qty.ToString());
-                        int 本次数量 = int.Parse(pd_qty.ToString());
-                        int 总数 = int.Parse(pd_totalqty.ToString());
-                        //计算中盘数量
-                        int mid_num = (本次数量 - restqty1) / (最小包装量 * 中盘容量);
-                        //计算中盘尾数
-                        if (((本次数量 - restqty1)) % (最小包装量 * 中盘容量) == 0)
-                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
-                        else
-                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num + 1;
-                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = (本次数量 - restqty1) - mid_num * 最小包装量 * 中盘容量;
+                        ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
+                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
+                    }
+                    else
+                    {
+                        ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = Math.Floor(mid_num) + 1;
+                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - Math.Floor(mid_num) * 最小包装量 * 中盘容量;
                     }
                 }
             }