Make_BigBoxCollection.cs 36 KB

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