Special_FreezeKey.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 = null;
  43. switch (cu_code.Text)
  44. {
  45. case "华硕":
  46. dt = (DataTable)dh.ExecuteSql("select 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");
  47. break;
  48. case "机械革命":
  49. dt = (DataTable)dh.ExecuteSql("select mk_id mil_id,nvl(ms_ifqccheck,0)ms_ifqccheck,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode,MK_DPK mil_netcode from makeserial left join MECHREVO_KEY on mk_sncode=ms_sncode where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  50. break;
  51. case "MEDION":
  52. dt = (DataTable)dh.ExecuteSql("select mk_id mil_id,nvl(ms_ifqccheck,0)ms_ifqccheck,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode,MK_DPK mil_netcode from makeserial left join medion_key on mk_sncode=ms_sncode where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  53. break;
  54. case "ACER":
  55. dt = (DataTable)dh.ExecuteSql("select mk_id mil_id,nvl(ms_ifqccheck,0)ms_ifqccheck,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode,MK_DPK mil_netcode from makeserial left join acer_key on mk_sncode=ms_sncode where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  56. break;
  57. default:
  58. break;
  59. }
  60. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  61. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在或未执行过" + cd_stepcode.Text + "工序\n"); return; }
  62. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  63. string ms_ifqccheck = dt.Rows[0]["ms_ifqccheck"].ToString();
  64. string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  65. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  66. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  67. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  68. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  69. if (ms_outboxcode != "")
  70. {
  71. OperateResult.AppendText(">>序列号已经装箱" + ms_outboxcode + "\n"); return;
  72. }
  73. if (ms_ifqccheck == "0")
  74. {
  75. OperateResult.AppendText(">>序列号不处于抽检状态\n"); return;
  76. }
  77. string mil_id = dt.Rows[0]["mil_id"].ToString();
  78. string mil_netcode = dt.Rows[0]["mil_netcode"].ToString();
  79. if (mil_netcode == "")
  80. {
  81. OperateResult.AppendText(">>序列号" + SN.Text + "不存在Key\n", Color.Red, SN);
  82. return;
  83. }
  84. switch (cu_code.Text)
  85. {
  86. case "华硕":
  87. dh.ExecuteSql("update makeimeilist set mil_sncode='',mil_status=-2,MIL_REMARK='主动冻结' where mil_id='" + mil_id + "'", "update");
  88. break;
  89. case "机械革命":
  90. dh.ExecuteSql("update mechrevo_key set mk_sncode='',MK_STATUS=-2,mk_remark='主动冻结' where mk_id='" + mil_id + "'", "update");
  91. break;
  92. case "MEDION":
  93. dh.ExecuteSql("update medion_key set mk_sncode='',MK_STATUS=-2,mk_remark='主动冻结' where mk_id='" + mil_id + "'", "update");
  94. break;
  95. case "ACER":
  96. dh.ExecuteSql("update acer_key set mk_sncode='',MK_STATUS=-2,mk_remark='主动冻结' where mk_id='" + mil_id + "'", "update");
  97. break;
  98. default:
  99. break;
  100. }
  101. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "Key冻结成功", "Key冻结成功", SN.Text, "");
  102. OperateResult.AppendText(">>序列号" + SN.Text + "Key[" + mil_netcode + "]冻结成功\n", Color.Green, SN);
  103. if (cr_code.Text != "" && cr_code.Text != ms_craftcode) { OperateResult.AppendText(">>序列号途程和所选途程不一致\n"); return; }
  104. 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");
  105. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>工序不在所选途程中\n"); return; }
  106. 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();
  107. StringBuilder sql = new StringBuilder();
  108. sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where cm_stepcode in (select cd_stepcode from craft left join ");
  109. sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ") ");
  110. sql.Append("and cm_firstsn='" + ms_firstsn + "' and cm_makecode='" + ms_makecode + "'");
  111. dh.ExecuteSql(sql.ToString(), "update");
  112. 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" +
  113. " on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ")", "delete");
  114. dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + ms_sncode + "'", "update");
  115. dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=(select count(1) from oqcbatchdetail where obd_checkno='" + ms_checkno + "') where ob_checkno='" + ms_checkno + "'", "update");
  116. 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");
  117. dh.ExecuteSql("update sninfo set si_keyid='' where si_sn='" + ms_sncode + "'", "update");
  118. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "OQC回流", "回流成功" + cd_stepcode.Text + "产品:" + ms_prodcode + "序号:" + stepno, ms_sncode, ms_checkno);
  119. OperateResult.AppendText(">>" + SN.Text + "回流成功\n");
  120. //cr_code.Text = "";
  121. //cd_stepcode.Text = "";
  122. SN.Text = "";
  123. ms_id = "";
  124. }
  125. private void SN_KeyDown(object sender, KeyEventArgs e)
  126. {
  127. if (e.KeyCode == Keys.Enter)
  128. {
  129. 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");
  130. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; }
  131. ms_id = dt.Rows[0]["ms_id"].ToString();
  132. string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  133. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  134. //if (ms_checkno == "") { OperateResult.AppendText(">>" + SN.Text + "不存在抽检批次中\n", System.Drawing.Color.Red, SN); return; }
  135. cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString();
  136. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  137. 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";
  138. SaveRepairInf_Click(sender, e);
  139. }
  140. }
  141. }
  142. }