FrmALARAMRECORD.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Utility;
  12. namespace WCS_Client.From
  13. {
  14. public partial class FrmALARAMRECORD : CCSkinMain
  15. {
  16. DataTable _dt;
  17. public FrmALARAMRECORD()
  18. {
  19. InitializeComponent();
  20. Bind();
  21. }
  22. private static FrmALARAMRECORD childFromInstanc;
  23. public static FrmALARAMRECORD ChildFromInstanc
  24. {
  25. get
  26. {
  27. if (childFromInstanc == null || childFromInstanc.IsDisposed)
  28. {
  29. childFromInstanc = new FrmALARAMRECORD();
  30. }
  31. return childFromInstanc;
  32. }
  33. }
  34. //绑定数据
  35. private void Bind()
  36. {
  37. PageData pd = QueryPageDataMethods(pagerControl1.CurrentPage, pagerControl1.PageSize);
  38. if (pd == null)
  39. {
  40. if (_dt != null)
  41. _dt.Clear();
  42. }
  43. else
  44. {
  45. pagerControl1.Record = pd.RowsCount;
  46. dgvTask.DataSource = pd.Dt;
  47. _dt = pd.Dt;
  48. }
  49. }
  50. //获取数据集
  51. private PageData QueryPageDataMethods(int PageIndex, int PageSize)
  52. {
  53. string _SQLText = @"select ALARAMR_EQUNO,ALARAMR_EQUTYPE,ALARAMR_ALARAMNO,ALARAMR_ALARAMMSG,
  54. to_char(ALARAMR_ALARAMSTARTTIME,'yyyy-mm-dd hh24:mi:ss') ALARAMR_ALARAMSTARTTIME,to_char(ALARAMR_ALARAMENDTIME,'yyyy-mm-dd hh24:mi:ss') ALARAMR_ALARAMENDTIME,ALARAMR_WCSTASKID
  55. from WCS_ALARAMRECORD where 1=1 ";
  56. List<string> wherelist = new List<string>();
  57. if (string.IsNullOrWhiteSpace(txtEquNo.Text) == false)
  58. wherelist.Add(string.Format("ALARAMR_EQUNO like '%{0}%'", txtEquNo.Text));
  59. if (string.IsNullOrWhiteSpace(txtEquType.Text.Trim()) == false)
  60. wherelist.Add(string.Format("ALARAMR_EQUTYPE like '%{0}%'", txtEquType.Text.Trim()));
  61. if (string.IsNullOrWhiteSpace(txtALARAMRMsg.Text.Trim()) == false)
  62. wherelist.Add(string.Format("ALARAMR_ALARAMMSG like '%{0}%'", txtALARAMRMsg.Text.Trim()));
  63. if (string.IsNullOrWhiteSpace(sknStartDate.text) == false)
  64. {
  65. DateTime startdate = Convert.ToDateTime(sknStartDate.text);
  66. string starttime = startdate.ToString("yyyy-MM-dd");
  67. wherelist.Add(string.Format("to_char(ALARAMR_ALARAMSTARTTIME,'yyyy-mm-dd')>='{0}'", starttime));
  68. }
  69. if (string.IsNullOrWhiteSpace(sknEndDate.text) == false)
  70. {
  71. DateTime enddate = Convert.ToDateTime(sknEndDate.text);
  72. string endtime = enddate.ToString("yyyy-MM-dd");
  73. wherelist.Add(string.Format("to_char(ALARAMR_ALARAMSTARTTIME,'yyyy-mm-dd')<='{0}'", endtime));
  74. }
  75. string _Orderby = " ALARAMR_ALARAMSTARTTIME desc";
  76. PageData pd = BaseWorkflow.QueryPageData(_SQLText, _Orderby, wherelist, PageIndex, PageSize);
  77. return pd;
  78. }
  79. private void pagerControl1_BindSource(object sender, EventArgs e)
  80. {
  81. Bind();
  82. }
  83. private void btnResert_Click(object sender, EventArgs e)
  84. {
  85. txtEquNo.Text = string.Empty;
  86. txtEquType.Text = string.Empty;
  87. txtALARAMRMsg.Text = string.Empty;
  88. sknStartDate.text = string.Empty;
  89. sknEndDate.text = string.Empty;
  90. Bind();
  91. }
  92. private void btn_QueryTask_Click(object sender, EventArgs e)
  93. {
  94. pagerControl1.CurrentPage = 1;
  95. Bind();
  96. }
  97. }
  98. }