Packing_PalletCollection.cs 36 KB

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