SNChange.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using AGV_WPF.DLL;
  2. using AGV_WPF.Model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace AGV_WPF.ExtraUI
  13. {
  14. public partial class SNChange : Form
  15. {
  16. PLCSqlDLL PLCSql = new PLCSqlDLL();
  17. String resultRead1, resultRead2, resultRead3;
  18. public SNChange()
  19. {
  20. InitializeComponent();
  21. }
  22. private void button1_Click(object sender, EventArgs e)
  23. {
  24. if (MessageBox.Show("是否要解除" + this.textBox1.Text + "号AGV绑定?", "警告", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  25. {
  26. if (PLCSql.PLCSqlMES(this.textBox1.Text, resultRead1, resultRead2, resultRead3, "3")) //删除数据
  27. {
  28. MessageBox.Show("解除绑定成功!");
  29. textBox1.Text = "";
  30. textBox1.Enabled = true;
  31. textBox2.Text = "";
  32. textBox3.Text = "";
  33. textBox4.Text = "";
  34. textBox2.Enabled = false;
  35. textBox3.Enabled = false;
  36. textBox4.Enabled = false;
  37. button1.Enabled = false;
  38. button2.Enabled = false;
  39. }
  40. }
  41. }
  42. private void button2_Click(object sender, EventArgs e)
  43. {
  44. if (MessageBox.Show("是否要修改" + this.textBox1.Text + "号AGV绑定?", "警告", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  45. {
  46. resultRead1 = this.textBox2.Text;
  47. resultRead2 = this.textBox3.Text;
  48. resultRead3 = this.textBox4.Text;
  49. if (PLCSql.PLCSqlMES(this.textBox1.Text, resultRead1, resultRead2, resultRead3, "1")) //修改数据
  50. {
  51. MessageBox.Show("修改绑定成功!");
  52. textBox1.Text = ""; textBox1.Enabled = true;
  53. textBox2.Text = "";
  54. textBox3.Text = "";
  55. textBox4.Text = "";
  56. textBox2.Enabled = false;
  57. textBox3.Enabled = false;
  58. textBox4.Enabled = false;
  59. button1.Enabled = false;
  60. button2.Enabled = false;
  61. }
  62. }
  63. }
  64. private void SNChange_FormClosed(object sender, FormClosedEventArgs e)
  65. {
  66. SNShow sn = new SNShow();
  67. DataTable data = PLCSql.PLCSqlSelectAll();
  68. sn.dataInit(data);
  69. }
  70. private void textBox1_TextChanged(object sender, EventArgs e)
  71. {
  72. }
  73. private void label4_Click(object sender, EventArgs e)
  74. {
  75. }
  76. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  77. {
  78. if (e.KeyChar == 13)
  79. {
  80. if (this.textBox1.Text == "")
  81. {
  82. MessageBox.Show("请输入AGV号!");
  83. return;
  84. }
  85. else
  86. {
  87. AGVInfo Agvinfo = new AGVInfo();
  88. PLCSql.PLCMESSelect(this.textBox1.Text, "2", ref Agvinfo); //查询数据
  89. resultRead1 = Agvinfo.ProductCode;
  90. resultRead2 = Agvinfo.HolderBarCode;
  91. resultRead3 = Agvinfo.ProductType;
  92. //if (resultRead1 == null || resultRead1 == "")
  93. //{
  94. // textBox1.Text = "";
  95. // MessageBox.Show("该AGV号暂无绑定记录!");
  96. //}
  97. //else
  98. //{
  99. textBox1.Enabled = false;
  100. textBox2.Enabled = true;
  101. textBox3.Enabled = true;
  102. textBox4.Enabled = true;
  103. button1.Enabled = true;
  104. button2.Enabled = true;
  105. textBox2.Text = resultRead1;
  106. textBox3.Text = resultRead2;
  107. textBox4.Text = resultRead3;
  108. //}
  109. }
  110. }
  111. }
  112. }
  113. }