Packing_BigBoxCollection.cs 36 KB

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