Special_CancelOQCToLastStep.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicMethod;
  8. namespace UAS_MES_NEW.Special
  9. {
  10. public partial class Special_CancelOQCToLastStep : Form
  11. {
  12. DataHelper dh;
  13. LogStringBuilder sql = new LogStringBuilder();
  14. DataTable Dbfind;
  15. public Special_CancelOQCToLastStep()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Special_BoxSplit_Load(object sender, EventArgs e)
  20. {
  21. dh = SystemInf.dh;
  22. cd_stepcode.FormName = Name;
  23. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  24. cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" };
  25. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  26. cd_stepcode.DBTitle = "回流工序";
  27. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  28. }
  29. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  30. {
  31. Dbfind = cd_stepcode.ReturnData;
  32. BaseUtil.SetFormValue(this.Controls, Dbfind);
  33. }
  34. string ms_id = "";
  35. private void SaveRepairInf_Click(object sender, EventArgs e)
  36. {
  37. if (ms_id == "") { OperateResult.AppendText(">>请先获取SN\n"); return; }
  38. if (cd_stepcode.Text == "") { OperateResult.AppendText(">>请选择回流工序\n"); return; }
  39. DataTable dt = (DataTable)dh.ExecuteSql("select ms_nextstepcode,ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode from makeserial where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select");
  40. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在或未执行过" + cd_stepcode.Text + "工序\n"); return; }
  41. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  42. string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  43. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  44. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  45. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  46. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  47. string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  48. if (cr_code.Text != "" && cr_code.Text != ms_craftcode) { OperateResult.AppendText(">>序列号途程和所选途程不一致\n"); return; }
  49. dt = (DataTable)dh.ExecuteSql("select cd_detno-1 cd_detno from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + ms_nextstepcode + "'", "select");
  50. if (dt.Rows.Count == 0)
  51. {
  52. OperateResult.AppendText(">>工序不在所选途程中\n"); return;
  53. }
  54. else
  55. {
  56. string cd_detno = dt.Rows[0]["cd_detno"].ToString();
  57. dt = (DataTable)dh.ExecuteSql("select CD_STEPCODE from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_detno='" + cd_detno + "'", "select");
  58. if (dt.Rows.Count > 0)
  59. {
  60. cd_stepcode.Text = dt.Rows[0]["cd_stepcode"].ToString();
  61. StringBuilder sql = new StringBuilder();
  62. dh.ExecuteSql("update makeserial set ms_nextstepcode='" + cd_stepcode.Text + "',ms_checkno='' where ms_id='" + ms_id + "'", "update");
  63. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "OQC回流", "回流成功", ms_sncode, ms_checkno);
  64. OperateResult.AppendText(">>" + SN.Text + "回流成功\n");
  65. //cr_code.Text = "";
  66. //cd_stepcode.Text = "";
  67. SN.Text = "";
  68. ms_id = "";
  69. }
  70. }
  71. }
  72. private void SN_KeyDown(object sender, KeyEventArgs e)
  73. {
  74. if (e.KeyCode == Keys.Enter)
  75. {
  76. DataTable dt = (DataTable)dh.ExecuteSql("select ms_sncode,ms_firstsn,ms_makecode,ms_id,ms_craftcode,ms_prodcode,ms_nextstepcode,ms_checkno from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select");
  77. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; }
  78. ms_id = dt.Rows[0]["ms_id"].ToString();
  79. string ms_checkno = dt.Rows[0]["ms_checkno"].ToString();
  80. string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  81. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  82. string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  83. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  84. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  85. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  86. cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString();
  87. //cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode + "' order by cd_stepno";
  88. dt = (DataTable)dh.ExecuteSql("select cd_detno-1 cd_detno from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + ms_nextstepcode + "'", "select");
  89. if (dt.Rows.Count == 0)
  90. {
  91. OperateResult.AppendText(">>工序不在所选途程中\n"); return;
  92. }
  93. else
  94. {
  95. string cd_detno = dt.Rows[0]["cd_detno"].ToString();
  96. dt = (DataTable)dh.ExecuteSql("select CD_STEPCODE from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_detno='" + cd_detno + "'", "select");
  97. if (dt.Rows.Count > 0)
  98. {
  99. cd_stepcode.Text = dt.Rows[0]["cd_stepcode"].ToString();
  100. }
  101. }
  102. SaveRepairInf_Click(sender, e);
  103. }
  104. }
  105. }
  106. }