Special_UpdateSn.cs 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Special
  10. {
  11. public partial class Special_UpdateSn : Form
  12. {
  13. DataHelper dh = SystemInf.dh;
  14. LogStringBuilder sql = new LogStringBuilder();
  15. public Special_UpdateSn()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Confirm_Click(object sender, EventArgs e)
  20. {
  21. if (!dh.CheckExist("smtbind", "sb_barcode = '" + sncode.Text + "'"))
  22. {
  23. OperateResult.AppendText(">>序列号" + sncode.Text + "不存在绑定记录,无法操作\n", Color.Red, sncode);
  24. sncode.Focus();
  25. return;
  26. }
  27. if (dh.CheckExist("smtbind", "sb_barcode = '" + newsncode.Text + "'") || dh.CheckExist("makeserial", "ms_sncode = '" + newsncode.Text + "'"))
  28. {
  29. OperateResult.AppendText(">>序列号" + newsncode.Text + "存在绑定以及采集记录,无法操作\n", Color.Red, newsncode);
  30. newsncode.Focus();
  31. return;
  32. }
  33. //更新记录
  34. dh.ExecuteSql("update MES_SMTLOCATION_TABLE set smt_ms_sncode = '"+ newsncode.Text + "' where smt_ms_sncode = '"+ sncode.Text + "'", "update");
  35. dh.ExecuteSql("update smtbind set sb_barcode = '" + newsncode.Text + "' where sb_barcode = '" + sncode.Text + "'", "update");
  36. dh.ExecuteSql("update steppassed set sp_sncode = '" + newsncode.Text + "' where sp_sncode = '" + sncode.Text + "'", "update");
  37. dh.ExecuteSql("update makeserial set ms_code = '" + newsncode.Text + "',ms_sncode = '" + newsncode.Text + "',ms_firstsn = '" + newsncode.Text + "' where ms_sncode = '" + sncode.Text + "'", "update");
  38. dh.ExecuteSql("update CRAFTMATERIAL set cm_mscode = '" + newsncode.Text + "',cm_sncode = '" + newsncode.Text + "' where cm_sncode = '" + sncode.Text + "'", "update");
  39. dh.ExecuteSql("update REDUCESTEPRECORD set rsd_sncode = '" + newsncode.Text + "' where rsd_sncode = '" + sncode.Text + "'", "update");
  40. dh.ExecuteSql("update makeprocess set mp_sncode = '" + newsncode.Text + "',mp_mscode = '" + newsncode.Text + "' where mp_sncode = '" + sncode.Text + "'", "update");
  41. dh.ExecuteSql("update commandlog set cl_sncode = '" + newsncode.Text + "' where cl_sncode = '" + sncode.Text + "'", "update");
  42. dh.ExecuteSql("update makebad set mb_mscode = '" + newsncode.Text + "',mb_sncode = '" + newsncode.Text + "' where mb_sncode = '" + sncode.Text + "'", "update");
  43. dh.ExecuteSql("update MAKEBADREASON set mbr_sncode = '" + newsncode.Text + "' where mbr_sncode = '" + sncode.Text + "'", "update");
  44. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode,"", User.UserLineCode, User.UserSourceCode, "SN更新", "旧SN:"+ sncode.Text + "更新为:"+ newsncode.Text + "", newsncode.Text, "");
  45. OperateResult.AppendText(">>旧SN:" + sncode.Text + "更新为:" + newsncode.Text + "\n", Color.Green);
  46. newsncode.Text = "";
  47. sncode.Text = "";
  48. sncode.Focus();
  49. // OperateResult.AppendText(">>序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
  50. }
  51. private void Clean_Click(object sender, EventArgs e)
  52. {
  53. OperateResult.Clear();
  54. }
  55. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  56. {
  57. if (e.KeyCode == Keys.Enter)
  58. {
  59. if (!dh.CheckExist("smtbind", "sb_barcode = '" + sncode.Text + "'"))
  60. {
  61. OperateResult.AppendText(">>序列号" + sncode.Text + "不存在绑定记录,无法操作\n", Color.Red, sncode);
  62. return;
  63. }
  64. else
  65. {
  66. newsncode.Focus();
  67. newsncode.SelectAll();
  68. }
  69. }
  70. }
  71. private void enterTextBox1_KeyDown(object sender, KeyEventArgs e)
  72. {
  73. if (e.KeyCode == Keys.Enter)
  74. {
  75. if (dh.CheckExist("smtbind", "sb_barcode = '" + newsncode.Text + "'") || dh.CheckExist("makeserial", "ms_sncode = '" + newsncode.Text + "'"))
  76. {
  77. OperateResult.AppendText(">>序列号" + newsncode.Text + "存在绑定以及采集记录,无法操作\n", Color.Red, newsncode);
  78. return;
  79. }
  80. else
  81. {
  82. Confirm_Click(sender, e);
  83. }
  84. }
  85. }
  86. }
  87. }