Form_EquLockQuery.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using CCWin;
  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. using WCS_Client.UC;
  12. using WCS_Client.Utility;
  13. namespace WCS_Client.From
  14. {
  15. public partial class Form_EquLockQuery : CCSkinMain
  16. {
  17. DataTable _dt;
  18. DataRow _currentDr;
  19. public Form_EquLockQuery()
  20. {
  21. InitializeComponent();
  22. Bind();
  23. }
  24. private static Form_EquLockQuery childFromInstanc;
  25. public static Form_EquLockQuery ChildFromInstanc
  26. {
  27. get
  28. {
  29. if (childFromInstanc == null || childFromInstanc.IsDisposed)
  30. {
  31. childFromInstanc = new Form_EquLockQuery();
  32. }
  33. return childFromInstanc;
  34. }
  35. }
  36. //绑定数据
  37. private void Bind()
  38. {
  39. PageData pd = QueryPageDataMethods(1, 10000);
  40. if (pd != null)
  41. {
  42. _dt = pd.Dt;
  43. dgvTask.DataSource = _dt;
  44. }
  45. else
  46. {
  47. if (_dt != null) _dt.Clear();
  48. }
  49. }
  50. //获取数据集
  51. private PageData QueryPageDataMethods(int PageIndex, int PageSize)
  52. {
  53. string _SQLText = @"SELECT equipmentno,islock,isenablei_in,isenable_out,equtype,to_char(updatetime,'yyyy-MM-dd hh24:mi:ss') updatetime FROM wcs_equipmentlock";
  54. string _Orderby = " equtype asc";
  55. PageData pd = BaseWorkflow.QueryPageData(_SQLText, _Orderby, new List<string>(), PageIndex, PageSize);
  56. return pd;
  57. }
  58. private void sknBinNuLock_Click(object sender, EventArgs e)
  59. {
  60. if (_currentDr == null)
  61. {
  62. MessageBox.Show("请选择要解锁的设备。");
  63. }
  64. else
  65. {
  66. string equipmentno = _currentDr["equipmentno"].ToString();
  67. DialogResult dr = MessageUtil.ShowYesNoAndWarning(string.Format("设备[{0}]确定要执行[解锁]吗(谨慎操作)?", equipmentno));
  68. if (dr != DialogResult.Yes) return;
  69. BaseWorkflow.Equipment_UpdateLock(equipmentno, false);
  70. MessageBox.Show(string.Format("设备[{0}]解锁成功。", equipmentno));
  71. Bind();
  72. }
  73. }
  74. private void dgvTask_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  75. {
  76. _currentDr = GetDgvRow("equipmentno");
  77. }
  78. public DataRow GetDgvRow(string cellName)
  79. {
  80. try
  81. {
  82. if (dgvTask.CurrentCell == null) return null;
  83. if (dgvTask.CurrentCell.RowIndex >= 0)
  84. {
  85. string no = Convert.ToString(dgvTask.Rows[dgvTask.CurrentCell.RowIndex].Cells[cellName].Value);
  86. return _dt.Select(cellName + "='" + no + "'")[0];
  87. }
  88. return null;
  89. }
  90. catch (Exception ex)
  91. {
  92. return null;
  93. }
  94. }
  95. private void skinButton1_Click(object sender, EventArgs e)
  96. {
  97. Bind();
  98. }
  99. }
  100. }