|
|
@@ -191,11 +191,11 @@ namespace UAS_LabelMachine
|
|
|
string pr_brand = ProdIoInfDGV.Rows[i].Cells["pr_brand"].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;
|
|
|
try
|
|
|
@@ -210,7 +210,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>();
|
|
|
@@ -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();
|
|
|
//如果尾数不为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
|
|
|
{
|
|
|
@@ -251,7 +259,7 @@ namespace UAS_LabelMachine
|
|
|
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("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 + "')");
|
|
|
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>
|
|
|
private void ProdIoInfDGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
+
|
|
|
object pr_zxbzs = ProdIoInfDGV.Rows[e.RowIndex].Cells["pr_zxbzs"].Value;
|
|
|
object pd_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_qty"].Value;
|
|
|
object mid_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_qty"].Value;
|
|
|
object pd_totalqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_totalqty"].Value;
|
|
|
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 * 最小包装量 * 中盘容量;
|
|
|
}
|
|
|
+ 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;
|
|
|
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_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
|
|
|
+ }
|
|
|
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:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
|
|
|
}
|