?? findmessagedlg.cpp
字號:
// FindMessageDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GpsSC.h"
#include "FindMessageDlg.h"
#include "ClientinfoSet.h"
#include "VehicleMessageSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFindMessageDlg dialog
CFindMessageDlg::CFindMessageDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindMessageDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFindMessageDlg)
m_findHour = _T("");
m_findDay = _T("");
m_findMonth = _T("");
m_findYear = _T("");
m_findCarPhone = _T("");
//}}AFX_DATA_INIT
m_strTime="";
}
void CFindMessageDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindMessageDlg)
DDX_Control(pDX, IDC_FIND_MONTH, m_ControlMonth);
DDX_Control(pDX, IDC_MESSAGELIST, m_listctrl);
DDX_CBString(pDX, IDC_FIND_HOUR, m_findHour);
DDX_CBString(pDX, IDC_FIND_DAY, m_findDay);
DDX_CBString(pDX, IDC_FIND_MONTH, m_findMonth);
DDX_CBString(pDX, IDC_FIND_YEAR, m_findYear);
DDX_Text(pDX, IDC_FIND_CARPHONE, m_findCarPhone);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFindMessageDlg, CDialog)
//{{AFX_MSG_MAP(CFindMessageDlg)
ON_BN_CLICKED(IDC_FINDMESSAGE, OnFindmessage)
ON_WM_LBUTTONDOWN()
ON_WM_CLOSE()
ON_CBN_EDITCHANGE(IDC_FIND_YEAR, OnEditchangeFindYear)
ON_BN_CLICKED(IDC_DELETEMESSAGE, OnDeletemessage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFindMessageDlg message handlers
BOOL CFindMessageDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_listctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_OWNERDATA);
m_listctrl.InsertColumn(0,"司機", LVCFMT_CENTER,50);
m_listctrl.InsertColumn(1,"車牌號碼", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(2,"車載電話", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(3,"收到消息時間", LVCFMT_CENTER,100);
m_listctrl.InsertColumn(4,"汽車狀態", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(5,"汽車位置", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(6,"速度", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(7,"緯度", LVCFMT_CENTER,80);
m_listctrl.InsertColumn(8,"經度", LVCFMT_CENTER,80);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFindMessageDlg::OnFindmessage()
{
// TODO: Add your control notification handler code here
CVehicleMessageSet messageSet;
CClientinfoSet clientinfoSet;
CString str_ClientName,str_CarNumber;
BOOL opinion1,opinion2;
UpdateData(TRUE);
m_strFindYear = m_findYear;
m_strFindMonth = m_findMonth;
m_strFindDay = m_findDay;
m_strFindHour = m_findHour;
m_strFindCarPhone = m_findCarPhone;
if(m_findYear!="")
m_strTime=m_findYear.Right(2)+'/';
if(m_findMonth!="")
m_strTime+=m_findMonth+'/';
if(m_findDay!="")
m_strTime+=m_findDay+',';
if(m_findHour!="")
m_strTime+=m_findHour;
//判斷條件
opinion1=opinion2=FALSE;
m_listctrl.DeleteAllItems();
int length=m_strTime.GetLength();
try
{
if(!messageSet.IsOpen())
messageSet.Open();
if(!messageSet.IsEOF())
messageSet.MoveFirst();
while(!messageSet.IsEOF())
{
int m_nItemCount = m_listctrl.GetItemCount();
//判斷條件,編輯框為空默認為符合條件
//車載電話
if((m_findCarPhone=="")||(m_findCarPhone.Right(11)==messageSet.m_CarPhone.Right(11)))
opinion1=TRUE;
//只判斷有選擇的日期
if((m_strTime=="")||(m_strTime==messageSet.m_Time.Left(length)))
opinion2=TRUE;
if((opinion1)&&(opinion2))
{
//客戶姓名、車牌號碼
clientinfoSet.FindClientinfo(messageSet.m_CarPhone.Right(11),str_ClientName,str_CarNumber);
m_listctrl.InsertItem(m_nItemCount, str_ClientName);
m_listctrl.SetItemText(m_nItemCount,1, str_CarNumber);
m_listctrl.SetItemText(m_nItemCount,2, messageSet.m_CarPhone);
m_listctrl.SetItemText(m_nItemCount,3, messageSet.m_Time);
m_listctrl.SetItemText(m_nItemCount,4, messageSet.m_CarEstate);
m_listctrl.SetItemText(m_nItemCount,5, messageSet.m_CarPlace);
m_listctrl.SetItemText(m_nItemCount,6, messageSet.m_Speed);
m_listctrl.SetItemText(m_nItemCount,7, messageSet.m_Longitude);
m_listctrl.SetItemText(m_nItemCount,8, messageSet.m_Latitude);
}
opinion1=opinion2=FALSE;
str_ClientName=str_CarNumber="";
messageSet.MoveNext();
}
}
catch(CDBException *Exp)
{
AfxMessageBox(Exp->m_strError);
}
}
void CFindMessageDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
}
void CFindMessageDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
}
void CFindMessageDlg::OnEditchangeFindYear()
{
// TODO: Add your control notification handler code here
}
void CFindMessageDlg::OnDeletemessage()
{
// TODO: Add your control notification handler code here
CVehicleMessageSet messageSet;
int nItemCount = m_listctrl.GetItemCount();
if(nItemCount<0)
{
AfxMessageBox("請選擇要刪除的記錄");
return;
}
BOOL opinion1,opinion2;
UpdateData(TRUE);
m_strFindYear = m_findYear;
m_strFindMonth = m_findMonth;
m_strFindDay = m_findDay;
m_strFindHour = m_findHour;
m_strFindCarPhone = m_findCarPhone;
if(m_strFindYear!="")
m_strTime=m_findYear.Right(2)+'/';
if(m_strFindMonth!="")
m_strTime+=m_findMonth+'/';
if(m_strFindDay!="")
m_strTime+=m_findDay+',';
if(m_strFindHour!="")
m_strTime+=m_findHour;
//判斷條件
opinion1=opinion2=FALSE;
int length=m_strTime.GetLength();
try
{
if(!messageSet.IsOpen())
messageSet.Open();
if(!messageSet.IsEOF())
messageSet.MoveFirst();
while(!messageSet.IsEOF())
{
//判斷條件,編輯框為空默認為符合條件
//車載電話
if((m_findCarPhone=="")||(m_findCarPhone.Right(11)==messageSet.m_CarPhone.Right(11)))
opinion1=TRUE;
//只判斷有選擇的日期
if((m_strTime=="")||(m_strTime==messageSet.m_Time.Left(length)))
opinion2=TRUE;
if((opinion1)&&(opinion2))
{
messageSet.Delete();
}
opinion1=opinion2=FALSE;
messageSet.MoveNext();
}
}
catch(CDBException *Exp)
{
AfxMessageBox(Exp->m_strError);
}
m_listctrl.DeleteAllItems();
AfxMessageBox("刪除記錄成功!");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -