Special_ChecknoSpitBox.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Special
  10. {
  11. public partial class Special_ChecknoSpitBox : Form
  12. {
  13. DataHelper dh;
  14. LogStringBuilder sql = new LogStringBuilder();
  15. public Special_ChecknoSpitBox()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Special_BoxSplit_Load(object sender, EventArgs e)
  20. {
  21. dh = SystemInf.dh;
  22. }
  23. private void Split_Click(object sender, EventArgs e)
  24. {
  25. if (dh.getFieldDataByCondition("step", "st_ifpack", "st_code = '" + User.CurrentStepCode + "'").ToString() != "-1")
  26. {
  27. OperatResult.AppendText(">>当前登陆资源非包装资源,不允许采集\n", Color.Red);
  28. return;
  29. }
  30. if (checkno.Text == "")
  31. {
  32. OperatResult.AppendText(">>抽检批不能为空\n", Color.Red);
  33. return;
  34. }
  35. string Delete = MessageBox.Show(this.ParentForm, "是否确认批量拆箱?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  36. if (Delete == "Yes")
  37. {
  38. DataTable dt = (DataTable)dh.ExecuteSql("select pa_makecode,pa_outboxcode,nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_status,pa_checkno,ob_status,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus from package join oqcbatch on pa_checkno=ob_checkno where ob_checkno='" + checkno.Text + "'", "select");
  39. if (dt.Rows.Count > 0)
  40. {
  41. for (int jk = 0; jk < dt.Rows.Count; jk++)
  42. {
  43. if (dt.Rows[jk]["pa_outno"].ToString() != "")
  44. {
  45. OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已被出货单" + dt.Rows[jk]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
  46. return;
  47. }
  48. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  49. {
  50. OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "处于入库状态,不允许操作\n", Color.Red);
  51. return;
  52. }
  53. if (dt.Rows[0]["pa_status"].ToString() != "1")
  54. {
  55. OperatResult.AppendText(">>卡通箱" + dt.Rows[jk]["pa_outboxcode"].ToString() + "未封箱,不允许操作\n", Color.Red);
  56. return;
  57. }
  58. if (dt.Rows[0]["pa_mothercode"].ToString() == "")
  59. {
  60. if (dt.Rows[0]["pa_downstatus"].ToString() == "0")
  61. {
  62. string ob_status = dt.Rows[0]["ob_status"].ToString();
  63. string pa_checkno = dt.Rows[0]["pa_checkno"].ToString();
  64. ////不存在抽检批次或者还未检验可以拆解
  65. //if (ob_status == "" || ob_status == "ENTERING" || ob_status == "UNCHECK")
  66. //{
  67. sql.Clear();
  68. sql.Append("select pd_makecode,count(1) num from packagedetail left join makeserial ");
  69. sql.Append("on ms_sncode=pd_barcode and ms_makecode=pd_makecode where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' group by pd_makecode");
  70. DataTable dtB = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  71. List<string> SQLS1 = new List<string>();
  72. for (int i = 0; i < dtB.Rows.Count; i++)
  73. {
  74. string ma_code = dtB.Rows[i]["pd_makecode"].ToString();
  75. string num = dtB.Rows[i]["num"].ToString();
  76. // SQLS1.Add("delete from makeprocess where mp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "') and mp_makecode='" + ma_code + "' and mp_stepcode='" + User.CurrentStepCode + "'");
  77. // SQLS1.Add("delete from steppassed where sp_sncode in (select ms_sncode from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "') and sp_makecode='" + ma_code + "' and sp_stepcode='" + User.CurrentStepCode + "'");
  78. SQLS1.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + num + ",mcd_outqty=mcd_outqty-" + num + ",mcd_okqty=mcd_okqty-" + num + " where mcd_macode='" + ma_code + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  79. //扣减已完工数
  80. SQLS1.Add("update make set ma_madeqty=ma_madeqty-(select count(1) from makeserial where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "' and ms_makecode='" + ma_code + "' and ms_status=2) where ma_code='" + ma_code + "'");
  81. }
  82. if (pa_checkno != "")
  83. {
  84. SQLS1.Add("update makeserial set ms_checkno='' where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
  85. SQLS1.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-(select count(1) from oqcbatchdetail where obd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "') where ob_checkno='" + pa_checkno + "'");
  86. SQLS1.Add("delete from oqcbatchdetail where obd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
  87. }
  88. //更新序列号状态
  89. SQLS1.Add("update makeserial set ms_status=1,ms_outboxcode='',ms_nextstepcode= (case when ms_nextstepcode='" + User.CurrentStepCode + "' then ms_nextstepcode else '" + User.CurrentStepCode + "' end ),ms_paststep=replace(ms_paststep,'," + User.CurrentStepCode + "','') where ms_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'");
  90. //抽检批次不为空的时候进行移除
  91. dh.ExecuteSQLTran(SQLS1.ToArray());
  92. string prcode = dh.getFieldDataByCondition("packagedetail", "pd_prodcode", "pd_outboxcode = '" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'").ToString();
  93. string standqty = dh.getFieldDataByCondition("product", "pr_outboxinnerqty", "pr_code = '" + prcode + "'").ToString();
  94. //if (standqty != "")
  95. //{
  96. // //置空原箱
  97. // dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0,PA_STANDARDQTY = '" + standqty + "' where checkno='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "update");
  98. //}
  99. //else
  100. // //置空原箱
  101. // dh.ExecuteSql("update package set pa_checkno='',pa_prodcode='',pa_packtype='',pa_salecode='',pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where checkno='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "update");
  102. dh.ExecuteSql("insert into PACKAGEBACKUP select * from package where pa_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "insert");
  103. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "insert");
  104. dh.ExecuteSql("delete from package where pa_outboxcode = '" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "delete");
  105. //删除箱的明细
  106. dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + dt.Rows[jk]["pa_outboxcode"].ToString() + "'", "delete");
  107. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, dt.Rows[jk]["pa_makecode"].ToString(), User.UserLineCode, User.UserSourceCode, "卡通箱拆解", "成功", dt.Rows[jk]["pa_outboxcode"].ToString(), checkno.Text);
  108. OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "成功拆解!\n", Color.Green);
  109. //}
  110. //else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已送检,不允许解除\n", Color.Red);
  111. }
  112. else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已下地,不允许解除\n", Color.Red);
  113. }
  114. else OperatResult.AppendText(">>箱号" + dt.Rows[jk]["pa_outboxcode"].ToString() + "已装箱" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许解除\n", Color.Red);
  115. }
  116. }
  117. else OperatResult.AppendText(">>抽检批" + checkno.Text + "不存在\n", Color.Red);
  118. }
  119. }
  120. }
  121. }