Packing_BigBoxCollection.cs 35 KB

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