Special_CancelImei.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_CancelImei : Form
  11. {
  12. DataHelper dh;
  13. LogStringBuilder sql = new LogStringBuilder();
  14. DataTable Dbfind;
  15. public Special_CancelImei()
  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_makecode,ms_firstsn,ms_sncode,ms_prodcode 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. StringBuilder sql = new StringBuilder();
  45. sql.Append("update craftmaterial set cm_status=-1 where cm_stepcode in (select cd_stepcode from craft left join ");
  46. sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + cd_stepno.Text + ") ");
  47. sql.Append("and cm_firstsn='" + ms_firstsn + "' and cm_makecode='" + ms_makecode + "'");
  48. dh.ExecuteSql(sql.ToString(), "update");
  49. dh.ExecuteSql("update makeserial set ms_nextstepcode='" + cd_stepcode.Text + "' where ms_id='" + ms_id + "'", "update");
  50. OperateResult.AppendText(">>" + SN.Text + "回流成功\n");
  51. ms_id = "";
  52. }
  53. private void SN_KeyDown(object sender, KeyEventArgs e)
  54. {
  55. if (e.KeyCode == Keys.Enter)
  56. {
  57. DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select");
  58. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n"); return; }
  59. ms_id = dt.Rows[0]["ms_id"].ToString();
  60. cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString();
  61. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  62. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode + "' order by cd_stepno";
  63. }
  64. }
  65. }
  66. }