ShowLOg.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // ShowLOg.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "ylgl.h"
  4. #include "ShowLOg.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // ShowLOg dialog
  12. ShowLOg::ShowLOg(CWnd* pParent /*=NULL*/)
  13. : CDialog(ShowLOg::IDD, pParent)
  14. , m_StartTime(0)
  15. , m_EndTime(0)
  16. ,m_strLogType(_T(""))
  17. {
  18. m_nIndex = 0;
  19. }
  20. void ShowLOg::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. DDX_Control(pDX, IDC_LIST1, m_list);
  24. DDX_DateTimeCtrl(pDX, DTP_StartTime, m_StartTime); // Jeff.add
  25. DDX_DateTimeCtrl(pDX, DTP_EndTime, m_EndTime); // Jeff.add
  26. }
  27. BEGIN_MESSAGE_MAP(ShowLOg, CDialog)
  28. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  29. ON_BN_CLICKED(Btn_TimeFilter, OnBnClickedTimefilter) // Jeff.add
  30. ON_BN_CLICKED(Btn_ContentFind, OnBnClickedContentfind) // Jeff.add
  31. END_MESSAGE_MAP()
  32. /////////////////////////////////////////////////////////////////////////////
  33. // ShowLOg message handlers
  34. BOOL ShowLOg::OnInitDialog()
  35. {
  36. CDialog::OnInitDialog();
  37. // TODO: Add extra initialization here
  38. CTimeSpan tSpan(30, 0, 0, 0);
  39. m_EndTime = CTime::GetCurrentTime();
  40. m_StartTime = m_EndTime - tSpan;
  41. UpdateData(FALSE);
  42. CRect rc;
  43. GetClientRect(rc);
  44. int wid = rc.Width() - 30;
  45. wid /= 5;
  46. m_list.SetHeadings(
  47. _T("日志类型, 100"),
  48. _T("日志操作, 100"),
  49. _T("日志时间, 100"),
  50. _T("日志员工, 100"),
  51. _T("日志内容, 120"),
  52. NULL
  53. );
  54. GetData();
  55. CenterWindow();
  56. return TRUE;
  57. }
  58. void ShowLOg::GetData()
  59. {
  60. UpdateData();
  61. CString strStartTime = m_StartTime.Format("%Y-%m-%d 00:00:00");
  62. CString strEndTime = m_EndTime.Format("%Y-%m-%d 23:59:59");
  63. CString strFilter;
  64. strFilter.Format("log_date between '%s' and '%s'", strStartTime, strEndTime);
  65. if ( !m_strLogType.IsEmpty() )
  66. strFilter += _T(" and log_type = '") + m_strLogType + _T("'");
  67. g_sendhead.bsql = 0;
  68. g_sendhead.code[0] = 185;
  69. g_sendhead.tabcount = 1;
  70. g_pMainWnd->ProcessChatMessageRequest2(strFilter);
  71. if (g_bSendOK == 0)
  72. return;
  73. DataToArray(&m_List1array);
  74. m_list.m_AryList.RemoveAll();
  75. m_list.DeleteAllItems();
  76. m_list.m_AryList.SetSize(m_List1array.GetSize(), 1);
  77. for ( int i = 0; i < m_List1array.GetSize(); i++ ) {
  78. m_list.m_AryList.ElementAt(i).RemoveAll();
  79. m_list.m_AryList.ElementAt(i).Copy(m_List1array.ElementAt(i));
  80. }
  81. m_list.SetItemCountEx(m_List1array.GetSize());
  82. }
  83. void ShowLOg::OnButton1()
  84. {
  85. }
  86. void ShowLOg::OnBnClickedTimefilter()
  87. {
  88. UpdateData();
  89. CString strStartTime = m_StartTime.Format("%Y-%m-%d 00:00:00");
  90. CString strEndTime = m_EndTime.Format("%Y-%m-%d 23:59:59");
  91. CString strFilter;
  92. strFilter.Format("log_date between '%s' and '%s'", strStartTime, strEndTime);
  93. if ( !m_strLogType.IsEmpty() )
  94. strFilter += _T(" and log_type = '") + m_strLogType + _T("'");
  95. g_sendhead.bsql = 0;
  96. g_sendhead.code[0] = 185;
  97. g_sendhead.tabcount = 1;
  98. g_pMainWnd->ProcessChatMessageRequest2(strFilter);
  99. if (g_bSendOK == 0)
  100. return;
  101. DataToArray(&m_List1array);
  102. m_list.m_AryList.RemoveAll();
  103. m_list.DeleteAllItems();
  104. m_list.m_AryList.SetSize(m_List1array.GetSize(), 1);
  105. for ( int i = 0; i < m_List1array.GetSize(); i++ ) {
  106. m_list.m_AryList.ElementAt(i).RemoveAll();
  107. m_list.m_AryList.ElementAt(i).Copy(m_List1array.ElementAt(i));
  108. }
  109. m_list.SetItemCountEx(m_List1array.GetSize());
  110. }
  111. void ShowLOg::OnBnClickedContentfind()
  112. {
  113. UpdateData();
  114. CString strFind;
  115. GetDlgItemText(Edt_ContentFind, strFind);
  116. if (strFind == _T("")) {
  117. AfxMessageBox("请输入查找内容");
  118. return;
  119. }
  120. int nCount = m_list.GetItemCount();
  121. BOOL bFind = FALSE;
  122. for (int i = m_nIndex; i < nCount; i++) {
  123. CString strContent = m_list.m_AryList.ElementAt(i).ElementAt(1);
  124. if (
  125. m_list.m_AryList.ElementAt(i).ElementAt(0).Find(strFind) != -1 ||
  126. m_list.m_AryList.ElementAt(i).ElementAt(1).Find(strFind) != -1 ||
  127. m_list.m_AryList.ElementAt(i).ElementAt(3).Find(strFind) != -1 ||
  128. m_list.m_AryList.ElementAt(i).ElementAt(4).Find(strFind) != -1
  129. )
  130. {
  131. int nItem = m_list.GetTopIndex();
  132. CRect rc;
  133. m_list.GetItemRect(nItem, rc, LVIR_BOUNDS);
  134. CSize sz(0, (i - nItem)*rc.Height());
  135. m_list.Scroll(sz);//m_List1.SendMessage(WM_VSCROLL,SB_LINERIGHT,0);
  136. m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  137. //m_List1.SetItemState(i,LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  138. m_list.SetFocus();
  139. m_nIndex = i + 1;
  140. bFind = TRUE;
  141. SetDlgItemText(Btn_ContentFind, "下一个");
  142. break;
  143. }
  144. }
  145. if (bFind == FALSE) {
  146. m_nIndex = 0;
  147. SetDlgItemText(Btn_ContentFind, "查询");
  148. AfxMessageBox("未找到相关内容!");
  149. }
  150. }
  151. void ShowLOg::OnOK()
  152. {
  153. OnBnClickedContentfind();
  154. }