Special_FreezeKey.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using HslCommunication.Profinet.Knx;
  2. using System;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. using UAS_MES_NEW.DataOperate;
  8. using UAS_MES_NEW.Entity;
  9. using UAS_MES_NEW.PublicMethod;
  10. namespace UAS_MES_NEW.Special
  11. {
  12. public partial class Special_FreezeKey : Form
  13. {
  14. DataHelper dh;
  15. LogStringBuilder sql = new LogStringBuilder();
  16. DataTable Dbfind;
  17. public Special_FreezeKey()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Special_BoxSplit_Load(object sender, EventArgs e)
  22. {
  23. dh = SystemInf.dh;
  24. cd_stepcode.FormName = Name;
  25. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  26. cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" };
  27. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  28. cd_stepcode.DBTitle = "回流工序";
  29. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  30. cd_stepcode.Text = "Z_OA3";
  31. }
  32. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  33. {
  34. Dbfind = cd_stepcode.ReturnData;
  35. BaseUtil.SetFormValue(this.Controls, Dbfind);
  36. }
  37. string ms_id = "";
  38. private void SaveRepairInf_Click(object sender, EventArgs e)
  39. {
  40. if (ms_id == "") { OperateResult.AppendText(">>请先获取SN\n"); return; }
  41. if (cd_stepcode.Text == "") { OperateResult.AppendText(">>请选择回流工序\n"); return; }
  42. DataTable dt = (DataTable)dh.ExecuteSql("select mil_sncode,mil_id,nvl(ms_ifqccheck,0)ms_ifqccheck,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode,mil_netcode from makeserial left join makeimeilist on mil_sncode=ms_sncode where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  43. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  44. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在或未执行过" + cd_stepcode.Text + "工序\n"); return; }
  45. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  46. string ms_ifqccheck = dt.Rows[0]["ms_ifqccheck"].ToString();
  47. string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  48. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  49. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  50. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  51. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  52. if (ms_outboxcode != "")
  53. {
  54. OperateResult.AppendText(">>序列号已经装箱" + ms_outboxcode + "\n"); return;
  55. }
  56. if (ms_ifqccheck == "0")
  57. {
  58. OperateResult.AppendText(">>序列号不处于抽检状态\n"); return;
  59. }
  60. string mil_id = dt.Rows[0]["mil_id"].ToString();
  61. string mil_netcode = dt.Rows[0]["mil_netcode"].ToString();
  62. if (mil_netcode == "")
  63. {
  64. OperateResult.AppendText(">>序列号" + SN.Text + "不存在Key\n", Color.Red, SN);
  65. return;
  66. }
  67. dh.ExecuteSql("update makeimeilist set mil_sncode='',mil_status=-2,MIL_REMARK='主动冻结' where mil_id='" + mil_id + "'", "update");
  68. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "Key冻结成功", "Key冻结成功", SN.Text, "");
  69. OperateResult.AppendText(">>序列号" + SN.Text + "Key[" + mil_netcode + "]冻结成功\n", Color.Green, SN);
  70. if (cr_code.Text != "" && cr_code.Text != ms_craftcode) { OperateResult.AppendText(">>序列号途程和所选途程不一致\n"); return; }
  71. dt = (DataTable)dh.ExecuteSql("select cd_id from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + cd_stepcode.Text + "'", "select");
  72. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>工序不在所选途程中\n"); return; }
  73. string stepno = dh.getFieldDataByCondition("craft left join craftdetail on cd_crid=cr_id", "cd_stepno", "cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + cd_stepcode.Text + "'").ToString();
  74. StringBuilder sql = new StringBuilder();
  75. sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where cm_stepcode in (select cd_stepcode from craft left join ");
  76. sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ") ");
  77. sql.Append("and cm_firstsn='" + ms_firstsn + "' and cm_makecode='" + ms_makecode + "'");
  78. dh.ExecuteSql(sql.ToString(), "update");
  79. dh.ExecuteSql("delete from labelprintlog where lpl_value='" + SN.Text + "' and lpl_makecode='" + ms_makecode + "' and LPL_STEPCODE in (select cd_stepcode from craft left join craftdetail" +
  80. " on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ")", "delete");
  81. dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + ms_sncode + "'", "update");
  82. dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=(select count(1) from oqcbatchdetail where obd_checkno='" + ms_checkno + "') where ob_checkno='" + ms_checkno + "'", "update");
  83. dh.ExecuteSql("update makeserial set ms_keyid='',ms_qccheck='',ms_status=1,ms_nextstepcode='" + cd_stepcode.Text + "',ms_checkno='' where ms_id='" + ms_id + "'", "update");
  84. dh.ExecuteSql("update sninfo set si_keyid='' where si_sn='" + ms_sncode + "'", "update");
  85. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "OQC回流", "回流成功" + cd_stepcode.Text + "产品:" + ms_prodcode + "序号:" + stepno, ms_sncode, ms_checkno);
  86. OperateResult.AppendText(">>" + SN.Text + "回流成功\n");
  87. //cr_code.Text = "";
  88. //cd_stepcode.Text = "";
  89. SN.Text = "";
  90. ms_id = "";
  91. }
  92. private void SN_KeyDown(object sender, KeyEventArgs e)
  93. {
  94. if (e.KeyCode == Keys.Enter)
  95. {
  96. DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_paststep,ms_craftcode,ms_prodcode,ms_checkno from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select");
  97. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; }
  98. ms_id = dt.Rows[0]["ms_id"].ToString();
  99. string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  100. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  101. //if (ms_checkno == "") { OperateResult.AppendText(">>" + SN.Text + "不存在抽检批次中\n", System.Drawing.Color.Red, SN); return; }
  102. cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString();
  103. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  104. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode + "' and instr('" + ms_paststep + "',cd_stepcode)>0 order by cd_stepno";
  105. SaveRepairInf_Click(sender, e);
  106. }
  107. }
  108. }
  109. }