123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- #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::ShowLOg(CWnd* pParent )
- : CDialog(ShowLOg::IDD, pParent)
- , m_StartTime(0)
- , m_EndTime(0)
- {
-
-
- m_nIndex = 0;
- }
- void ShowLOg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_Control(pDX, IDC_LIST1, m_List1);
-
- DDX_DateTimeCtrl(pDX, DTP_StartTime, m_StartTime);
- DDX_DateTimeCtrl(pDX, DTP_EndTime, m_EndTime);
- }
- BEGIN_MESSAGE_MAP(ShowLOg, CDialog)
-
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
-
- ON_BN_CLICKED(Btn_TimeFilter, OnBnClickedTimefilter)
- ON_BN_CLICKED(Btn_ContentFind, OnBnClickedContentfind)
- END_MESSAGE_MAP()
- BOOL ShowLOg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- m_combo1.AddString("1个月");
- m_combo1.AddString("2个月");
- m_combo1.AddString("3个月");
- m_combo1.AddString("6个月");
- CString str = g_cominfoarray.ElementAt(0).ElementAt(112);
- if (str == "")str = "6个月";
- m_combo1.SetCurSel(m_combo1.FindString(0, str));
- #if 1
- m_EndTime = CTime::GetCurrentTime();
-
- int nCurSel = m_combo1.GetCurSel();
-
- switch (nCurSel)
- {
- case 0:
- {
- CTimeSpan ts(31, 0, 0, 0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 1:
- {
- CTimeSpan ts(62, 0, 0, 0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 2:
- {
- CTimeSpan ts(93, 0, 0, 0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 3:
- {
- CTimeSpan ts(186, 0, 0, 0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- default:
- break;
- }
- UpdateData(FALSE);
-
- #endif
- CRect rc;
- GetClientRect(rc);
- int wid = rc.Width() - 30;
- wid /= 5;
- str.Format("日期,%d;内容,%d", wid, wid * 4);
- m_List1.SetHeadings(str);
- GetData();
- CenterWindow();
- return TRUE;
-
- }
- void ShowLOg::GetData()
- {
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 185;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if (g_bSendOK == 0)return;
- DataToArray(&m_List1array);
- m_List1.DeleteAllItems2();
- int ii = 0;
- m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
- int count = 0;
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii = count;
- m_List1.m_LabelCount = ii;
- m_List1.SetItemCountEx(ii);
- }
- void ShowLOg::OnButton1()
- {
-
- int pos = m_combo1.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_combo1.GetLBText(pos, str);
- CString sql;
- sql.Format("update version set [logdays]='" + str + "'");
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- g_cominfoarray.ElementAt(0).SetAt(112, str);
- }
- void ShowLOg::OnBnClickedTimefilter()
- {
-
- UpdateData();
- CString strStartTime = m_StartTime.Format("%Y-%m-%d");
- CString strEndTime = m_EndTime.Format("%Y-%m-%d");
- CString strFilter;
-
- strFilter.Format("date between '%s' and '%s'", strStartTime, strEndTime);
-
- 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);
- SetDlgItemText(Btn_ContentFind, "查询");
- m_nIndex = 0;
- m_List1.DeleteAllItems2();
- int ii = 0;
- m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
- int count = 0;
- for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii = count;
- m_List1.m_LabelCount = ii;
- m_List1.SetItemCountEx(ii);
- }
- void ShowLOg::OnBnClickedContentfind()
- {
- UpdateData();
-
- CString strFind;
- GetDlgItemText(Edt_ContentFind, strFind);
- if (strFind == "")
- {
- AfxMessageBox("请输入查找内容");
- return;
- }
- int nCount = m_List1.GetItemCount();
- BOOL bFind = FALSE;
- for (int i = m_nIndex; i < nCount; i++)
- {
- CString strContent = m_List1.m_arLabels.ElementAt(i).ElementAt(1);
-
- if (strContent.Find(strFind) != -1)
- {
- int nItem = m_List1.GetTopIndex();
- CRect rc;
- m_List1.GetItemRect(nItem, rc, LVIR_BOUNDS);
- CSize sz(0, (i - nItem)*rc.Height());
- m_List1.Scroll(sz);
- m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
-
- m_List1.SetFocus();
- m_nIndex = i + 1;
- bFind = TRUE;
- SetDlgItemText(Btn_ContentFind, "下一个");
- break;
- }
- }
- if (bFind == FALSE)
- {
- m_nIndex = 0;
- SetDlgItemText(Btn_ContentFind, "查询");
- AfxMessageBox("未找到相关内容!");
- }
- }
|