Make_PalletCollection.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. using LabelManager2;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Windows.Forms;
  11. using UAS_MES.DataOperate;
  12. using UAS_MES.Entity;
  13. using UAS_MES.PublicForm;
  14. using UAS_MES.PublicMethod;
  15. namespace UAS_MES.Make
  16. {
  17. public partial class Make_PalletCollection : Form
  18. {
  19. AutoSizeFormClass asc = new AutoSizeFormClass();
  20. DataHelper dh;
  21. DataTable dt;
  22. LogStringBuilder sql = new LogStringBuilder();
  23. Make_NewPallet NewPallet;
  24. string pa_nextstep = "";
  25. //箱类型
  26. string pa_type;
  27. //物料编号
  28. string pr_code;
  29. //Package表的主键
  30. string pa_id;
  31. ApplicationClass lbl;
  32. Document doc;
  33. Thread thread;
  34. string ErrorMessage = "";
  35. public Make_PalletCollection()
  36. {
  37. InitializeComponent();
  38. }
  39. //创建打印进程
  40. private void NewPrint()
  41. {
  42. try
  43. {
  44. lbl = new ApplicationClass();
  45. BaseUtil.WriteLbl();
  46. }
  47. catch
  48. {
  49. OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
  50. }
  51. }
  52. private void Make_PalletCollection_Load(object sender, EventArgs e)
  53. {
  54. asc.controllInitializeSize(this);
  55. thread = new Thread(NewPrint);
  56. SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
  57. BaseUtil.SetFormCenter(stw);
  58. stw.ShowDialog();
  59. OutBoxLength.Text = BaseUtil.GetCacheData("PalletLength").ToString();
  60. PalletPreFix.Text = BaseUtil.GetCacheData("PalletPreFix").ToString();
  61. dh = SystemInf.dh;
  62. StepCount.StepCode = User.CurrentStepCode;
  63. StepCount.Source = User.UserSourceCode;
  64. StepCount.LineCode = User.UserLineCode;
  65. StepCount.Dh = dh;
  66. StepCount.Start();
  67. }
  68. private void Clean_Click(object sender, EventArgs e)
  69. {
  70. OperateResult.Clear();
  71. }
  72. private void palletcode_KeyDown(object sender, KeyEventArgs e)
  73. {
  74. if (e.KeyCode == Keys.Enter)
  75. {
  76. string pa_type = dh.getFieldDataByCondition("package", "pa_type", "pa_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
  77. if (pa_type == "1")
  78. {
  79. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "为卡通箱,不可进行操作\n", Color.Red, pa_outboxcode);
  80. return;
  81. }
  82. else if (pa_type == "2")
  83. {
  84. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "为大箱,不可进行操作\n", Color.Red, pa_outboxcode);
  85. return;
  86. }
  87. LoadGridData();
  88. sql.Clear();
  89. sql.Append("select pa_makecode,pa_id,pa_status,nvl(pa_standardqty,PR_PALLETQTY)pa_standardqty,pa_prodcode,pa_packageqty,pa_totalqty,pa_salecode,pa_currentqty,pr_code pa_prodcode,pa_outboxcode,pa_totalqty,pa_custcode ");
  90. sql.Append("from package left join packagedetail on pa_id =pd_paid left join product on pr_code=pd_prodcode where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type =3");
  91. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  92. if (dt.Rows.Count > 0)
  93. {
  94. BaseUtil.SetFormValue(Controls, dt);
  95. pa_id = dt.Rows[0]["pa_id"].ToString();
  96. }
  97. if (CheckOutBoxLength())
  98. {
  99. if (pa_standardqty.Text == "")
  100. pa_standardqty.Focus();
  101. else
  102. outboxcode.Focus();
  103. }
  104. }
  105. }
  106. //箱号Enter事件
  107. private void outboxcode_KeyDown(object sender, KeyEventArgs e)
  108. {
  109. if (e.KeyCode == Keys.Enter)
  110. {
  111. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  112. {
  113. if (outboxcode.Text == "")
  114. {
  115. OperateResult.AppendText(">>箱号不能为空\n", Color.Red);
  116. return;
  117. }
  118. sql.Clear();
  119. sql.Append("select nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_makecode pd_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_salecode pd_salecode,pr_packrule,pa_id,pa_prodcode pd_prodcode,pa_status,pa_mothercode,pa_nextstep,pa_weight ");
  120. sql.Append("from packagedetail left join package on pd_paid=pa_id left join product on pd_prodcode=pr_code where pd_outboxcode='" + outboxcode.Text + "'");
  121. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  122. if (dt.Rows.Count > 0)
  123. {
  124. BaseUtil.SetFormValue(this.Controls, dt);
  125. if (dt.Rows[0]["pa_status"].ToString() != "1")
  126. {
  127. OperateResult.AppendText(">>箱号" + outboxcode.Text + "未封箱不允许采集\n", Color.Red, outboxcode);
  128. return;
  129. }
  130. if (dt.Rows[0]["pa_downstatus"].ToString() != "0")
  131. {
  132. OperateResult.AppendText(">>箱号" + outboxcode.Text + "下地状态不允许采集\n", Color.Red, outboxcode);
  133. return;
  134. }
  135. if (dt.Rows[0]["pa_outno"].ToString() != "")
  136. {
  137. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  138. return;
  139. }
  140. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  141. {
  142. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已入库不允许采集\n", Color.Red, outboxcode);
  143. return;
  144. }
  145. if (dt.Rows[0]["pa_weight"].ToString() == ""&& dt.Rows[0]["pd_prodcode"].ToString() != "")
  146. {
  147. if(dh.getFieldDataByCondition("product", "pr_checkcartonw","pr_code = '"+ dt.Rows[0]["pd_prodcode"].ToString() + "'").ToString() == "-1")
  148. {
  149. OperateResult.AppendText(">>箱号" + outboxcode.Text + "未称重,对应产品"+ dt.Rows[0]["pd_prodcode"].ToString() + "需要称重,不允许采集\n", Color.Red, outboxcode);
  150. return;
  151. }
  152. }
  153. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  154. {
  155. if (pa_outboxcode.Text == "")
  156. {
  157. pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
  158. palletcode_KeyDown(sender, e);
  159. }
  160. }
  161. string unfinpack = dh.getFieldDataByCondition("Line", "nvl(li_allowUnFinPack,0)", "li_code='" + User.UserLineCode + "'").ToString();
  162. pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
  163. if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "" && (unfinpack == "0" || unfinpack == ""))
  164. {
  165. OperateResult.AppendText(">>箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序\n", Color.Red, outboxcode);
  166. return;
  167. }
  168. sql.Clear();
  169. sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno,pa_type from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
  170. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  171. if (dt.Rows.Count > 0)
  172. {
  173. if (dt.Rows[0]["pa_type"].ToString() != "3")
  174. {
  175. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "类型并非栈板,不允许操作\n", Color.Red);
  176. return;
  177. }
  178. if (dt.Rows[0]["pa_outno"].ToString() != "")
  179. {
  180. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  181. return;
  182. }
  183. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  184. {
  185. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red);
  186. return;
  187. }
  188. }
  189. //为空表示线外
  190. if (pa_nextstep == "")
  191. {
  192. //判断线外,必须已完工并且未入库
  193. dt = (DataTable)dh.ExecuteSql("select wm_concat(ms_sncode) from mes_package_view left join makeserial on v_barcode=ms_sncode and v_makecode = ms_makecode where v_outboxcode='" + outboxcode.Text + "' and ms_status<>2", "select");
  194. if (dt.Rows[0][0].ToString() != "" && (unfinpack != "0" || unfinpack == ""))
  195. {
  196. OperateResult.AppendText(">>序列号" + dt.Rows[0][0].ToString() + "尚未完工\n", Color.Red);
  197. return;
  198. }
  199. }
  200. }
  201. else
  202. {
  203. OperateResult.AppendText(">>箱号" + outboxcode.Text + "未采集内容或不存在,不允许装栈板\n", Color.Red, outboxcode);
  204. return;
  205. }
  206. if (!Cancel.Checked)
  207. {
  208. pa_status.Text = dh.getFieldDataByCondition("package", "nvl(pa_status,0)pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  209. if (pa_outboxcode.Text == "" && AutoOutBoxCode.Checked)
  210. {
  211. //箱已采集满并且未勾选自动生成
  212. if (pa_standardqty.Text == pa_totalqty.Text && !AutoOutBoxCode.Checked)
  213. {
  214. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已采集满\n", Color.Red, outboxcode);
  215. return;
  216. }
  217. else
  218. {
  219. pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", "", pa_prodcode.Text, User.UserCode);
  220. }
  221. }
  222. else if (pa_outboxcode.Text != "" && pa_status.Text == "1" && AutoOutBoxCode.Checked)
  223. {
  224. pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", "", pa_prodcode.Text, User.UserCode);
  225. }
  226. else if (pa_outboxcode.Text == "")
  227. {
  228. OperateResult.AppendText(">>栈板号不能为空\n", Color.Red);
  229. return;
  230. }
  231. if (!CheckOutBoxLength())
  232. {
  233. return;
  234. }
  235. dt = (DataTable)dh.ExecuteSql("select pa_id from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  236. if (dt.Rows.Count == 0)
  237. {
  238. pa_id = dh.GetSEQ("package_seq");
  239. sql.Clear();
  240. sql.Append("insert into package (pa_id,pa_outboxcode,PA_STANDARDQTY,pa_makecode,pa_indate,pa_packageqty,pa_type,pa_prodcode,pa_level,PA_STATUS,pa_sccode,pa_currentstep,pa_salecode)values");
  241. sql.Append("(" + pa_id + ",'" + pa_outboxcode.Text + "','" + pa_standardqty.Text + "','" + pd_makecode.Text + "',sysdate,'0',3,'" + pd_prodcode.Text + "',0,0,'" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + pd_salecode.Text + "')");
  242. dh.ExecuteSql(sql.GetString(), "insert");
  243. }
  244. else
  245. {
  246. pa_id = dt.Rows[0]["pa_id"].ToString();
  247. }
  248. palletcode_KeyDown(sender, e);
  249. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) > 0)
  250. {
  251. if (!LogicHandler.CheckPackRule(pr_packrule.Text, pa_outboxcode.Text, outboxcode.Text, pa_makecode.Text, pa_salecode.Text, pa_prodcode.Text, "栈板", out ErrorMessage))
  252. {
  253. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, outboxcode);
  254. return;
  255. }
  256. }
  257. dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_mothercode,nvl(pa_status,0) pa_status from package where pa_outboxcode='" + outboxcode.Text + "'", "select");
  258. if (dt.Rows.Count > 0)
  259. {
  260. //判断是否已经装箱
  261. int sonboxtotalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString());
  262. if (dt.Rows[0]["pa_mothercode"].ToString() == "")
  263. {
  264. if (dt.Rows[0]["pa_status"].ToString() == "1")
  265. {
  266. pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  267. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) + sonboxtotalqty > int.Parse(pa_standardqty.Text == "" ? "0" : pa_standardqty.Text))
  268. {
  269. OperateResult.AppendText(">>采集箱号" + outboxcode.Text + "后超出容量\n", Color.Red, outboxcode);
  270. return;
  271. }
  272. if (checkbox11.Checked)
  273. {
  274. if (outinfo.Text == "" || ininfo.Text == "")
  275. {
  276. OperateResult.AppendText("箱号信息校验,请输入外箱信息\n", Color.Red);
  277. ininfo.Focus();
  278. ininfo.SelectAll();
  279. return;
  280. }
  281. if (outinfo.Text != ininfo.Text)
  282. {
  283. OperateResult.AppendText("箱号信息校验,外箱信息与栈板信息不一致\n", Color.Red);
  284. ininfo.Focus();
  285. ininfo.SelectAll();
  286. return;
  287. }
  288. }
  289. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) == 0)
  290. {
  291. dh.ExecuteSql("update package set pa_prodcode='" + pd_prodcode.Text + "',pa_salecode='" + pd_salecode.Text + "',pa_makecode='" + pd_makecode.Text + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  292. }
  293. List<string> SQLS = new List<string>();
  294. sql.Clear();
  295. sql.Append("insert into packagedetail(pd_id, pd_paid, pd_outboxcode,pd_makecode,pd_prodcode,pd_innerboxcode, pd_innerqty,pd_builddate)");
  296. sql.Append("select packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + pd_makecode.Text + "','" + pd_prodcode.Text + "','" + outboxcode.Text + "' ");
  297. sql.Append(",(select nvl(sum(pd_innerqty),0) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode=");
  298. sql.Append("'" + outboxcode.Text + "'),sysdate from package where pa_outboxcode='" + outboxcode.Text + "'");
  299. SQLS.Add(sql.GetString());
  300. //如果采集完这个超出了容量提示
  301. SQLS.Add("update package set PA_CURRENTQTY=nvl(PA_CURRENTQTY,0)+1,PA_PACKAGEQTY=nvl(PA_PACKAGEQTY,0)+1,PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "') where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type=3");
  302. SQLS.Add("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + outboxcode.Text + "'");
  303. dh.ExecuteSQLTran(SQLS.ToArray());
  304. //更新大箱的栈板号
  305. if (dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "")
  306. {
  307. string carton_macode = dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + outboxcode.Text + "'").ToString();
  308. pa_makecode.Text = carton_macode;
  309. dh.ExecuteSql("update package set pa_makecode='" + carton_macode + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  310. }
  311. //如果是线内并且下一工序等于当前岗位资源工序
  312. if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode)
  313. {
  314. LogicHandler.OutBoxStepPass(outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集", out ErrorMessage);
  315. }
  316. if (pa_totalqty.Text == "1")
  317. {
  318. string nextstepcode = dh.getFieldDataByCondition("mes_package_view left join makeserial on ms_sncode=v_barcode", "ms_nextstepcode", "v_outboxcode='" + outboxcode.Text + "'").ToString();
  319. dh.UpdateByCondition("package", "pa_nextstep='" + nextstepcode + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  320. }
  321. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "栈板采集", "栈板" + pa_outboxcode.Text + "采集箱" + outboxcode.Text + "成功,额外信息:"+ininfo.Text, pa_outboxcode.Text, "");
  322. OperateResult.AppendText(">>箱号" + outboxcode.Text + "采集成功!\n", Color.Green, outboxcode);
  323. ininfo.Clear();
  324. LoadCollectNum();
  325. palletcode_KeyDown(sender, e);
  326. if (pa_standardqty.Text == pa_totalqty.Text)
  327. {
  328. dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  329. OperateResult.AppendText("栈板" + pa_outboxcode.Text + "已装满,封栈板成功\n");
  330. if (!AutoOutBoxCode.Checked)
  331. {
  332. pa_outboxcode.Focus();
  333. pa_outboxcode.SelectAll();
  334. }
  335. else
  336. {
  337. outboxcode.Focus();
  338. outboxcode.SelectAll();
  339. }
  340. if (AutoPrint.Checked)
  341. {
  342. OperateResult.AppendText(">>打印栈板" + pa_outboxcode.Text + ",自动打印!\n", Color.Green);
  343. Printlab.PerformClick();
  344. }
  345. }
  346. }
  347. else OperateResult.AppendText(">>箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode);
  348. }
  349. else
  350. {
  351. if (dt.Rows[0]["pa_mothercode"].ToString() == pa_outboxcode.Text)
  352. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已在本栈板内\n", Color.Red, outboxcode);
  353. else
  354. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已采集至栈板" + dt.Rows[0]["pa_mothercode"].ToString() + "\n", Color.Red, outboxcode);
  355. }
  356. }
  357. else OperateResult.AppendText(">>箱号" + outboxcode.Text + "不存在\n", Color.Red, outboxcode);
  358. }
  359. //进行拆箱操作
  360. else
  361. {
  362. sql.Clear();
  363. sql.Append("select nvl(pa_iostatus,0)pa_iostatus from packagedetail left join package on pa_id =pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "' ");
  364. sql.Append("and pd_innerboxcode='" + outboxcode.Text + "'");
  365. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  366. if (dt.Rows.Count > 0)
  367. {
  368. if (dt.Rows[0]["pa_iostatus"].ToString() == "0")
  369. {
  370. List<string> SQLS = new List<string>();
  371. //删除明细
  372. SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "' and pd_innerboxcode='" + outboxcode.Text + "'");
  373. //减少箱内容量
  374. SQLS.Add("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-(select pa_totalqty from package where pa_outboxcode='" + outboxcode.Text + "'),pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'");
  375. SQLS.Add("update package set pa_mothercode='' where pa_outboxcode='" + outboxcode.Text + "'");
  376. dh.ExecuteSQLTran(SQLS.ToArray());
  377. OperateResult.AppendText(">>箱号" + outboxcode.Text + "取消采集成功\n", Color.Green);
  378. LoadCollectNum();
  379. palletcode_KeyDown(sender, e);
  380. outboxcode.Clear();
  381. }
  382. else OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已入库,不允许取消采集\n", Color.Red);
  383. }
  384. else OperateResult.AppendText(">>箱号" + outboxcode.Text + "不在栈板" + pa_outboxcode.Text + "\n", Color.Red);
  385. }
  386. }
  387. }
  388. }
  389. private void LoadGridData()
  390. {
  391. sql.Clear();
  392. sql.Append("select pd_prodcode,nvl(pd_barcode,PD_INNERBOXCODE) code ,pd_innerqty,pa_salecode");
  393. sql.Append(",pd_makecode,pa_prodcode,pa_custcode,pa_packageqty from packagedetail left join package on pd_paid=pa_id left ");
  394. sql.Append("join product on pr_code=pa_prodcode where pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=3");
  395. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  396. if (dt.Rows.Count == 0 && dh.CheckExist("package", "pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=3"))
  397. {
  398. dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_makecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  399. }
  400. BaseUtil.FillDgvWithDataTable(PackageInf, dt);
  401. }
  402. private void FillPrintLabel()
  403. {
  404. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,substr(la_url,instr(la_url,'\\',-1)+1)la_name,la_url,la_isdefault from label where la_prodcode='" + pa_prodcode.Text + "' and la_templatetype='栈板标' and la_statuscode='AUDITED' order by la_isdefault", "select");
  405. PrintLabel.DataSource = _dt;
  406. PrintLabel.DisplayMember = "la_url";
  407. PrintLabel.ValueMember = "la_id";
  408. }
  409. private void LoadCollectNum()
  410. {
  411. pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type=3").ToString();
  412. }
  413. private void Make_PalletCollection_SizeChanged(object sender, EventArgs e)
  414. {
  415. asc.controlAutoSize(this);
  416. }
  417. private void NewPallet_Click(object sender, EventArgs e)
  418. {
  419. NewPallet = new Make_NewPallet("PALLET", pa_makecode.Text);
  420. NewPallet.Controls["Confirm"].Click += Make_PalletCollection_Click;
  421. BaseUtil.SetFormCenter(NewPallet);
  422. NewPallet.ShowDialog();
  423. }
  424. private void Make_PalletCollection_Click(object sender, EventArgs e)
  425. {
  426. pa_outboxcode.Text = NewPallet.OutBoxCode;
  427. palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  428. NewPallet.Close();
  429. }
  430. private void Print_Click(object sender, EventArgs e)
  431. {
  432. if (PrintLabel.Items.Count != 0)
  433. {
  434. if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
  435. {
  436. if (!AutoOutBoxCode.Checked)
  437. {
  438. pa_outboxcode.Focus();
  439. pa_outboxcode.SelectAll();
  440. }
  441. else {
  442. outboxcode.Focus();
  443. outboxcode.SelectAll();
  444. }
  445. //doc = lbl.Documents.Open(PrintLabel.Text);
  446. if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "栈板标", "0", out ErrorMessage))
  447. {
  448. OperateResult.AppendText(">>打印栈板" + pa_outboxcode.Text + "\n", Color.Black);
  449. }
  450. else
  451. {
  452. OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
  453. }
  454. }
  455. else OperateResult.AppendText(">>必须封栈板才能进行打印\n", Color.Red);
  456. }
  457. else OperateResult.AppendText(">>产品" + pa_prodcode.Text + "未维护打印标签\n", Color.Red);
  458. }
  459. private void ReleasePallet_Click(object sender, EventArgs e)
  460. {
  461. if (dh.getRowCount("packagedetail", "pd_outboxcode='" + pa_outboxcode.Text + "'") > 0)
  462. {
  463. string Delete = MessageBox.Show(this.ParentForm, "是否确认拆栈板?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  464. if (Delete == "Yes")
  465. {
  466. sql.Clear();
  467. sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
  468. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  469. if (dt.Rows.Count > 0)
  470. {
  471. if (dt.Rows[0]["pa_outno"].ToString() != "")
  472. {
  473. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  474. return;
  475. }
  476. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  477. {
  478. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red);
  479. return;
  480. }
  481. }
  482. //如果含有下一执行步骤的撤销过站,否则直接删除
  483. if (dh.getFieldDataByCondition("package", "pa_nextstep", "pa_mothercode='" + pa_outboxcode.Text + "'").ToString() != "")
  484. LogicHandler.OutBoxDrawStepPass(pa_outboxcode.Text, pa_makecode.Text, User.UserSourceCode);
  485. else
  486. {
  487. List<string> SQLS = new List<string>();
  488. SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'");
  489. SQLS.Add("update package set pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'");
  490. SQLS.Add("update package set pa_mothercode='' where pa_mothercode='" + pa_outboxcode.Text + "'");
  491. dh.ExecuteSQLTran(SQLS.ToArray());
  492. }
  493. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "栈板采集", "解除栈板" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, "");
  494. OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "解除成功\n", Color.Green);
  495. palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  496. }
  497. }
  498. else OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "未采集箱\n", Color.Red);
  499. }
  500. private void Make_PalletCollection_FormClosing(object sender, FormClosingEventArgs e)
  501. {
  502. BaseUtil.ClosePrint(lbl);
  503. }
  504. private void Packing_Click(object sender, EventArgs e)
  505. {
  506. if (pa_outboxcode.Text != "")
  507. {
  508. sql.Clear();
  509. sql.Append("select nvl(pa_status,0) pa_status from packagedetail left join package ");
  510. sql.Append("on pa_id=pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "'");
  511. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  512. if (dt.Rows.Count > 0)
  513. {
  514. if (dt.Rows[0]["pa_status"].ToString() == "0")
  515. {
  516. string Seal = MessageBox.Show(this.ParentForm, "是否确认封栈板?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  517. if (Seal == "Yes")
  518. {
  519. OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "装栈板成功\n", Color.Green);
  520. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "栈板采集", "封栈板" + pa_outboxcode.Text + "成功", outboxcode.Text, "");
  521. dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  522. pa_status.Text = "1";
  523. if (!AutoOutBoxCode.Checked)
  524. {
  525. pa_outboxcode.Focus();
  526. pa_outboxcode.SelectAll();
  527. }
  528. else
  529. {
  530. outboxcode.Focus();
  531. outboxcode.SelectAll();
  532. }
  533. }
  534. }
  535. else OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "已封栈板\n", Color.Red);
  536. }
  537. else OperateResult.AppendText(">>栈板号" + pa_outboxcode.Text + "未采集内容\n", Color.Red);
  538. }
  539. else OperateResult.AppendText(">>栈板号不能为空\n", Color.Red);
  540. }
  541. private void PrintLabel_SelectedValueChanged(object sender, EventArgs e)
  542. {
  543. if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView")
  544. {
  545. string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString();
  546. PrintNum.Text = (PrintNums == "" ? "1" : PrintNums);
  547. }
  548. }
  549. private void pa_prodcode_TextChanged(object sender, EventArgs e)
  550. {
  551. FillPrintLabel();
  552. }
  553. private void pa_standardqty_KeyDown(object sender, KeyEventArgs e)
  554. {
  555. if (e.KeyCode == Keys.Enter)
  556. {
  557. ResetPackageQTY();
  558. }
  559. }
  560. private void ResetPackageQTY()
  561. {
  562. if (pa_outboxcode.Text != "")
  563. {
  564. DataTable dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_status from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  565. if (dt.Rows.Count > 0)
  566. {
  567. string total = dt.Rows[0]["pa_totalqty"].ToString();
  568. if (int.Parse(pa_standardqty.Text) >= int.Parse(total))
  569. {
  570. dh.UpdateByCondition("package", "pa_standardqty='" + pa_standardqty.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  571. OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "修改容量成功,已修改为" + pa_standardqty.Text + "\n", Color.Green);
  572. outboxcode.Focus();
  573. return;
  574. }
  575. else OperateResult.AppendText(">>容量不能小于已装数量\n", Color.Red);
  576. }
  577. else outboxcode.Focus();
  578. }
  579. }
  580. private bool CheckOutBoxLength()
  581. {
  582. //勾选了检验长度进行校验
  583. if (OutBoxLength.Text != "")
  584. {
  585. try
  586. {
  587. int.Parse(OutBoxLength.Text);
  588. }
  589. catch (Exception)
  590. {
  591. MessageBox.Show("请填写正确的箱号长度");
  592. return false;
  593. }
  594. if (pa_outboxcode.Text.Length != int.Parse(OutBoxLength.Text))
  595. {
  596. OperateResult.AppendText(">>箱号长度错误,请重新输入箱号\n", Color.Red);
  597. return false;
  598. }
  599. else return true;
  600. }
  601. if (PalletPreFix.Text != "")
  602. {
  603. try
  604. {
  605. if (pa_outboxcode.Text.Substring(0, PalletPreFix.Text.Length) != PalletPreFix.Text)
  606. {
  607. OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
  608. return false;
  609. }
  610. }
  611. catch (Exception)
  612. {
  613. OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
  614. return false;
  615. }
  616. }
  617. return true;
  618. }
  619. private void OutBoxLength_KeyDown(object sender, KeyEventArgs e)
  620. {
  621. if (e.KeyCode == Keys.Enter)
  622. {
  623. try
  624. {
  625. if (OutBoxLength.Text != "")
  626. {
  627. int.Parse(OutBoxLength.Text);
  628. }
  629. BaseUtil.SetCacheData("PalletLength", OutBoxLength.Text);
  630. pa_outboxcode.Focus();
  631. }
  632. catch (Exception)
  633. {
  634. OutBoxLength.Clear();
  635. MessageBox.Show("请输入正确的长度");
  636. }
  637. }
  638. }
  639. private void PalletPreFix_KeyDown(object sender, KeyEventArgs e)
  640. {
  641. if (e.KeyCode == Keys.Enter)
  642. {
  643. BaseUtil.SetCacheData("PalletPreFix", PalletPreFix.Text);
  644. pa_outboxcode.Focus();
  645. }
  646. }
  647. private void ininfo_KeyDown(object sender, KeyEventArgs e)
  648. {
  649. if (e.KeyCode == Keys.Enter)
  650. {
  651. if (checkbox11.Checked && ininfo.Text != "")
  652. {
  653. outboxcode.Focus();
  654. outboxcode.SelectAll();
  655. outboxcode_KeyDown(sender, e);
  656. }
  657. }
  658. }
  659. }
  660. }