FindMessageDlg.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:6k
- // 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("删除记录成功!");
- }