Special_ActiveSN.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_ActiveSN : Form
  13. {
  14. DataHelper dh;
  15. LogStringBuilder sql = new LogStringBuilder();
  16. DataTable Dbfind;
  17. public Special_ActiveSN()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Special_BoxSplit_Load(object sender, EventArgs e)
  22. {
  23. dh = SystemInf.dh;
  24. }
  25. string ms_id = "";
  26. private void SaveRepairInf_Click(object sender, EventArgs e)
  27. {
  28. if (ms_id == "") { OperateResult.AppendText(">>请先获取SN\n"); return; }
  29. DataTable dt = (DataTable)dh.ExecuteSql("select ms_sncode,ms_makecode,ms_outboxcode,nvl(ms_isactive,0)ms_isactive,ms_status,ms_id,ms_paststep,ms_craftcode,ms_prodcode,ms_checkno from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select");
  30. string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
  31. string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
  32. string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  33. if (ms_outboxcode != "")
  34. {
  35. OperateResult.AppendText(">>序列号已经装箱" + ms_outboxcode + "\n"); return;
  36. }
  37. dh.ExecuteSql("update makeserial set MS_ISACTIVE=-1 where ms_id='" + ms_id + "'", "update");
  38. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "SN激活", "SN激活成功", ms_sncode, "");
  39. OperateResult.AppendText(">>" + SN.Text + "激活成功\n");
  40. //cr_code.Text = "";
  41. //cd_stepcode.Text = "";
  42. SN.Text = "";
  43. ms_id = "";
  44. }
  45. private void SN_KeyDown(object sender, KeyEventArgs e)
  46. {
  47. if (e.KeyCode == Keys.Enter)
  48. {
  49. DataTable dt = (DataTable)dh.ExecuteSql("select nvl(ms_isactive,0)ms_isactive,ms_status,ms_id,ms_paststep,ms_craftcode,ms_prodcode,ms_checkno from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select");
  50. ms_id = "";
  51. if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; }
  52. ms_id = dt.Rows[0]["ms_id"].ToString();
  53. string ms_isactive = dt.Rows[0]["ms_isactive"].ToString();
  54. string ms_status = dt.Rows[0]["ms_status"].ToString();
  55. if (ms_isactive == "-1") { OperateResult.AppendText(">>" + SN.Text + "已激活\n", System.Drawing.Color.Red, SN); return; }
  56. if (ms_status == "3") { OperateResult.AppendText(">>" + SN.Text + "处于待维修状态,不允许激活\n", System.Drawing.Color.Red, SN); return; }
  57. }
  58. }
  59. }
  60. }