EditWareHouseMsg.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Pms.UserEvent.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace PMSUI.UI.库位状态显示
  12. {
  13. public partial class EditWareHouseMsg : Form
  14. {
  15. public EditWareHouseMsg()
  16. {
  17. InitializeComponent();
  18. }
  19. private enum NullFull
  20. {
  21. 空 = 0,
  22. 满 = 1,
  23. }
  24. public string StationNum = string.Empty;
  25. private void findData()
  26. {
  27. StringBuilder sb = new StringBuilder();
  28. sb.Append($" SELECT ");
  29. sb.Append($" * ");
  30. sb.Append($" from ");
  31. sb.Append($" UpStation");
  32. sb.Append($" where ");
  33. sb.Append($" StationNum='{StationNum}' ");
  34. DataTable dt = ConDataBase.reDt(sb.ToString());
  35. if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
  36. {
  37. txt_StationNum.Text = dt.Rows[0]["StationNum"].ToString();
  38. int StationValue = int.Parse(dt.Rows[0]["StationValue"].ToString());
  39. switch (StationValue)
  40. {
  41. case 0:
  42. {
  43. cbx_StationValue.Text = NullFull.空.ToString().Trim();
  44. break;
  45. }
  46. case 1:
  47. {
  48. cbx_StationValue.Text = NullFull.满.ToString().Trim();
  49. break;
  50. }
  51. }
  52. cbx_Sel.Text = dt.Rows[0]["StationSelect"].ToString();
  53. }
  54. }
  55. private void button1_Click(object sender, EventArgs e)
  56. {
  57. int index = cbx_Sel.SelectedIndex;
  58. if (index < 0)
  59. {
  60. MessageBox.Show("库位顺序不可为空!");
  61. return;
  62. }
  63. int StationValue = 0;
  64. switch (cbx_StationValue.Text.Trim())
  65. {
  66. case "空":
  67. {
  68. StationValue = (int)NullFull.空;
  69. break;
  70. }
  71. case "满":
  72. {
  73. StationValue = (int)NullFull.满;
  74. break;
  75. }
  76. }
  77. StringBuilder sb = new StringBuilder();
  78. sb.Append($" update ");
  79. sb.Append($" UpStation");
  80. sb.Append($" set ");
  81. sb.Append($" StationNum='{txt_StationNum.Text.Trim()}', ");
  82. sb.Append($" StationValue={StationValue}, ");
  83. sb.Append($" StationSelect={cbx_Sel.Text.Trim()} ");
  84. sb.Append($" where ");
  85. sb.Append($" StationNum='{StationNum}' ");
  86. int flag = ConDataBase.sqlNonQuery(sb.ToString());
  87. if (flag > 0)
  88. {
  89. MessageBox.Show($"状态信息更新成功!");
  90. findData();
  91. }
  92. }
  93. private void EditWareHouseMsg_Load(object sender, EventArgs e)
  94. {
  95. findData();
  96. }
  97. }
  98. }