Packing_PalletCollection_WN.cs 37 KB

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