Packing_BigBoxCollection.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. using DevExpress.XtraSpellChecker;
  2. using LabelManager2;
  3. using Seagull.BarTender.Print;
  4. using System;
  5. using System.Collections.Generic;
  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_BigBoxCollection : Form
  17. {
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataHelper dh;
  20. DataTable dt;
  21. LogStringBuilder sql = new LogStringBuilder();
  22. Document doc;
  23. Packing_NewBigBox NewBigBox;
  24. string pa_id;
  25. ApplicationClass lbl;
  26. Thread thread;
  27. string ErrorMessage = "";
  28. string pa_nextstep = "";
  29. Engine engine;
  30. public Packing_BigBoxCollection()
  31. {
  32. InitializeComponent();
  33. }
  34. //创建打印进程
  35. private void NewPrint()
  36. {
  37. try
  38. {
  39. engine = new Engine(true);
  40. //BaseUtil.WriteLbl();
  41. }
  42. catch
  43. {
  44. OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red);
  45. }
  46. }
  47. private void 栈板称重_Load(object sender, EventArgs e)
  48. {
  49. asc.controllInitializeSize(this);
  50. AutoOutBoxCode.Checked = true;
  51. OutBoxLength.Enabled = false;
  52. OutBoxLength.Enabled = false;
  53. pa_outboxcode.Enabled = false;
  54. thread = new Thread(NewPrint);
  55. SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
  56. BaseUtil.SetFormCenter(stw);
  57. stw.ShowDialog();
  58. dh = SystemInf.dh;
  59. StepCount.StepCode = User.CurrentStepCode;
  60. StepCount.Source = User.UserSourceCode;
  61. StepCount.LineCode = User.UserLineCode;
  62. StepCount.Dh = dh;
  63. StepCount.Start();
  64. }
  65. private void Clean_Click(object sender, EventArgs e)
  66. {
  67. OperateResult.Clear();
  68. }
  69. //大箱号Enter事件
  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_id,nvl(pa_standardqty,'0')pa_standardqty,pa_makecode,pa_prodcode,pa_id,pa_packageqty,pa_outboxcode,pa_totalqty,pa_currentqty, ");
  77. sql.Append("pa_salecode,pa_custcode from package where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type =2");
  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. sql.Clear();
  106. sql.Append("select nvl(pa_iostatus,0)pa_iostatus,pa_outno, pd_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_salecode pd_salecode,");
  107. sql.Append("pr_packrule,pa_id,pa_prodcode pd_prodcode,pa_status,pa_mothercode,pa_nextstep from packagedetail left ");
  108. sql.Append("join package on pd_paid=pa_id left join product on pd_prodcode=pr_code where pd_outboxcode='" + outboxcode.Text + "'");
  109. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  110. //判断采集的卡通箱是否有明细
  111. if (dt.Rows.Count > 0)
  112. {
  113. BaseUtil.SetFormValue(this.Controls, dt);
  114. pa_makecode.Text = dt.Rows[0]["pd_makecode"].ToString();
  115. if (dt.Rows[0]["pa_downstatus"].ToString() != "0")
  116. {
  117. OperateResult.AppendText(">>箱号" + outboxcode.Text + "下地状态不允许采集\n", Color.Red, outboxcode);
  118. return;
  119. }
  120. if (dt.Rows[0]["pa_outno"].ToString() != "")
  121. {
  122. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red, outboxcode);
  123. return;
  124. }
  125. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  126. {
  127. OperateResult.AppendText(">>箱号" + outboxcode.Text + "已入库不允许采集\n", Color.Red, outboxcode);
  128. return;
  129. }
  130. //之前装过箱加载明细
  131. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  132. {
  133. if (pa_outboxcode.Text == "")
  134. {
  135. pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
  136. palletcode_KeyDown(sender, e);
  137. }
  138. }
  139. pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
  140. if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "")
  141. {
  142. OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序,下一工序为" + pa_nextstep + "\n", Color.Red, outboxcode);
  143. return;
  144. }
  145. sql.Clear();
  146. sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno,pa_mothercode,pa_type from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
  147. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  148. if (dt.Rows.Count > 0)
  149. {
  150. if (dt.Rows[0]["pa_type"].ToString() != "2")
  151. {
  152. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "类型并非大箱,不允许操作\n", Color.Red);
  153. return;
  154. }
  155. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  156. {
  157. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被栈板" + dt.Rows[0]["pa_mothercode"].ToString() + "采集,不允许操作\n", Color.Red);
  158. return;
  159. }
  160. if (dt.Rows[0]["pa_outno"].ToString() != "")
  161. {
  162. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  163. return;
  164. }
  165. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  166. {
  167. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red);
  168. return;
  169. }
  170. }
  171. //为空表示线外
  172. if (pa_nextstep == "")
  173. {
  174. //判断线外,必须已完工并且未入库
  175. dt = (DataTable)dh.ExecuteSql("select wm_concat(ms_sncode) from mes_package_view left join makeserial on v_makecode=ms_makecode and ms_sncode=v_barcode where v_outboxcode='" + outboxcode.Text + "' and ms_status<>2", "select");
  176. if (dt.Rows[0][0].ToString() != "")
  177. {
  178. ////判断箱未入库
  179. //dt = (DataTable)dh.ExecuteSql("select count(1) from package where pa_outboxcode='" + outboxcode.Text + "' and nvl(pa_iostatus,0)<>0", "select");
  180. //if (dt.Rows[0][0].ToString() != "0")
  181. //{
  182. // OperateResult.AppendText(">>卡通箱" + outboxcode.Text + "已入库,不允许装箱\n", Color.Red);
  183. // return;
  184. //}
  185. OperateResult.AppendText(">>序列号" + dt.Rows[0][0].ToString() + "尚未完工\n", Color.Red);
  186. return;
  187. }
  188. }
  189. }
  190. else
  191. {
  192. OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "未采集内容或不存在,不允许装大箱\n", Color.Red, outboxcode);
  193. return;
  194. }
  195. if (!Cancel.Checked)
  196. {
  197. pa_status.Text = dh.getFieldDataByCondition("package", "nvl(pa_status,0)pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  198. if (pa_standardqty.Text == pa_totalqty.Text && pa_status.Text == "0")
  199. {
  200. dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  201. pa_status.Text = "1";
  202. }
  203. //如果箱号为空的时候并且勾选了自动生成
  204. if (pa_outboxcode.Text == "" && AutoOutBoxCode.Checked || pa_status.Text == "1")
  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("BIGBOX", pa_makecode.Text, pa_prodcode.Text, User.UserCode);
  215. }
  216. }
  217. else if (pa_outboxcode.Text == "")
  218. {
  219. OperateResult.AppendText(">>大箱号不能为空\n", Color.Red);
  220. return;
  221. }
  222. if (!CheckOutBoxLength())
  223. {
  224. return;
  225. }
  226. //箱号不存在进行插入
  227. DataTable dt = (DataTable)dh.ExecuteSql("select pa_id from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  228. if (dt.Rows.Count == 0)
  229. {
  230. pa_id = dh.GetSEQ("package_seq");
  231. sql.Clear();
  232. sql.Append("insert into package (pa_id,pa_outboxcode,pa_makecode,pa_indate,pa_packageqty,pa_type,pa_prodcode,pa_level,PA_STATUS,pa_standardqty,pa_sccode,pa_currentstep,pa_salecode)values");
  233. sql.Append("(" + pa_id + ",'" + pa_outboxcode.Text + "','" + pd_makecode.Text + "',sysdate,'0',2,'" + pd_prodcode.Text + "',0,'','" + pa_standardqty.Text + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + pd_salecode.Text + "')");
  234. dh.ExecuteSql(sql.GetString(), "insert");
  235. }
  236. else
  237. {
  238. pa_id = dt.Rows[0]["pa_id"].ToString();
  239. }
  240. palletcode_KeyDown(sender, e);
  241. string error;
  242. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) > 0)
  243. {
  244. if (!LogicHandler.CheckPackRule(pr_packrule.Text, pa_outboxcode.Text, outboxcode.Text, pa_makecode.Text, pa_salecode.Text, pa_prodcode.Text, "大箱", out error))
  245. {
  246. OperateResult.AppendText(">>" + error + "\n", Color.Red, outboxcode);
  247. return;
  248. }
  249. }
  250. dt = (DataTable)dh.ExecuteSql("select pa_totalqty,nvl(pa_status,0) pa_status,pa_mothercode from package where pa_outboxcode='" + outboxcode.Text + "' and pa_type=1", "select");
  251. //采集的卡通箱号存在
  252. if (dt.Rows.Count > 0)
  253. {
  254. int sonboxtotalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString());
  255. if (dt.Rows[0]["pa_status"].ToString() == "1")
  256. {
  257. //判断是否已经装箱
  258. if (dt.Rows[0]["pa_mothercode"].ToString() == "")
  259. {
  260. pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  261. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) + sonboxtotalqty > int.Parse(pa_standardqty.Text == "" ? "0" : pa_standardqty.Text))
  262. {
  263. OperateResult.AppendText(">>采集箱号" + outboxcode.Text + "后超出容量\n", Color.Red, outboxcode);
  264. return;
  265. }
  266. if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) == 0)
  267. {
  268. 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");
  269. }
  270. //插入大箱明细
  271. List<string> SQLS = new List<string>();
  272. sql.Clear();
  273. sql.Append("insert into packagedetail(pd_id, pd_paid, pd_outboxcode,pd_innerboxcode, pd_innerqty,pd_makecode,pd_prodcode,pd_builddate)");
  274. sql.Append("select packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + outboxcode.Text + "'");
  275. sql.Append(",pa_packageqty,pa_makecode,'" + pd_prodcode.Text + "',sysdate from package where pa_outboxcode='" + outboxcode.Text + "'");
  276. SQLS.Add(sql.GetString());
  277. //箱内计数+1
  278. SQLS.Add("update package set PA_CURRENTQTY=PA_CURRENTQTY+1,PA_PACKAGEQTY=PA_PACKAGEQTY+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=2");
  279. //更新采集的子箱记录母箱号
  280. SQLS.Add("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + outboxcode.Text + "'");
  281. dh.ExecuteSQLTran(SQLS.ToArray());
  282. if (dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "")
  283. {
  284. string carton_macode = dh.getFieldDataByCondition("package", "pa_makecode", "pa_outboxcode='" + outboxcode.Text + "'").ToString();
  285. pa_makecode.Text = carton_macode;
  286. dh.ExecuteSql("update package set pa_makecode='" + carton_macode + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  287. }
  288. //如果是线内并且下一工序等于当前岗位资源工序
  289. if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode)
  290. {
  291. LogicHandler.OutBoxStepPass(outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集", out ErrorMessage);
  292. }
  293. //更新箱号的NextStepCode
  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. //记录卡通箱所有序列号操作日志
  300. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "大箱" + pa_outboxcode.Text + "采集卡通箱" + outboxcode.Text + "采集成功", outboxcode.Text, "");
  301. OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "采集成功!\n", Color.Green, outboxcode);
  302. LoadCollectNum();
  303. palletcode_KeyDown(sender, e);
  304. if (pa_standardqty.Text == pa_totalqty.Text)
  305. {
  306. dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  307. OperateResult.AppendText("大箱" + pa_outboxcode.Text + "已装满,封箱成功");
  308. if (!AutoOutBoxCode.Checked)
  309. {
  310. pa_outboxcode.Focus();
  311. pa_outboxcode.SelectAll();
  312. }
  313. else
  314. {
  315. outboxcode.Focus();
  316. outboxcode.SelectAll();
  317. }
  318. if (AutoPrint.Checked)
  319. {
  320. OperateResult.AppendText(">>箱已装满,自动打印!\n", Color.Green);
  321. Printlab.PerformClick();
  322. }
  323. }
  324. }
  325. else
  326. {
  327. if (dt.Rows[0]["pa_mothercode"].ToString() == pa_outboxcode.Text)
  328. OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已在本大箱内\n", Color.Red, outboxcode);
  329. else
  330. OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已采集至大箱" + dt.Rows[0]["pa_mothercode"].ToString() + "\n", Color.Red, outboxcode);
  331. }
  332. }
  333. else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode);
  334. }
  335. else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "不存在\n", Color.Red, outboxcode);
  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. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, outboxcode);
  365. }
  366. }
  367. private void LoadGridData()
  368. {
  369. sql.Clear();
  370. sql.Append("select pd_prodcode,nvl(pd_barcode,PD_INNERBOXCODE) code ,pd_innerqty,pa_salecode");
  371. sql.Append(",pd_makecode,pa_custcode,pa_packageqty from packagedetail left join package on pd_paid=pa_id left ");
  372. sql.Append("join product on pr_code=pa_prodcode where pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=2");
  373. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  374. if (dt.Rows.Count == 0 && dh.CheckExist("package", "pa_outboxcode ='" + pa_outboxcode.Text + "' and pa_type=2"))
  375. {
  376. 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");
  377. }
  378. BaseUtil.FillDgvWithDataTable(PackageInf, dt);
  379. }
  380. private void FillPrintLabel()
  381. {
  382. 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");
  383. if (_dt.Rows.Count == 0)
  384. {
  385. _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");
  386. }
  387. if (_dt.Rows.Count > 0)
  388. {
  389. string la_id = _dt.Rows[0]["la_id"].ToString();
  390. _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");
  391. PrintLabel.DataSource = _dt;
  392. PrintLabel.DisplayMember = "la_url";
  393. PrintLabel.ValueMember = "la_id";
  394. }
  395. }
  396. private void LoadCollectNum()
  397. {
  398. pa_totalqty.Text = dh.getFieldDataByCondition("package", "pa_totalqty", "pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type=2").ToString();
  399. }
  400. private void 栈板称重_SizeChanged(object sender, EventArgs e)
  401. {
  402. asc.controlAutoSize(this);
  403. }
  404. private void NewPallet_Click(object sender, EventArgs e)
  405. {
  406. NewBigBox = new Packing_NewBigBox("BIGBOX", pa_makecode.Text);
  407. NewBigBox.Controls["Confirm"].Click += Make_BigBoxCollection_Click;
  408. BaseUtil.SetFormCenter(NewBigBox);
  409. NewBigBox.ShowDialog();
  410. }
  411. private void Make_BigBoxCollection_Click(object sender, EventArgs e)
  412. {
  413. pa_outboxcode.Text = NewBigBox.OutBoxCode;
  414. palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  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 (Print.BarTenderS(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))
  423. {
  424. OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
  425. }
  426. else
  427. {
  428. OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
  429. }
  430. if (!AutoOutBoxCode.Checked)
  431. {
  432. pa_outboxcode.Focus();
  433. pa_outboxcode.SelectAll();
  434. }
  435. else
  436. {
  437. outboxcode.Focus();
  438. outboxcode.SelectAll();
  439. }
  440. }
  441. else OperateResult.AppendText(">>必须封箱才能进行打印\n", Color.Red);
  442. }
  443. else OperateResult.AppendText(">>产品" + pa_prodcode.Text + "未维护打印标签或者标签未审核\n", Color.Red);
  444. }
  445. private void ReleasePallet_Click(object sender, EventArgs e)
  446. {
  447. if (dh.getRowCount("packagedetail", "pd_outboxcode='" + pa_outboxcode.Text + "'") > 0)
  448. {
  449. string pa_mothercode = dh.getFieldDataByCondition("package", "pa_mothercode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  450. if (pa_mothercode == "")
  451. {
  452. string Delete = MessageBox.Show(this.ParentForm, "是否确认拆箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  453. if (Delete == "Yes")
  454. {
  455. sql.Clear();
  456. sql.Append("select nvl(pa_iostatus,0) pa_iostatus,pa_outno from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
  457. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  458. if (dt.Rows.Count > 0)
  459. {
  460. if (dt.Rows[0]["pa_outno"].ToString() != "")
  461. {
  462. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  463. return;
  464. }
  465. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  466. {
  467. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "处于入库状态,不允许操作\n", Color.Red);
  468. return;
  469. }
  470. }
  471. if (dh.getFieldDataByCondition("package", "pa_nextstep", "pa_mothercode='" + pa_outboxcode.Text + "'").ToString() != "")
  472. LogicHandler.OutBoxDrawStepPass(pa_outboxcode.Text, pa_makecode.Text, User.UserSourceCode);
  473. else
  474. {
  475. List<string> SQLS = new List<string>();
  476. SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'");
  477. SQLS.Add("update package set pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'");
  478. SQLS.Add("update package set pa_mothercode='' where pa_mothercode='" + pa_outboxcode.Text + "'");
  479. dh.ExecuteSQLTran(SQLS.ToArray());
  480. }
  481. //将子箱的母箱编号置成空
  482. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "解除成功\n", Color.Green);
  483. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "解除大箱" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, "");
  484. palletcode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  485. }
  486. }
  487. else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已装箱" + pa_mothercode + ",不能取消解除装箱\n", Color.Red);
  488. }
  489. else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "未采集箱\n", Color.Red);
  490. }
  491. private void Make_BigBoxCollection_FormClosed(object sender, FormClosedEventArgs e)
  492. {
  493. BaseUtil.ClosePrint(lbl);
  494. }
  495. private void Packing_Click(object sender, EventArgs e)
  496. {
  497. if (pa_outboxcode.Text != "")
  498. {
  499. sql.Clear();
  500. sql.Append("select nvl(pa_status,0) pa_status from packagedetail left join package ");
  501. sql.Append("on pa_id=pd_paid where pd_outboxcode='" + pa_outboxcode.Text + "'");
  502. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  503. if (dt.Rows.Count > 0)
  504. {
  505. if (dt.Rows[0]["pa_status"].ToString() == "0")
  506. {
  507. string Seal = MessageBox.Show(this.ParentForm, "是否确认封箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  508. if (Seal == "Yes")
  509. {
  510. OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "封大箱成功\n", Color.Green);
  511. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "大箱采集", "大箱封箱" + pa_outboxcode.Text + "成功", pa_outboxcode.Text, "");
  512. dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  513. pa_status.Text = "1";
  514. if (!AutoOutBoxCode.Checked)
  515. {
  516. pa_outboxcode.Focus();
  517. pa_outboxcode.SelectAll();
  518. }
  519. else
  520. {
  521. outboxcode.Focus();
  522. outboxcode.SelectAll();
  523. }
  524. }
  525. }
  526. else OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "已封大箱\n", Color.Red);
  527. }
  528. else OperateResult.AppendText(">>大箱号" + pa_outboxcode.Text + "未采集内容\n", Color.Red);
  529. }
  530. else OperateResult.AppendText(">>大箱号不能为空\n", Color.Red);
  531. }
  532. private void PrintLabel_SelectedValueChanged(object sender, EventArgs e)
  533. {
  534. if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView")
  535. {
  536. string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString();
  537. PrintNum.Text = (PrintNums == "" ? "1" : PrintNums);
  538. }
  539. }
  540. private void pa_prodcode_TextChanged(object sender, EventArgs e)
  541. {
  542. FillPrintLabel();
  543. }
  544. private void ResetPackageQTY()
  545. {
  546. if (pa_outboxcode.Text != "")
  547. {
  548. DataTable dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_status from package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  549. if (dt.Rows.Count > 0)
  550. {
  551. string total = dt.Rows[0]["pa_totalqty"].ToString();
  552. if (int.Parse(pa_standardqty.Text) >= int.Parse(total))
  553. {
  554. dh.UpdateByCondition("package", "pa_standardqty='" + pa_standardqty.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  555. OperateResult.AppendText(">>大箱" + pa_outboxcode.Text + "修改容量成功,已修改为" + pa_standardqty.Text + "\n", Color.Green);
  556. outboxcode.Focus();
  557. return;
  558. }
  559. else OperateResult.AppendText(">>容量不能小于已装数量\n", Color.Red);
  560. }
  561. else OperateResult.AppendText(">>大箱板号不存在\n", Color.Red);
  562. pa_standardqty.Text = "";
  563. }
  564. }
  565. private void pa_standardqty_KeyDown(object sender, KeyEventArgs e)
  566. {
  567. if (e.KeyCode == Keys.Enter)
  568. {
  569. ResetPackageQTY();
  570. }
  571. }
  572. private bool CheckOutBoxLength()
  573. {
  574. //勾选了检验长度进行校验
  575. if (OutBoxLength.Text != "")
  576. {
  577. try
  578. {
  579. int.Parse(OutBoxLength.Text);
  580. }
  581. catch (Exception)
  582. {
  583. MessageBox.Show("请填写正确的箱号长度");
  584. return false;
  585. }
  586. if (pa_outboxcode.Text.Length != int.Parse(OutBoxLength.Text))
  587. {
  588. OperateResult.AppendText(">>箱号长度错误,请重新输入箱号\n", Color.Red);
  589. return false;
  590. }
  591. else return true;
  592. }
  593. if (PalletPreFix.Text != "")
  594. {
  595. try
  596. {
  597. if (pa_outboxcode.Text.Substring(0, PalletPreFix.Text.Length) != PalletPreFix.Text)
  598. {
  599. OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
  600. return false;
  601. }
  602. }
  603. catch (Exception)
  604. {
  605. OperateResult.AppendText(">>箱号前缀不匹配,请重新输入箱号\n", Color.Red);
  606. return false;
  607. }
  608. }
  609. return true;
  610. }
  611. private void AutoOutBoxCode_CheckedChanged(object sender, EventArgs e)
  612. {
  613. if (AutoOutBoxCode.Checked)
  614. {
  615. OutBoxLength.Enabled = false;
  616. OutBoxLength.Enabled = false;
  617. pa_outboxcode.Enabled = false;
  618. }
  619. else
  620. {
  621. OutBoxLength.Enabled = true;
  622. OutBoxLength.Enabled = true;
  623. pa_outboxcode.Enabled = true;
  624. }
  625. }
  626. private void AutoOutBoxCode_CheckStateChanged(object sender, EventArgs e)
  627. {
  628. }
  629. }
  630. }