|
|
@@ -2235,218 +2235,201 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
public void ImportBarcode()
|
|
|
{
|
|
|
-
|
|
|
- string Prefix = "";
|
|
|
-
|
|
|
- string Suffix = "";
|
|
|
- //客户编号
|
|
|
- string CustCode = "";
|
|
|
- //编码规则编号
|
|
|
- string NrCode = "";
|
|
|
- DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length,nr_code,nvl(nrd_iscombine,-1)nrd_iscombine from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + CustCode + "' order by nrd_detno", "select");
|
|
|
- //如果没有则取公共规则
|
|
|
- if (Nr.Rows.Count == 0)
|
|
|
- Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length,nr_code,nvl(nrd_iscombine,-1)nrd_iscombine from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
|
|
|
- //用于过滤参数的正则表达式
|
|
|
- if (Nr.Rows.Count > 0)
|
|
|
- {
|
|
|
- NrCode = Nr.Rows[0]["nr_code"].ToString();
|
|
|
- }
|
|
|
- Regex match = new Regex("{\\w+}");
|
|
|
- //用于存放每一项的明细的数据
|
|
|
- string[] NrData = new string[Nr.Rows.Count];
|
|
|
- //流水号的索引
|
|
|
- int SerialNumIndex = 0;
|
|
|
- //流水长度
|
|
|
- int SerialNumLength = 0;
|
|
|
- //存放键值对
|
|
|
- int Radix = 10;
|
|
|
- string PrefixFixed = "";
|
|
|
- for (int m = 0; m < Nr.Rows.Count; m++)
|
|
|
- {
|
|
|
- switch (Nr.Rows[m]["nrd_type"].ToString())
|
|
|
- {
|
|
|
- //常量直接进行拼接
|
|
|
- case "常量":
|
|
|
- NrData[m] = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
- Prefix += NrData[m];
|
|
|
- Suffix += NrData[m];
|
|
|
- break;
|
|
|
- case "SQL":
|
|
|
- string SQL = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
- DataTable Temp;
|
|
|
- //如果不包含参数替换
|
|
|
- if (SQL.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //替换参数后重新执行SQL
|
|
|
- foreach (Match mch in match.Matches(SQL))
|
|
|
- {
|
|
|
- SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
|
|
|
- }
|
|
|
- Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
- }
|
|
|
- if (Temp.Rows.Count > 0)
|
|
|
- {
|
|
|
- NrData[m] = Temp.Rows[0][0].ToString();
|
|
|
- Prefix += NrData[m];
|
|
|
- Suffix += NrData[m];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- NrData[m] = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string Prefix = "";
|
|
|
+
|
|
|
+ string Suffix = "";
|
|
|
+ //客户编号
|
|
|
+ string CustCode = "";
|
|
|
+ //编码规则编号
|
|
|
+ string NrCode = "";
|
|
|
+ DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length,nr_code,nvl(nrd_iscombine,-1)nrd_iscombine from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + CustCode + "' order by nrd_detno", "select");
|
|
|
+ //如果没有则取公共规则
|
|
|
+ if (Nr.Rows.Count == 0)
|
|
|
+ Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length,nr_code,nvl(nrd_iscombine,-1)nrd_iscombine from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
|
|
|
+ //用于过滤参数的正则表达式
|
|
|
+ if (Nr.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ NrCode = Nr.Rows[0]["nr_code"].ToString();
|
|
|
+ }
|
|
|
+ Regex match = new Regex("{\\w+}");
|
|
|
+ //用于存放每一项的明细的数据
|
|
|
+ string[] NrData = new string[Nr.Rows.Count];
|
|
|
+ //流水号的索引
|
|
|
+ int SerialNumIndex = 0;
|
|
|
+ //流水长度
|
|
|
+ int SerialNumLength = 0;
|
|
|
+ //存放键值对
|
|
|
+ int Radix = 10;
|
|
|
+ string PrefixFixed = "";
|
|
|
+ for (int m = 0; m < Nr.Rows.Count; m++)
|
|
|
+ {
|
|
|
+ switch (Nr.Rows[m]["nrd_type"].ToString())
|
|
|
+ {
|
|
|
+ //常量直接进行拼接
|
|
|
+ case "常量":
|
|
|
+ NrData[m] = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
Prefix += NrData[m];
|
|
|
Suffix += NrData[m];
|
|
|
- }
|
|
|
- break;
|
|
|
- //流水需要通过MaxNumber去取
|
|
|
- case "流水":
|
|
|
- NrData[m] = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "'").ToString();
|
|
|
- Suffix = "";
|
|
|
- PrefixFixed = Prefix;
|
|
|
- //设置当前流水
|
|
|
- custserialnum = int.Parse(NrData[m] == "" ? "0" : NrData[m]);
|
|
|
- SerialNumIndex = m;
|
|
|
- SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
|
|
|
- Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //获取最大的流水号
|
|
|
- string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'").ToString();
|
|
|
- if (maxnum == "")
|
|
|
- {
|
|
|
- dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + NrCode + "','" + Prefix + "','1')", "insert");
|
|
|
- custserialnum = 1;
|
|
|
- }//如果流水号不为空则取当前流水
|
|
|
- else
|
|
|
- {
|
|
|
- custserialnum = int.Parse(maxnum);
|
|
|
- }
|
|
|
- dt = ExcelHandler.ExcelToDataTable(ImportExcel.FileName, true);
|
|
|
- if (dt == null)
|
|
|
- {
|
|
|
- MessageBox.Show("文件" + ImportExcel.FileName + "被占用");
|
|
|
- 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");
|
|
|
- DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- //需要插入的参数
|
|
|
- ArrayList<string> barcode = new ArrayList<string>();
|
|
|
- ArrayList<string> custbarcode = new ArrayList<string>();
|
|
|
- ArrayList<string> datecode = new ArrayList<string>();
|
|
|
- ArrayList<string> lotno = new ArrayList<string>();
|
|
|
- ArrayList<string> pib_inqty = new ArrayList<string>();
|
|
|
- ArrayList<string> piboutboxcode2 = new ArrayList<string>();
|
|
|
- ArrayList<string> pdordercode = new ArrayList<string>();
|
|
|
- ArrayList<string> pdorderdetno = new ArrayList<string>();
|
|
|
- ArrayList<string> pdpdno = new ArrayList<string>();
|
|
|
- ArrayList<string> pdid = new ArrayList<string>();
|
|
|
- ArrayList<string> prbrand = new ArrayList<string>();
|
|
|
- ArrayList<string> pdprodcode = new ArrayList<string>();
|
|
|
- //用于数量的校验
|
|
|
- Dictionary<string, decimal> sumqty = new 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();
|
|
|
- string DateCode = "";
|
|
|
- string LotNo = "";
|
|
|
- if (dt.Columns.Contains("DC/LOT NO"))
|
|
|
- {
|
|
|
- DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[0];
|
|
|
- LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[1];
|
|
|
- }
|
|
|
- if (dt.Columns.Contains("DC"))
|
|
|
- {
|
|
|
- DateCode = dt.Rows[i]["DC"].ToString();
|
|
|
- }
|
|
|
- if (dt.Columns.Contains("LOT NO"))
|
|
|
- {
|
|
|
- LotNo = dt.Rows[i]["LOT NO"].ToString();
|
|
|
- }
|
|
|
- string pib_outboxcode2 = dt.Rows[i]["箱号"].ToString();
|
|
|
- DataRow[] dr = dt1.Select("pr_orispeccode='" + pr_orispeccode + "'");
|
|
|
- if (dr.Length == 0)
|
|
|
- {
|
|
|
- LogicHandler.FilterData(cu_code.Text, "FUDAN", pr_orispeccode, qty, DateCode, LotNo, out pr_orispeccode, out qty, out DateCode, out LotNo);
|
|
|
- dr = dt1.Select("pr_orispeccode='" + pr_orispeccode + "'");
|
|
|
+ break;
|
|
|
+ case "SQL":
|
|
|
+ string SQL = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
+ DataTable Temp;
|
|
|
+ //如果不包含参数替换
|
|
|
+ if (SQL.IndexOf("{") == 0)
|
|
|
+ {
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //替换参数后重新执行SQL
|
|
|
+ foreach (Match mch in match.Matches(SQL))
|
|
|
+ {
|
|
|
+ SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
|
|
|
+ }
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
+ }
|
|
|
+ if (Temp.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ NrData[m] = Temp.Rows[0][0].ToString();
|
|
|
+ Prefix += NrData[m];
|
|
|
+ Suffix += NrData[m];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NrData[m] = "";
|
|
|
+ Prefix += NrData[m];
|
|
|
+ Suffix += NrData[m];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ //流水需要通过MaxNumber去取
|
|
|
+ case "流水":
|
|
|
+ NrData[m] = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "'").ToString();
|
|
|
+ Suffix = "";
|
|
|
+ PrefixFixed = Prefix;
|
|
|
+ //设置当前流水
|
|
|
+ custserialnum = int.Parse(NrData[m] == "" ? "0" : NrData[m]);
|
|
|
+ SerialNumIndex = m;
|
|
|
+ SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
|
|
|
+ Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ //获取最大的流水号
|
|
|
+ string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'").ToString();
|
|
|
+ if (maxnum == "")
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + NrCode + "','" + Prefix + "','1')", "insert");
|
|
|
+ custserialnum = 1;
|
|
|
+ }//如果流水号不为空则取当前流水
|
|
|
else
|
|
|
{
|
|
|
- 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)
|
|
|
- {
|
|
|
- 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();
|
|
|
- //已导入数量
|
|
|
- decimal zxbzs = decimal.Parse(dr[0]["pr_zxbzs"].ToString());
|
|
|
- decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
|
|
|
- decimal barcodenum = 0;
|
|
|
- if (!sumqty.ContainsKey(pr_orispeccode))
|
|
|
+ custserialnum = int.Parse(maxnum);
|
|
|
+ }
|
|
|
+ dt = ExcelHandler.ExcelToDataTable(ImportExcel.FileName, true);
|
|
|
+ if (dt == null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("文件" + ImportExcel.FileName + "被占用");
|
|
|
+ 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");
|
|
|
+ DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
+ //需要插入的参数
|
|
|
+ ArrayList<string> barcode = new ArrayList<string>();
|
|
|
+ ArrayList<string> custbarcode = new ArrayList<string>();
|
|
|
+ ArrayList<string> datecode = new ArrayList<string>();
|
|
|
+ ArrayList<string> lotno = new ArrayList<string>();
|
|
|
+ ArrayList<string> pib_inqty = new ArrayList<string>();
|
|
|
+ ArrayList<string> piboutboxcode2 = new ArrayList<string>();
|
|
|
+ ArrayList<string> pdordercode = new ArrayList<string>();
|
|
|
+ ArrayList<string> pdorderdetno = new ArrayList<string>();
|
|
|
+ ArrayList<string> pdpdno = new ArrayList<string>();
|
|
|
+ ArrayList<string> pdid = new ArrayList<string>();
|
|
|
+ ArrayList<string> prbrand = new ArrayList<string>();
|
|
|
+ ArrayList<string> pdprodcode = new ArrayList<string>();
|
|
|
+ //用于数量的校验
|
|
|
+ Dictionary<string, decimal> sumqty = new 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();
|
|
|
+ string DateCode = "";
|
|
|
+ string LotNo = "";
|
|
|
+ if (dt.Columns.Contains("DC/LOT NO"))
|
|
|
{
|
|
|
- sumqty.Add(pr_orispeccode, 0);
|
|
|
+ DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[0];
|
|
|
+ LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[1];
|
|
|
}
|
|
|
- //累计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 (dt.Columns.Contains("DC"))
|
|
|
{
|
|
|
- barcodenum = Math.Floor(outqty / zxbzs) + 1;
|
|
|
- //如果有余数先加上所有最小包最后加尾数
|
|
|
- for (int j = 0; j < barcodenum - 1; j++)
|
|
|
- {
|
|
|
- barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
- custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
- piboutboxcode2.Add(pib_outboxcode2);
|
|
|
- pib_inqty.Add(zxbzs);
|
|
|
- datecode.Add(DateCode);
|
|
|
- lotno.Add(LotNo);
|
|
|
- pdordercode.Add(pd_ordercode);
|
|
|
- pdorderdetno.Add(pd_orderdetno);
|
|
|
- pdpdno.Add(pd_pdno);
|
|
|
- pdid.Add(pd_id);
|
|
|
- prbrand.Add(pr_brand);
|
|
|
- pdprodcode.Add(pd_prodcode);
|
|
|
- }
|
|
|
- custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
- barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
- pib_inqty.Add(outqty % zxbzs);
|
|
|
- piboutboxcode2.Add(pib_outboxcode2);
|
|
|
- datecode.Add(DateCode);
|
|
|
- lotno.Add(LotNo);
|
|
|
- pdordercode.Add(pd_ordercode);
|
|
|
- pdorderdetno.Add(pd_orderdetno);
|
|
|
- pdpdno.Add(pd_pdno);
|
|
|
- pdid.Add(pd_id);
|
|
|
- prbrand.Add(pr_brand);
|
|
|
- pdprodcode.Add(pd_prodcode);
|
|
|
+ DateCode = dt.Rows[i]["DC"].ToString();
|
|
|
+ }
|
|
|
+ if (dt.Columns.Contains("LOT NO"))
|
|
|
+ {
|
|
|
+ LotNo = dt.Rows[i]["LOT NO"].ToString();
|
|
|
+ }
|
|
|
+ string pib_outboxcode2 = dt.Rows[i]["箱号"].ToString();
|
|
|
+ DataRow[] dr = dt1.Select("pr_orispeccode='" + pr_orispeccode + "'");
|
|
|
+ if (dr.Length == 0)
|
|
|
+ {
|
|
|
+ LogicHandler.FilterData(cu_code.Text, "FUDAN", pr_orispeccode, qty, DateCode, LotNo, out pr_orispeccode, out qty, out DateCode, out LotNo);
|
|
|
+ dr = dt1.Select("pr_orispeccode='" + pr_orispeccode + "'");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- barcodenum = outqty / zxbzs;
|
|
|
- for (int j = 0; j < barcodenum; j++)
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ 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();
|
|
|
+ //已导入数量
|
|
|
+ decimal zxbzs = decimal.Parse(dr[0]["pr_zxbzs"].ToString());
|
|
|
+ decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
|
|
|
+ decimal barcodenum = 0;
|
|
|
+ if (!sumqty.ContainsKey(pr_orispeccode))
|
|
|
{
|
|
|
- barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
+ sumqty.Add(pr_orispeccode, 0);
|
|
|
+ }
|
|
|
+ //累计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)
|
|
|
+ {
|
|
|
+ barcodenum = Math.Floor(outqty / zxbzs) + 1;
|
|
|
+ //如果有余数先加上所有最小包最后加尾数
|
|
|
+ for (int j = 0; j < barcodenum - 1; j++)
|
|
|
+ {
|
|
|
+ barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
+ custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
+ piboutboxcode2.Add(pib_outboxcode2);
|
|
|
+ pib_inqty.Add(zxbzs);
|
|
|
+ datecode.Add(DateCode);
|
|
|
+ lotno.Add(LotNo);
|
|
|
+ pdordercode.Add(pd_ordercode);
|
|
|
+ pdorderdetno.Add(pd_orderdetno);
|
|
|
+ pdpdno.Add(pd_pdno);
|
|
|
+ pdid.Add(pd_id);
|
|
|
+ prbrand.Add(pr_brand);
|
|
|
+ pdprodcode.Add(pd_prodcode);
|
|
|
+ }
|
|
|
custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
- pib_inqty.Add(zxbzs);
|
|
|
+ barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
+ pib_inqty.Add(outqty % zxbzs);
|
|
|
piboutboxcode2.Add(pib_outboxcode2);
|
|
|
datecode.Add(DateCode);
|
|
|
lotno.Add(LotNo);
|
|
|
@@ -2457,49 +2440,72 @@ namespace UAS_LabelMachine
|
|
|
prbrand.Add(pr_brand);
|
|
|
pdprodcode.Add(pd_prodcode);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ barcodenum = outqty / zxbzs;
|
|
|
+ for (int j = 0; j < barcodenum; j++)
|
|
|
+ {
|
|
|
+ barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
|
|
|
+ custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
+ pib_inqty.Add(zxbzs);
|
|
|
+ piboutboxcode2.Add(pib_outboxcode2);
|
|
|
+ datecode.Add(DateCode);
|
|
|
+ lotno.Add(LotNo);
|
|
|
+ pdordercode.Add(pd_ordercode);
|
|
|
+ pdorderdetno.Add(pd_orderdetno);
|
|
|
+ pdpdno.Add(pd_pdno);
|
|
|
+ pdid.Add(pd_id);
|
|
|
+ prbrand.Add(pr_brand);
|
|
|
+ pdprodcode.Add(pd_prodcode);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //插叙所有的统计数量
|
|
|
- string ErrMsg = "";
|
|
|
- foreach (var item in sumqty)
|
|
|
- {
|
|
|
- dt = (DataTable)dh.ExecuteSql("select nvl(sum(pd_outqty),0)pd_outqty,pr_orispeccode from prodiodetail left join product on pr_code=pd_prodcode where pd_piid=" + PI_ID + "group by pr_orispeccode", "select");
|
|
|
- dt1 = (DataTable)dh.ExecuteSql("select nvl(sum(pib_qty),0)pib_qty,pr_orispeccode from prodiobarcode left join product on pib_prodcode=pr_code where pib_piid=" + PI_ID + " group by pr_orispeccode", "select");
|
|
|
- DataRow[] dr = dt.Select("pr_orispeccode='" + item.Key + "'");
|
|
|
- DataRow[] dr1 = dt1.Select("pr_orispeccode='" + item.Key + "'");
|
|
|
- if (dr.Length > 0)
|
|
|
+ //插叙所有的统计数量
|
|
|
+ string ErrMsg = "";
|
|
|
+ foreach (var item in sumqty)
|
|
|
{
|
|
|
- decimal pd_outqty = decimal.Parse(dr[0]["pd_outqty"].ToString());
|
|
|
- decimal pib_qty = 0;
|
|
|
- //如果有已导入的数量
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- pib_qty = decimal.Parse(dr1[0]["pib_qty"].ToString());
|
|
|
- }
|
|
|
- //本次导入的数量和原有导入数量累加和出库数量做对比
|
|
|
- if (pd_outqty < item.Value + pib_qty)
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select nvl(sum(pd_outqty),0)pd_outqty,pr_orispeccode from prodiodetail left join product on pr_code=pd_prodcode where pd_piid=" + PI_ID + "group by pr_orispeccode", "select");
|
|
|
+ dt1 = (DataTable)dh.ExecuteSql("select nvl(sum(pib_qty),0)pib_qty,pr_orispeccode from prodiobarcode left join product on pib_prodcode=pr_code where pib_piid=" + PI_ID + " group by pr_orispeccode", "select");
|
|
|
+ DataRow[] dr = dt.Select("pr_orispeccode='" + item.Key + "'");
|
|
|
+ DataRow[] dr1 = dt1.Select("pr_orispeccode='" + item.Key + "'");
|
|
|
+ if (dr.Length > 0)
|
|
|
{
|
|
|
- ErrMsg += "型号" + dr[0]["pr_orispeccode"].ToString() + "出货数量" + pd_outqty + ",已导入数量" + pib_qty + ",本次导入" + item.Value + ",超出数量" + (item.Value + pib_qty - pd_outqty) + "\n";
|
|
|
+ decimal pd_outqty = decimal.Parse(dr[0]["pd_outqty"].ToString());
|
|
|
+ decimal pib_qty = 0;
|
|
|
+ //如果有已导入的数量
|
|
|
+ if (dr1.Length > 0)
|
|
|
+ {
|
|
|
+ pib_qty = decimal.Parse(dr1[0]["pib_qty"].ToString());
|
|
|
+ }
|
|
|
+ //本次导入的数量和原有导入数量累加和出库数量做对比
|
|
|
+ if (pd_outqty < item.Value + pib_qty)
|
|
|
+ {
|
|
|
+ ErrMsg += "型号" + dr[0]["pr_orispeccode"].ToString() + "出货数量" + pd_outqty + ",已导入数量" + pib_qty + ",本次导入" + item.Value + ",超出数量" + (item.Value + pib_qty - pd_outqty) + "\n";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (ErrMsg == "")
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_PDNO,");
|
|
|
+ sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,pib_datecode,pib_lotno,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,pib_orderdetno,pib_outboxcode2,pib_custbarcode)");
|
|
|
+ sql.Append(" values (prodiobarcode_seq.nextval,:pd_prodcode,'" + User.UserName + "',sysdate,'" + pi_inoutno.Text + "'");
|
|
|
+ sql.Append("," + PI_ID + ",:pr_brand,:barcode,:pd_pdno,:pd_id,");
|
|
|
+ sql.Append("'" + pi_class.Text + "',:pib_inqty,:pib_datecode,:pib_lotno,0,0,:pd_ordercode,'',:pd_orderdetno,:outboxcode,:custbarcode)");
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "pd_prodcode", "pr_brand", "barcode", "pd_pdno", "pd_id", "pib_inqty", "pib_datecode", "pib_lotno", "pd_ordercode", "pd_orderdetno", "outboxcode", "custbarcode" }, pdprodcode.ToArray(), prbrand.ToArray(), barcode.ToArray(), pdpdno.ToArray(), pdid.ToArray(), pib_inqty.ToArray(), datecode.ToArray(), lotno.ToArray(), pdordercode.ToArray(), pdorderdetno.ToArray(), piboutboxcode2.ToArray(), custbarcode.ToArray());
|
|
|
+ //更新流水
|
|
|
+ dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
|
|
|
+ LoadGridData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show(ErrMsg, "超出数量提醒");
|
|
|
+ }
|
|
|
}
|
|
|
- if (ErrMsg == "")
|
|
|
- {
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_PDNO,");
|
|
|
- sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,pib_datecode,pib_lotno,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,pib_orderdetno,pib_outboxcode2,pib_custbarcode)");
|
|
|
- sql.Append(" values (prodiobarcode_seq.nextval,:pd_prodcode,'" + User.UserName + "',sysdate,'" + pi_inoutno.Text + "'");
|
|
|
- sql.Append("," + PI_ID + ",:pr_brand,:barcode,:pd_pdno,:pd_id,");
|
|
|
- sql.Append("'" + pi_class.Text + "',:pib_inqty,:pib_datecode,:pib_lotno,0,0,:pd_ordercode,'',:pd_orderdetno,:outboxcode,:custbarcode)");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "pd_prodcode", "pr_brand", "barcode", "pd_pdno", "pd_id", "pib_inqty", "pib_datecode", "pib_lotno", "pd_ordercode", "pd_orderdetno", "outboxcode", "custbarcode" }, pdprodcode.ToArray(), prbrand.ToArray(), barcode.ToArray(), pdpdno.ToArray(), pdid.ToArray(), pib_inqty.ToArray(), datecode.ToArray(), lotno.ToArray(), pdordercode.ToArray(), pdorderdetno.ToArray(), piboutboxcode2.ToArray(), custbarcode.ToArray());
|
|
|
- //更新流水
|
|
|
- dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
|
|
|
- LoadGridData();
|
|
|
- }
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- MessageBox.Show(ErrMsg, "超出数量提醒");
|
|
|
+ MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|