Make_PalletCollection.cs 31 KB

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