123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- // ShowLOg.cpp : implementation file
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowLOg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // ShowLOg dialog
- ShowLOg::ShowLOg(CWnd* pParent /*=NULL*/)
- : CDialog(ShowLOg::IDD, pParent)
- , m_StartTime(0)
- , m_EndTime(0)
- ,m_strLogType(_T(""))
- {
- m_nIndex = 0;
- }
- void ShowLOg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_list);
- DDX_DateTimeCtrl(pDX, DTP_StartTime, m_StartTime); // Jeff.add
- DDX_DateTimeCtrl(pDX, DTP_EndTime, m_EndTime); // Jeff.add
- }
- BEGIN_MESSAGE_MAP(ShowLOg, CDialog)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(Btn_TimeFilter, OnBnClickedTimefilter) // Jeff.add
- ON_BN_CLICKED(Btn_ContentFind, OnBnClickedContentfind) // Jeff.add
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowLOg message handlers
- BOOL ShowLOg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CTimeSpan tSpan(30, 0, 0, 0);
- m_EndTime = CTime::GetCurrentTime();
- m_StartTime = m_EndTime - tSpan;
- UpdateData(FALSE);
- CRect rc;
- GetClientRect(rc);
- int wid = rc.Width() - 30;
- wid /= 5;
- m_list.SetHeadings(
- _T("日志类型, 100"),
- _T("日志操作, 100"),
- _T("日志时间, 100"),
- _T("日志员工, 100"),
- _T("日志内容, 120"),
- NULL
- );
- GetData();
- CenterWindow();
- return TRUE;
- }
- void ShowLOg::GetData()
- {
- UpdateData();
- CString strStartTime = m_StartTime.Format("%Y-%m-%d 00:00:00");
- CString strEndTime = m_EndTime.Format("%Y-%m-%d 23:59:59");
- CString strFilter;
- strFilter.Format("log_date between '%s' and '%s'", strStartTime, strEndTime);
- if ( !m_strLogType.IsEmpty() )
- strFilter += _T(" and log_type = '") + m_strLogType + _T("'");
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 185;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strFilter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_List1array);
- m_list.m_AryList.RemoveAll();
- m_list.DeleteAllItems();
- m_list.m_AryList.SetSize(m_List1array.GetSize(), 1);
- for ( int i = 0; i < m_List1array.GetSize(); i++ ) {
- m_list.m_AryList.ElementAt(i).RemoveAll();
- m_list.m_AryList.ElementAt(i).Copy(m_List1array.ElementAt(i));
- }
- m_list.SetItemCountEx(m_List1array.GetSize());
- }
- void ShowLOg::OnButton1()
- {
- }
- void ShowLOg::OnBnClickedTimefilter()
- {
- UpdateData();
- CString strStartTime = m_StartTime.Format("%Y-%m-%d 00:00:00");
- CString strEndTime = m_EndTime.Format("%Y-%m-%d 23:59:59");
- CString strFilter;
- strFilter.Format("log_date between '%s' and '%s'", strStartTime, strEndTime);
- if ( !m_strLogType.IsEmpty() )
- strFilter += _T(" and log_type = '") + m_strLogType + _T("'");
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 185;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strFilter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_List1array);
- m_list.m_AryList.RemoveAll();
- m_list.DeleteAllItems();
- m_list.m_AryList.SetSize(m_List1array.GetSize(), 1);
- for ( int i = 0; i < m_List1array.GetSize(); i++ ) {
- m_list.m_AryList.ElementAt(i).RemoveAll();
- m_list.m_AryList.ElementAt(i).Copy(m_List1array.ElementAt(i));
- }
- m_list.SetItemCountEx(m_List1array.GetSize());
- }
- void ShowLOg::OnBnClickedContentfind()
- {
- UpdateData();
- CString strFind;
- GetDlgItemText(Edt_ContentFind, strFind);
- if (strFind == _T("")) {
- AfxMessageBox("请输入查找内容");
- return;
- }
- int nCount = m_list.GetItemCount();
- BOOL bFind = FALSE;
- for (int i = m_nIndex; i < nCount; i++) {
- CString strContent = m_list.m_AryList.ElementAt(i).ElementAt(1);
- if (
- m_list.m_AryList.ElementAt(i).ElementAt(0).Find(strFind) != -1 ||
- m_list.m_AryList.ElementAt(i).ElementAt(1).Find(strFind) != -1 ||
- m_list.m_AryList.ElementAt(i).ElementAt(3).Find(strFind) != -1 ||
- m_list.m_AryList.ElementAt(i).ElementAt(4).Find(strFind) != -1
- )
- {
- int nItem = m_list.GetTopIndex();
- CRect rc;
- m_list.GetItemRect(nItem, rc, LVIR_BOUNDS);
- CSize sz(0, (i - nItem)*rc.Height());
- m_list.Scroll(sz);//m_List1.SendMessage(WM_VSCROLL,SB_LINERIGHT,0);
- m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- //m_List1.SetItemState(i,LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- m_list.SetFocus();
- m_nIndex = i + 1;
- bFind = TRUE;
- SetDlgItemText(Btn_ContentFind, "下一个");
- break;
- }
- }
- if (bFind == FALSE) {
- m_nIndex = 0;
- SetDlgItemText(Btn_ContentFind, "查询");
- AfxMessageBox("未找到相关内容!");
- }
- }
- void ShowLOg::OnOK()
- {
- OnBnClickedContentfind();
- }
|