AddClientinfoDlg.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:4k
- // AddClientinfoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "AddClientinfoDlg.h"
- #include "ClientinfoSet.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAddClientinfoDlg dialog
- CAddClientinfoDlg::CAddClientinfoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CAddClientinfoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CAddClientinfoDlg)
- m_BatholithNo = _T("");
- m_CarColor = _T("");
- m_CarNumber = _T("");
- m_CarPhone = _T("");
- m_CarType = _T("");
- m_ClientDuty = _T("");
- m_ClientName = _T("");
- m_ClientUnits = _T("");
- m_CarEngine = _T("");
- m_ClientPassword = _T("");
- m_ClientPhone = _T("");
- m_ClientDrivelicence = _T("");
- m_ClientIDcard = _T("");
- m_ClientAge = _T("");
- //}}AFX_DATA_INIT
- }
- void CAddClientinfoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAddClientinfoDlg)
- DDX_Text(pDX, IDC_BATHOLITHNO, m_BatholithNo);
- DDX_Text(pDX, IDC_CARCOLOR, m_CarColor);
- DDX_Text(pDX, IDC_CARNUMBER, m_CarNumber);
- DDX_Text(pDX, IDC_CARPHONE, m_CarPhone);
- DDX_Text(pDX, IDC_CARTYPE, m_CarType);
- DDX_Text(pDX, IDC_CLIENTDUTY, m_ClientDuty);
- DDX_Text(pDX, IDC_CLIENTNAME, m_ClientName);
- DDX_Text(pDX, IDC_CLIENTUNITS, m_ClientUnits);
- DDX_Text(pDX, IDC_CARENGINE, m_CarEngine);
- DDX_Text(pDX, IDC_CLIENTPASSWORD, m_ClientPassword);
- DDX_Text(pDX, IDC_CLIENTPHONE, m_ClientPhone);
- DDX_Text(pDX, IDC_CLIENTDRIVELICENCE, m_ClientDrivelicence);
- DDX_Text(pDX, IDC_CLIENTIDCARD, m_ClientIDcard);
- DDX_Text(pDX, IDC_CLIENTAGE, m_ClientAge);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAddClientinfoDlg, CDialog)
- //{{AFX_MSG_MAP(CAddClientinfoDlg)
- ON_BN_CLICKED(IDC_ADDNEW, OnAddnew)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CAddClientinfoDlg message handlers
- void CAddClientinfoDlg::OnAddnew()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- //必填项
- if (m_ClientName=="")
- {
- AfxMessageBox("请输入客户姓名!");
- return;
- }
- if (m_ClientPassword=="")
- {
- AfxMessageBox("请输入客户密码!");
- return;
- }
- if (m_ClientPhone=="")
- {
- AfxMessageBox("请输入客户电话!");
- return;
- }
- if (m_CarPhone=="")
- {
- AfxMessageBox("请输入车载电话!");
- return;
- }
- if (m_CarNumber=="")
- {
- AfxMessageBox("请输入车牌!");
- return;
- }
- CClientinfoSet clientinfoSet;
- try
- {
- if(!clientinfoSet.IsOpen())
- clientinfoSet.Open();
- while(!clientinfoSet.IsEOF())
- {
- //车载电话是关键字
- if(clientinfoSet.m_CarPhone == m_CarPhone)
- {
- AfxMessageBox("已存在此车载电话号码!");
- return;
- }
- clientinfoSet.MoveNext();
- }
- clientinfoSet.AddNew();
- clientinfoSet.m_ClientName = m_ClientName;
- clientinfoSet.m_ClientAge = m_ClientAge;
- clientinfoSet.m_ClientUnits = m_ClientUnits;
- clientinfoSet.m_ClientDuty = m_ClientDuty;
- clientinfoSet.m_ClientIDcard = m_ClientIDcard;
- clientinfoSet.m_ClientDrivelicence= m_ClientDrivelicence;
- clientinfoSet.m_ClientPhone = m_ClientPhone;
- clientinfoSet.m_ClientPassword = m_ClientPassword;
- clientinfoSet.m_CarNumber = m_CarNumber;
- clientinfoSet.m_CarType = m_CarType;
- clientinfoSet.m_CarColor = m_CarColor;
- clientinfoSet.m_CarEngine = m_CarEngine;
- clientinfoSet.m_BatholithNo = m_BatholithNo;
- clientinfoSet.m_CarPhone = m_CarPhone;
- clientinfoSet.Update();
- clientinfoSet.MoveLast();
-
- AfxMessageBox("保存新记录成功!");
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- mainfrm->AddTreeItem(m_ClientName,m_CarNumber);
- }
- catch(CDBException* pEx)
- {
- AfxMessageBox(pEx->ReportError());
- }
- Empty();
- }
- void CAddClientinfoDlg::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- }
- void CAddClientinfoDlg::Empty()
- {
- m_ClientName = "";
- m_ClientAge = "";
- m_ClientUnits = "";
- m_ClientDuty = "";
- m_ClientIDcard = "";
- m_ClientDrivelicence = "";
- m_ClientPhone = "";
- m_ClientPassword = "";
- m_CarNumber = "";
- m_CarType = "";
- m_CarColor = "";
- m_CarEngine = "";
- m_BatholithNo = "";
- m_CarPhone = "";
- }