|
|
@@ -2356,10 +2356,10 @@ namespace UAS_LabelMachine
|
|
|
return;
|
|
|
}
|
|
|
sql.Clear();
|
|
|
- sql.Append("select pr_orispeccode,pd_outqty,pr_id,pd_piclass,pd_piid,pd_id,pr_zxbzs,pr_brand,pd_pdno");
|
|
|
- sql.Append(",pd_prodcode,pd_ordercode,pd_orderdetno from prodiodetail left join product on pd_prodcode=pr_code ");
|
|
|
- sql.Append("where pd_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pd_outqty,");
|
|
|
- sql.Append("pr_id,pd_piclass,pd_piid,pd_id,pr_zxbzs,pr_brand,pd_pdno,pd_id,pd_prodcode,pd_ordercode,pd_orderdetno");
|
|
|
+ sql.Append("select pr_orispeccode,pd_outqty-nvl(sum(pib_qty),0) pd_outqty,pr_id,pd_piclass,pd_piid,pd_id,pr_zxbzs,pr_brand,pd_pdno,");
|
|
|
+ sql.Append("pd_prodcode,pd_ordercode,pd_orderdetno from prodiodetail left join product on pd_prodcode=pr_code left join prodiobarcode ");
|
|
|
+ sql.Append("on pd_id=pib_pdid where pd_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pd_outqty,");
|
|
|
+ sql.Append("pr_id,pd_piclass,pd_piid,pd_id,pr_zxbzs,pr_brand,pd_pdno,pd_id,pd_prodcode,pd_ordercode,pd_orderdetno order by pd_pdno");
|
|
|
DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
//需要插入的参数
|
|
|
ArrayList<string> barcode = new ArrayList<string>();
|
|
|
@@ -2376,6 +2376,36 @@ namespace UAS_LabelMachine
|
|
|
ArrayList<string> pdprodcode = new ArrayList<string>();
|
|
|
//用于数量的校验
|
|
|
Dictionary<string, decimal> sumqty = new Dictionary<string, decimal>();
|
|
|
+ Dictionary<string, Dictionary<string, decimal>> outsumqty = new Dictionary<string, Dictionary<string, decimal>>();
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ string pr_orispeccode = dt.Rows[i]["规格型号"].ToString();
|
|
|
+ string qty = dt.Rows[i]["数量"].ToString();
|
|
|
+ //累计Excel该型号的数量
|
|
|
+ if (!sumqty.ContainsKey(pr_orispeccode))
|
|
|
+ {
|
|
|
+ sumqty.Add(pr_orispeccode, 0);
|
|
|
+ }
|
|
|
+ //累计Excel该型号的数量
|
|
|
+ sumqty[pr_orispeccode] += decimal.Parse(qty);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < dt1.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ //不包含型号则进行添加
|
|
|
+ string pr_orispeccode = dt1.Rows[i]["pr_orispeccode"].ToString();
|
|
|
+ string pd_pdno = dt1.Rows[i]["pd_pdno"].ToString();
|
|
|
+ decimal pd_outqty = decimal.Parse(dt1.Rows[i]["pd_outqty"].ToString());
|
|
|
+ if (!outsumqty.ContainsKey(pr_orispeccode))
|
|
|
+ {
|
|
|
+ Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
|
|
|
+ dic.Add(pd_pdno, pd_outqty);
|
|
|
+ outsumqty.Add(pr_orispeccode, dic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ outsumqty[pr_orispeccode].Add(pd_pdno, pd_outqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
string pr_orispeccode = dt.Rows[i]["规格型号"].ToString();
|
|
|
@@ -2406,31 +2436,41 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
LogicHandler.FilterData(cu_code.Text, dr[0]["pr_brand"].ToString(), pr_orispeccode, qty, DateCode, LotNo, out pr_orispeccode, out qty, out DateCode, out LotNo);
|
|
|
}
|
|
|
- if (dr.Length > 0)
|
|
|
+ decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
|
|
|
+ for (int k = 0; k < dr.Length; k++)
|
|
|
{
|
|
|
- string pd_orderdetno = dr[0]["pd_orderdetno"].ToString();
|
|
|
- string pd_prodcode = dr[0]["pd_prodcode"].ToString();
|
|
|
- string pd_ordercode = dr[0]["pd_ordercode"].ToString();
|
|
|
- string pd_piid = dr[0]["pd_piid"].ToString();
|
|
|
- string pr_brand = dr[0]["pr_brand"].ToString();
|
|
|
- string pd_pdno = dr[0]["pd_pdno"].ToString();
|
|
|
- string pd_id = dr[0]["pd_id"].ToString();
|
|
|
- string pd_piclass = dr[0]["pd_piclass"].ToString();
|
|
|
- string pr_id = dr[0]["pr_id"].ToString();
|
|
|
+ string pd_orderdetno = dr[k]["pd_orderdetno"].ToString();
|
|
|
+ string pd_prodcode = dr[k]["pd_prodcode"].ToString();
|
|
|
+ string pd_ordercode = dr[k]["pd_ordercode"].ToString();
|
|
|
+ string pd_piid = dr[k]["pd_piid"].ToString();
|
|
|
+ string pr_brand = dr[k]["pr_brand"].ToString();
|
|
|
+ string pd_pdno = dr[k]["pd_pdno"].ToString();
|
|
|
+ string pd_id = dr[k]["pd_id"].ToString();
|
|
|
+ string pd_piclass = dr[k]["pd_piclass"].ToString();
|
|
|
+ string pr_id = dr[k]["pr_id"].ToString();
|
|
|
//已导入数量
|
|
|
- decimal zxbzs = decimal.Parse(dr[0]["pr_zxbzs"].ToString());
|
|
|
- decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
|
|
|
+ decimal zxbzs = decimal.Parse(dr[k]["pr_zxbzs"].ToString());
|
|
|
+ decimal pd_outqty = 0;
|
|
|
decimal barcodenum = 0;
|
|
|
- if (!sumqty.ContainsKey(pr_orispeccode))
|
|
|
+ if (outsumqty[pr_orispeccode][pd_pdno] == 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果导入行的数量小于改明细的出货数量
|
|
|
+ if (outsumqty[pr_orispeccode][pd_pdno] >= outqty)
|
|
|
{
|
|
|
- sumqty.Add(pr_orispeccode, 0);
|
|
|
+ //使用导入明细行数量
|
|
|
+ pd_outqty = outqty;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ////使用该出货单明细行数量,并且数量置为0
|
|
|
+ pd_outqty = outsumqty[pr_orispeccode][pd_pdno];
|
|
|
}
|
|
|
- //累计Excel该型号的数量
|
|
|
- sumqty[pr_orispeccode] += decimal.Parse(qty);
|
|
|
string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
|
|
|
- if (outqty % zxbzs != 0)
|
|
|
+ if (pd_outqty % zxbzs != 0)
|
|
|
{
|
|
|
- barcodenum = Math.Floor(outqty / zxbzs) + 1;
|
|
|
+ barcodenum = Math.Floor(pd_outqty / zxbzs) + 1;
|
|
|
//如果有余数先加上所有最小包最后加尾数
|
|
|
for (int j = 0; j < barcodenum - 1; j++)
|
|
|
{
|
|
|
@@ -2449,7 +2489,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
- pib_inqty.Add(outqty % zxbzs);
|
|
|
+ pib_inqty.Add(pd_outqty % zxbzs);
|
|
|
piboutboxcode2.Add(pib_outboxcode2);
|
|
|
datecode.Add(DateCode);
|
|
|
lotno.Add(LotNo);
|
|
|
@@ -2462,7 +2502,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- barcodenum = outqty / zxbzs;
|
|
|
+ barcodenum = pd_outqty / zxbzs;
|
|
|
for (int j = 0; j < barcodenum; j++)
|
|
|
{
|
|
|
barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
@@ -2479,6 +2519,8 @@ namespace UAS_LabelMachine
|
|
|
pdprodcode.Add(pd_prodcode);
|
|
|
}
|
|
|
}
|
|
|
+ outqty -= outsumqty[pr_orispeccode][pd_pdno];
|
|
|
+ outsumqty[pr_orispeccode][pd_pdno] -= pd_outqty;
|
|
|
}
|
|
|
}
|
|
|
//插叙所有的统计数量
|
|
|
@@ -2614,6 +2656,5 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
setvalueandprint.FindForm().Close();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|