Special_FreezeKey.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. }
  31. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  32. {
  33. Dbfind = cd_stepcode.ReturnData;
  34. BaseUtil.SetFormValue(this.Controls, Dbfind);
  35. }
  36. string ms_id = "";
  37. private void SaveRepairInf_Click(object sender, EventArgs e)
  38. {
  39. if (ms_id == "") { OperateResult.AppendText(">>请先获取SN\n"); return; }
  40. if (cd_stepcode.Text == "") { OperateResult.AppendText(">>请选择回流工序\n"); return; }
  41. DataTable dt = (DataTable)dh.ExecuteSql("select mil_sncode,mil_id,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode from makeserial left join makeimeilist on mil_sncode=ms_sncode where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  42. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  43. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在或未执行过" + cd_stepcode.Text + "工序\n"); return; }
  44. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  45. string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  46. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  47. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  48. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  49. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  50. if (ms_outboxcode != "")
  51. {
  52. OperateResult.AppendText(">>序列号已经装箱" + ms_outboxcode + "\n"); return;
  53. }
  54. string mil_id = dt.Rows[0]["mil_id"].ToString();
  55. string mil_netcode = dt.Rows[0]["mil_netcode"].ToString();
  56. if (mil_netcode == "")
  57. {
  58. OperateResult.AppendText(">>序列号" + SN.Text + "不存在Key\n", Color.Red, SN);
  59. return;
  60. }
  61. dh.ExecuteSql("update makeimeilist set mil_status=-2,MIL_REMARK='主动冻结' where mil_id='" + mil_id + "'", "update");
  62. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "Key冻结成功", "Key冻结成功", SN.Text, "");
  63. OperateResult.AppendText(">>序列号" + SN.Text + "Key[" + mil_netcode + "]冻结成功\n", Color.Green, SN);
  64. if (cr_code.Text != "" && cr_code.Text != ms_craftcode) { OperateResult.AppendText(">>序列号途程和所选途程不一致\n"); return; }
  65. 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");
  66. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>工序不在所选途程中\n"); return; }
  67. 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();
  68. StringBuilder sql = new StringBuilder();
  69. sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='" + User.UserName + "' where cm_stepcode in (select cd_stepcode from craft left join ");
  70. sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ") ");
  71. sql.Append("and cm_firstsn='" + ms_firstsn + "' and cm_makecode='" + ms_makecode + "'");
  72. dh.ExecuteSql(sql.ToString(), "update");
  73. 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" +
  74. " on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + stepno + ")", "delete");
  75. dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + ms_sncode + "'", "update");
  76. dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=(select count(1) from oqcbatchdetail where obd_checkno='" + ms_checkno + "') where ob_checkno='" + ms_checkno + "'", "update");
  77. dh.ExecuteSql("update makeserial set ms_status=1,ms_nextstepcode='" + cd_stepcode.Text + "',ms_checkno='' where ms_id='" + ms_id + "'", "update");
  78. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "OQC回流", "回流成功" + cd_stepcode.Text + "产品:" + ms_prodcode + "序号:" + stepno, ms_sncode, ms_checkno);
  79. OperateResult.AppendText(">>" + SN.Text + "回流成功\n");
  80. //cr_code.Text = "";
  81. //cd_stepcode.Text = "";
  82. SN.Text = "";
  83. ms_id = "";
  84. }
  85. private void SN_KeyDown(object sender, KeyEventArgs e)
  86. {
  87. if (e.KeyCode == Keys.Enter)
  88. {
  89. 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");
  90. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; }
  91. ms_id = dt.Rows[0]["ms_id"].ToString();
  92. string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  93. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  94. if (ms_checkno == "") { OperateResult.AppendText(">>" + SN.Text + "不存在抽检批次中\n", System.Drawing.Color.Red, SN); return; }
  95. cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString();
  96. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  97. 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";
  98. SaveRepairInf_Click(sender, e);
  99. }
  100. }
  101. }
  102. }