Special_ChecknoSpitBox.cs 9.6 KB

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