LogicHandler.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Windows.Forms;
  7. using UAS_LabelMachine.Entity;
  8. namespace UAS_LabelMachine.PublicMethod
  9. {
  10. class LogicHandler
  11. {
  12. public static DataHelper dh = SystemInf.dh;
  13. /// <summary>
  14. /// 特殊业务过滤逻辑,目前只有海创在使用
  15. /// </summary>
  16. /// <param name="iCustCode"></param>
  17. /// <param name="iBrand"></param>
  18. /// <param name="iSpec"></param>
  19. /// <param name="iQty"></param>
  20. /// <param name="iDateCode"></param>
  21. /// <param name="iLotno"></param>
  22. /// <param name="oSpec"></param>
  23. /// <param name="oQty"></param>
  24. /// <param name="oDatecode"></param>
  25. /// <param name="oLotno"></param>
  26. public static void FilterData(string iCustCode, string iBrand, string iSpec, string iQty, string iDateCode, string iLotno, out string oSpec, out string oQty, out string oDatecode, out string oLotno)
  27. {
  28. oSpec = "";
  29. oQty = "";
  30. oDatecode = "";
  31. oLotno = "";
  32. string[] param = new string[] { iCustCode, iBrand, iSpec, iQty, iDateCode, iLotno, oSpec, oQty, oDatecode, oLotno };
  33. dh.CallProcedure("sp_datafilter", ref param);
  34. oSpec = param[6];
  35. oQty = param[7];
  36. oDatecode = param[8];
  37. oLotno = param[9];
  38. }
  39. /// <summary>
  40. /// 通用方法,日期格式转换,转换成指定的年月日
  41. /// </summary>
  42. /// <param name="iDatecode"></param>
  43. /// <param name="iCustcode"></param>
  44. /// <param name="oYear"></param>
  45. /// <param name="oMonth"></param>
  46. /// <param name="oDay"></param>
  47. /// <param name="oDate"></param>
  48. public static void GetTimeFromDatecode(string iDatecode, string iCustcode, out string oYear, out string oMonth, out string oDay, out string oDate)
  49. {
  50. oYear = "0";
  51. oMonth = "0";
  52. oDay = "0";
  53. oDate = "19000101";
  54. string[] param = new string[] { iDatecode, iCustcode, oYear, oMonth, oDay, oDate };
  55. dh.CallProcedure("GETTIMEFROMDATECODE", ref param);
  56. oYear = param[2];
  57. oMonth = param[3];
  58. oDay = param[4];
  59. oDate = param[5];
  60. }
  61. /// <summary>
  62. /// 特殊业务条码处理,目前针对海创长城客户
  63. /// </summary>
  64. /// <param name="iInoutno"></param>
  65. /// <param name="oSQL"></param>
  66. public static void CustBarCode(string iInoutno, out string oSQL)
  67. {
  68. oSQL = "";
  69. string[] param = new string[] { iInoutno, oSQL };
  70. dh.CallProcedure("SP_CUSTBARCODE", ref param);
  71. oSQL = param[1];
  72. }
  73. /// <summary>
  74. /// 特殊业务条码处理,目前针对海创长城客户
  75. /// </summary>
  76. /// <param name="iInoutno"></param>
  77. /// <param name="oSQL"></param>
  78. public static void SP_OUTCUSTBARCODE(string iInoutno, string iCondition)
  79. {
  80. string[] param = new string[] { iInoutno, iCondition };
  81. dh.CallProcedure("SP_OUTCUSTBARCODE", ref param);
  82. }
  83. public static bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
  84. {
  85. oErrorMessage = "";
  86. string SQL = "select em_code from employee where upper(em_code)=:UserName and em_password =:PassWord";
  87. DataTable dt;
  88. dt = (DataTable)dh.ExecuteSql(SQL, "select", iUserCode.ToUpper(), iPassWord);
  89. if (dt.Rows.Count > 0)
  90. return true;
  91. else
  92. {
  93. oErrorMessage = "用户名或者密码不正确!";
  94. return false;
  95. }
  96. }
  97. /// <summary>
  98. /// 自定义界面代码
  99. /// </summary>
  100. /// <param name="iPiId"></param>
  101. public static void CustInit(string iPiId)
  102. {
  103. string oContent = "";
  104. try
  105. {
  106. string[] param = new string[] { iPiId, oContent };
  107. dh.CallProcedure("SP_CUSTINIT", ref param);
  108. oContent = param[1];
  109. }
  110. catch (Exception)
  111. {
  112. }
  113. BaseUtil.CustomerInit(oContent);
  114. }
  115. /// <summary>
  116. /// 获取生成条码的SQL,目前添加用户海创和凯而高,凯而高有特殊定制逻辑
  117. /// </summary>
  118. /// <param name="iPiid"></param>
  119. /// <param name="iCustCode"></param>
  120. /// <param name="oSQL"></param>
  121. public static void GenerateBarCode(string iPiid, string iCustCode, out string oSQL)
  122. {
  123. oSQL = "";
  124. string[] param = new string[] { iPiid, iCustCode, oSQL };
  125. dh.CallProcedure("sp_GenerateBarCode", ref param);
  126. oSQL = param[2];
  127. }
  128. public static void ImportExcel(string iMaster, string iFileName, string iPiID, string iInOutNo, string iCustCode)
  129. {
  130. string config = dh.GetConfig("Master", "PrintMaster").ToString();
  131. switch (config)
  132. {
  133. //海创
  134. case "N_HC":
  135. ImportExcel_HC(iFileName, iPiID, iInOutNo, iCustCode);
  136. break;
  137. case "SZSI_TEST":
  138. ImportExcel_SZSI(iFileName, iPiID, iInOutNo, iCustCode);
  139. break;
  140. case "SZSI":
  141. ImportExcel_SZSI(iFileName, iPiID, iInOutNo, iCustCode);
  142. break;
  143. default:
  144. break;
  145. }
  146. }
  147. public static void ImportExcel_SZSI(string iFileName, string iPiID, string iInOutNo, string iCustCode)
  148. {
  149. StringBuilder sql = new StringBuilder();
  150. //获取最大的流水号
  151. DataTable dt = ExcelHandler.ExcelToDataTable(iFileName, true);
  152. if (dt == null)
  153. {
  154. MessageBox.Show("文件" + iFileName + "被占用或者格式不正确");
  155. return;
  156. }
  157. ArrayList<string> detno = new ArrayList<string>();
  158. ArrayList<string> batch = new ArrayList<string>();
  159. ArrayList<string> gk = new ArrayList<string>();
  160. ArrayList<string> weigh = new ArrayList<string>();
  161. ArrayList<string> qty = new ArrayList<string>();
  162. ArrayList<string> outboxcode1 = new ArrayList<string>();
  163. string prcode = dh.getFieldDataByCondition("prodiodetail", "pd_prodcode", "pd_piid=" + iPiID).ToString();
  164. for (int i = 0; i < dt.Rows.Count; i++)
  165. {
  166. if (dt.Columns.Contains("序号")) { detno.Add(dt.Rows[i]["序号"]); } else detno.Add("");
  167. if (dt.Columns.Contains("批号")) { batch.Add(dt.Rows[i]["批号"]); } else batch.Add("");
  168. if (dt.Columns.Contains("g/K")) { gk.Add(dt.Rows[i]["g/K"]); } else gk.Add("");
  169. if (dt.Columns.Contains("净重(g)")) { weigh.Add(dt.Rows[i]["净重(g)"]); } else weigh.Add("");
  170. if (dt.Columns.Contains("数量")) { qty.Add(dt.Rows[i]["数量"]); } else qty.Add("");
  171. if (dt.Columns.Contains("盒号")) { outboxcode1.Add(dt.Rows[i]["盒号"]); } else outboxcode1.Add("");
  172. }
  173. sql.Clear();
  174. sql.Append("insert into prodiobarcode (pib_id,pib_piid,pib_inoutno,pib_pdno,pib_custbarcode,pib_gk,pib_weigh,pib_qty,pib_outboxcode1,pib_prodcode) values(prodiobarcode_seq.nextval,'" + iPiID + "',");
  175. sql.Append("'" + iInOutNo + "',:pib_pdno,:pib_lotno,:pib_gk,:pib_weiht,:pib_qty,:pib_outboxcode1,'" + prcode + "')");
  176. dh.BatchInsert(sql.ToString(), new string[] { "pib_pdno", "pib_lotno", "pib_gk", "pib_weiht", "pib_qty", "pib_outboxcode1" }, detno.ToArray(), batch.ToArray(), gk.ToArray(), weigh.ToArray(), qty.ToArray(), outboxcode1.ToArray());
  177. }
  178. //海创的导入方法
  179. public static void ImportExcel_HC(string iFileName, string iPiID, string iInOutNo, string iCustCode)
  180. {
  181. StringBuilder sql = new StringBuilder();
  182. //获取最大的流水号
  183. DataTable dt = ExcelHandler.ExcelToDataTable(iFileName, true);
  184. if (dt == null)
  185. {
  186. MessageBox.Show("文件" + iFileName + "被占用或者格式不正确");
  187. return;
  188. }
  189. dt = BaseUtil.filterDataTable(dt, "规格型号 <>''");
  190. string outsql = "";
  191. GenerateBarCode(iPiID, iCustCode, out outsql);
  192. sql.Clear();
  193. sql.Append(outsql);
  194. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  195. //需要插入的参数
  196. ArrayList<string> barcode = new ArrayList<string>();
  197. ArrayList<string> custbarcode = new ArrayList<string>();
  198. ArrayList<string> datecode = new ArrayList<string>();
  199. ArrayList<string> lotno = new ArrayList<string>();
  200. ArrayList<string> pib_inqty = new ArrayList<string>();
  201. ArrayList<string> piboutboxcode2 = new ArrayList<string>();
  202. ArrayList<string> pdordercode = new ArrayList<string>();
  203. ArrayList<string> pdorderdetno = new ArrayList<string>();
  204. ArrayList<string> pdpdno = new ArrayList<string>();
  205. ArrayList<string> pdid = new ArrayList<string>();
  206. ArrayList<string> prbrand = new ArrayList<string>();
  207. ArrayList<string> pdprodcode = new ArrayList<string>();
  208. ArrayList<string> pib_custoutboxcode = new ArrayList<string>();
  209. ArrayList<string> brand = new ArrayList<string>();
  210. ArrayList<string> madein = new ArrayList<string>();
  211. ArrayList<string> prdetail = new ArrayList<string>();
  212. ArrayList<string> ordercode = new ArrayList<string>();
  213. ArrayList<string> size = new ArrayList<string>();
  214. ArrayList<string> weight = new ArrayList<string>();
  215. //用于数量的校验
  216. Dictionary<string, decimal> sumqty = new Dictionary<string, decimal>();
  217. Dictionary<string, Dictionary<string, decimal>> outsumqty = new Dictionary<string, Dictionary<string, decimal>>();
  218. for (int i = 0; i < dt.Rows.Count; i++)
  219. {
  220. string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
  221. if (pr_spec.Trim() == "")
  222. {
  223. break;
  224. }
  225. string qty = Regex.Replace(dt.Rows[i]["数量"].ToString(), @"[^\d]*", ""); ;
  226. //累计Excel该型号的数量
  227. if (!sumqty.ContainsKey(pr_spec))
  228. {
  229. sumqty.Add(pr_spec, 0);
  230. }
  231. //累计Excel该型号的数量
  232. sumqty[pr_spec] += decimal.Parse(qty);
  233. }
  234. DataTable temp = dt.Clone();
  235. temp.Columns["箱号"].DataType = typeof(int);
  236. foreach (DataRow s in dt.Rows)
  237. {
  238. temp.ImportRow(s);//导入旧数据
  239. }
  240. temp.DefaultView.Sort = "箱号";
  241. dt = temp.DefaultView.ToTable();
  242. for (int i = 0; i < dt1.Rows.Count; i++)
  243. {
  244. //不包含型号则进行添加
  245. string pr_spec = dt1.Rows[i]["pr_spec"].ToString().Trim();
  246. string pd_pdno = dt1.Rows[i]["pd_pdno"].ToString();
  247. decimal pd_outqty = decimal.Parse(dt1.Rows[i]["pd_outqty"].ToString());
  248. if (!outsumqty.ContainsKey(pr_spec))
  249. {
  250. Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
  251. dic.Add(pd_pdno, pd_outqty);
  252. outsumqty.Add(pr_spec, dic);
  253. }
  254. else
  255. {
  256. outsumqty[pr_spec].Add(pd_pdno, pd_outqty);
  257. }
  258. }
  259. //上一个的最小外箱号,如果箱号没有发生变化则外箱条码也不变化
  260. for (int i = 0; i < dt.Rows.Count; i++)
  261. {
  262. string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
  263. string 品牌 = dt.Rows[i]["品牌"].ToString().Trim();
  264. string 产地 = dt.Rows[i]["产地"].ToString().Trim();
  265. string 尺寸 = dt.Rows[i]["尺寸"].ToString().Trim();
  266. string 重量 = dt.Rows[i]["重量"].ToString().Trim();
  267. string 产品名称 = dt.Rows[i]["产品名称"].ToString().Trim();
  268. string 订单编号 = dt.Rows[i]["订单编号"].ToString().Trim();
  269. if (pr_spec.Trim() == "")
  270. {
  271. break;
  272. }
  273. string qty = dt.Rows[i]["数量"].ToString();
  274. string DateCode = "";
  275. string LotNo = "";
  276. if (dt.Columns.Contains("DC/LOT NO"))
  277. {
  278. if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf("-") > 0)
  279. {
  280. DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[0];
  281. LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[1];
  282. }
  283. else if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf(" ") > 0)
  284. {
  285. DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[0];
  286. LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[1];
  287. }
  288. }
  289. if (dt.Columns.Contains("DC") && DateCode == "")
  290. {
  291. DateCode = dt.Rows[i]["DC"].ToString();
  292. }
  293. if (dt.Columns.Contains("LOT NO") && LotNo == "")
  294. {
  295. LotNo = dt.Rows[i]["LOT NO"].ToString();
  296. }
  297. string pib_outboxcode2 = dt.Rows[i]["箱号"].ToString();
  298. DataRow[] dr = dt1.Select("pr_spec='" + pr_spec + "'");
  299. if (dr.Length == 0)
  300. {
  301. FilterData(iCustCode, "FUDAN", pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
  302. dr = dt1.Select("pr_spec='" + pr_spec + "'");
  303. }
  304. else
  305. {
  306. FilterData(iCustCode, dr[0]["pr_brand"].ToString(), pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
  307. }
  308. DataRow datarow = null;
  309. //获取指定行的数据,先被扣除完
  310. if (dr.Length > 0)
  311. {
  312. for (int m = 0; m < dr.Length; m++)
  313. {
  314. if (outsumqty[pr_spec][dr[m]["pd_pdno"].ToString()] != 0)
  315. {
  316. datarow = dr[m];
  317. break;
  318. }
  319. }
  320. }
  321. if (dr.Length == 0)
  322. {
  323. MessageBox.Show("出货单" + iInOutNo + "不包含型号" + pr_spec);
  324. return;
  325. }
  326. if (datarow == null)
  327. {
  328. MessageBox.Show("请检查型号" + pr_spec);
  329. return;
  330. }
  331. decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
  332. for (int k = 0; k < 1; k++)
  333. {
  334. string pd_orderdetno = datarow["pd_orderdetno"].ToString();
  335. string pd_prodcode = datarow["pd_prodcode"].ToString();
  336. string pd_ordercode = datarow["pd_ordercode"].ToString();
  337. string pd_piid = datarow["pd_piid"].ToString();
  338. string pr_brand = datarow["pr_brand"].ToString();
  339. string pd_pdno = datarow["pd_pdno"].ToString();
  340. string pd_id = datarow["pd_id"].ToString();
  341. string pd_piclass = datarow["pd_piclass"].ToString();
  342. string pr_id = datarow["pr_id"].ToString();
  343. string pr_madein = datarow["pr_madein"].ToString();
  344. //已导入数量
  345. decimal zxbzs = decimal.Parse(datarow["pr_zxbzs"].ToString());
  346. decimal pd_outqty = 0;
  347. decimal barcodenum = 0;
  348. if (outsumqty[pr_spec][pd_pdno] == 0)
  349. {
  350. continue;
  351. }
  352. //如果导入行的数量小于改明细的出货数量
  353. if (outsumqty[pr_spec][pd_pdno] >= outqty)
  354. {
  355. //使用导入明细行数量
  356. pd_outqty = outqty;
  357. }
  358. else
  359. {
  360. ////使用该出货单明细行数量,并且数量置为0
  361. pd_outqty = outsumqty[pr_spec][pd_pdno];
  362. }
  363. string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + iInOutNo + "'").ToString();
  364. if (pd_outqty % zxbzs != 0)
  365. {
  366. barcodenum = Math.Floor(pd_outqty / zxbzs) + 1;
  367. //如果有余数先加上所有最小包最后加尾数
  368. for (int j = 0; j < barcodenum - 1; j++)
  369. {
  370. barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
  371. custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
  372. pib_custoutboxcode.Add(pib_outboxcode2);
  373. piboutboxcode2.Add(pib_outboxcode2);
  374. pib_inqty.Add(zxbzs);
  375. datecode.Add(DateCode);
  376. lotno.Add(LotNo);
  377. pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
  378. pdorderdetno.Add(pd_orderdetno);
  379. pdpdno.Add(pd_pdno);
  380. pdid.Add(pd_id);
  381. prbrand.Add(品牌 == "" ? pr_brand : 品牌);
  382. madein.Add(产地 == "" ? pr_madein : 产地);
  383. size.Add(尺寸);
  384. weight.Add(重量);
  385. prdetail.Add(产品名称);
  386. ordercode.Add(订单编号);
  387. pdprodcode.Add(pd_prodcode);
  388. }
  389. custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
  390. pib_custoutboxcode.Add(pib_outboxcode2);
  391. barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
  392. pib_inqty.Add(pd_outqty % zxbzs);
  393. piboutboxcode2.Add(pib_outboxcode2);
  394. datecode.Add(DateCode);
  395. lotno.Add(LotNo);
  396. pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
  397. pdorderdetno.Add(pd_orderdetno);
  398. pdpdno.Add(pd_pdno);
  399. pdid.Add(pd_id);
  400. prbrand.Add(品牌 == "" ? pr_brand : 品牌);
  401. madein.Add(产地 == "" ? pr_madein : 产地);
  402. size.Add(尺寸);
  403. weight.Add(重量);
  404. prdetail.Add(产品名称);
  405. ordercode.Add(订单编号);
  406. pdprodcode.Add(pd_prodcode);
  407. }
  408. else
  409. {
  410. barcodenum = pd_outqty / zxbzs;
  411. for (int j = 0; j < barcodenum; j++)
  412. {
  413. barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
  414. custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
  415. pib_custoutboxcode.Add(pib_outboxcode2);
  416. pib_inqty.Add(zxbzs);
  417. piboutboxcode2.Add(pib_outboxcode2);
  418. datecode.Add(DateCode);
  419. lotno.Add(LotNo);
  420. pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
  421. pdorderdetno.Add(pd_orderdetno);
  422. pdpdno.Add(pd_pdno);
  423. pdid.Add(pd_id);
  424. prbrand.Add(品牌 == "" ? pr_brand : 品牌);
  425. madein.Add(产地 == "" ? pr_madein : 产地);
  426. size.Add(尺寸);
  427. weight.Add(重量);
  428. prdetail.Add(产品名称);
  429. pdprodcode.Add(pd_prodcode);
  430. }
  431. }
  432. if (outqty - outsumqty[pr_spec][pd_pdno] > 0) {
  433. outqty -= outsumqty[pr_spec][pd_pdno];
  434. }
  435. outsumqty[pr_spec][pd_pdno] -= pd_outqty;
  436. if (outsumqty[pr_spec][pd_pdno] >= pd_outqty)
  437. {
  438. break;
  439. }
  440. }
  441. }
  442. string Lastoutbox = "";
  443. string Lastoutboxcode = "";
  444. List<string> custoutboxcode = new List<string>();
  445. //根据记录的箱号,在料盘的流水之后拼接外箱的流水
  446. for (int i = 0; i < pib_custoutboxcode.Count; i++)
  447. {
  448. if (Lastoutbox != pib_custoutboxcode[i].ToString())
  449. {
  450. Lastoutboxcode = BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix);
  451. custoutboxcode.Add(Lastoutboxcode);
  452. Lastoutbox = pib_custoutboxcode[i].ToString();
  453. }
  454. else
  455. {
  456. custoutboxcode.Add(Lastoutboxcode);
  457. }
  458. }
  459. //插叙所有的统计数量
  460. string ErrMsg = "";
  461. foreach (var item in sumqty)
  462. {
  463. dt = (DataTable)dh.ExecuteSql("select nvl(sum(pd_outqty),0)pd_outqty,pr_spec from prodiodetail left join product on pr_code=pd_prodcode where pd_piid='" + iPiID + "' group by pr_spec", "select");
  464. dt1 = (DataTable)dh.ExecuteSql("select nvl(sum(pib_qty),0)pib_qty,pr_spec from prodiobarcode left join product on pib_prodcode=pr_code where pib_piid='" + iPiID + "' group by pr_spec", "select");
  465. DataRow[] dr = dt.Select("pr_spec='" + item.Key + "'");
  466. DataRow[] dr1 = dt1.Select("pr_spec='" + item.Key + "'");
  467. if (dr.Length > 0)
  468. {
  469. decimal pd_outqty = decimal.Parse(dr[0]["pd_outqty"].ToString());
  470. decimal pib_qty = 0;
  471. //如果有已导入的数量
  472. if (dr1.Length > 0)
  473. {
  474. pib_qty = decimal.Parse(dr1[0]["pib_qty"].ToString());
  475. }
  476. //本次导入的数量和原有导入数量累加和出库数量做对比
  477. if (pd_outqty < item.Value + pib_qty)
  478. {
  479. ErrMsg += "型号" + dr[0]["pr_spec"].ToString() + "出货数量" + pd_outqty + ",已导入数量" + pib_qty + ",本次导入" + item.Value + ",超出数量" + (item.Value + pib_qty - pd_outqty) + "\n";
  480. }
  481. }
  482. }
  483. if (ErrMsg == "")
  484. {
  485. if (pdprodcode.Count > 0)
  486. {
  487. sql.Clear();
  488. sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_PDNO,");
  489. sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,pib_datecode,pib_lotno,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,pib_orderdetno,");
  490. sql.Append("pib_outboxcode2,pib_custbarcode,pib_custoutboxcode,pib_madein,pib_size,pib_weight,pib_prdetail)values(prodiobarcode_seq.nextval,:pd_prodcode,'" + User.UserName + "',sysdate,");
  491. sql.Append("'" + iInOutNo + "'," + iPiID + ",:pr_brand,:barcode,:pd_pdno,:pd_id,'',:pib_inqty,");
  492. sql.Append(":pib_datecode,:pib_lotno,0,-1,:pd_ordercode,:pd_orderdetno,:outboxcode,:custbarcode,:pib_custoutboxcode,:pib_madein,:pib_size,:pib_weight,:pib_prdetail)");
  493. 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", "pib_custoutboxcode", "pib_madein", "pib_size", "pib_weight", "pib_prdetail" }, 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(), custoutboxcode.ToArray(), madein.ToArray(), size.ToArray(), weight.ToArray(), prdetail.ToArray());
  494. //更新流水
  495. dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + UAS_出货标签打印.custserialnum + "'", "rmn_nrcode='" + UAS_出货标签打印.NrCode + "' and rmn_prefix='" + UAS_出货标签打印.Prefix + "'");
  496. }
  497. else
  498. {
  499. MessageBox.Show("解析数据不包含出货单数据,请重新导入", "提示");
  500. }
  501. }
  502. else
  503. {
  504. MessageBox.Show(ErrMsg, "超出数量提醒");
  505. }
  506. }
  507. //生成客户条码
  508. public static string BarcodeMethod1(string Prefix, string Suffix, int Index, int Length, int radix)
  509. {
  510. string str = Prefix;
  511. //如果是流水则需要在前面加0
  512. string serialcode = BaseUtil.DToAny(UAS_出货标签打印.custserialnum, radix);
  513. for (int j = serialcode.ToString().Length; j < Length; j++)
  514. {
  515. serialcode = "0" + serialcode;
  516. }
  517. str += serialcode;
  518. str += Suffix;
  519. UAS_出货标签打印.custserialnum = UAS_出货标签打印.custserialnum + 1;
  520. return str;
  521. }
  522. public static void GetDataSQL(string iInoutno, string iText, string iNumOrRate, out string oSQL)
  523. {
  524. oSQL = "";
  525. string[] param = new string[] { iInoutno, iText, iNumOrRate, oSQL };
  526. dh.CallProcedure("SP_GETDATASQL1", ref param);
  527. oSQL = param[3];
  528. }
  529. public static void GenHFEData(string iInoutno)
  530. {
  531. string[] param = new string[] { iInoutno };
  532. dh.CallProcedure("sp_InsertHFE", ref param);
  533. }
  534. }
  535. }