?? formdlgview.cpp
字號:
// FormDlgView.cpp : implementation file
//
#include "stdafx.h"
#include "常州旅游管理系統.h"
#include "常州旅游管理系統View.h"
#include "SYSDLG.h"
#include "PasswordDlg.h"
#include "MainFrm.h"
#include "FormDlgView.h"
#include "RESOURSEDLG.h"
#include "QUERYDLG.h"
#include "TICKETDLG.h"
#include "TRACFFICDLG.h"
#include "SYSTEMDLG.h"
#include "PasswordSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// FormDlgView
IMPLEMENT_DYNCREATE(FormDlgView, CFormView)
FormDlgView::FormDlgView()
: CFormView(FormDlgView::IDD)
{
// m_crBackground=RGB(255,255,230);
// m_wndbkBrush.CreateSolidBrush(m_crBackground);
//{{AFX_DATA_INIT(FormDlgView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
FormDlgView::~FormDlgView()
{
}
void FormDlgView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(FormDlgView)
DDX_Control(pDX, IDC_TRACFFIC, m_tracffic);
DDX_Control(pDX, IDC_TICKET, m_ticket);
DDX_Control(pDX, IDC_SHEZHI, m_shezhi);
DDX_Control(pDX, IDC_RESOURSE, m_resourse);
DDX_Control(pDX, IDC_QUERY, m_query);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(FormDlgView, CFormView)
//{{AFX_MSG_MAP(FormDlgView)
ON_BN_CLICKED(IDC_RESOURSE, OnResourse)
ON_BN_CLICKED(IDC_TICKET, OnTicket)
ON_BN_CLICKED(IDC_TRACFFIC, OnTracffic)
ON_BN_CLICKED(IDC_QUERY, OnQuery)
ON_WM_ERASEBKGND()
ON_BN_CLICKED(IDC_SHEZHI, OnShezhi)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// FormDlgView diagnostics
#ifdef _DEBUG
void FormDlgView::AssertValid() const
{
CFormView::AssertValid();
}
void FormDlgView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// FormDlgView message handlers
void FormDlgView::OnResourse()
{
RESOURSEDLG dlg;
dlg.DoModal();
}
void FormDlgView::OnTicket()
{
TICKETDLG dlg;
dlg.DoModal();
}
void FormDlgView::OnTracffic()
{
TRACFFICDLG dlg;
dlg.DoModal();
}
void FormDlgView::OnQuery()
{
QUERYDLG dlg;
dlg.DoModal();
}
void FormDlgView::OnShezhi()
{
bool passwordflag=false;
CString user,password;
SYSDLG m_dlg;
m_database=new CDatabase;
m_database->Open("景點管理",FALSE,FALSE,"ODBC;UID=sa;PWD=",TRUE);
CString strSQL="select * from 用戶密碼表";
m_pSet=new PasswordSet(m_database);
m_pSet->Open(CRecordset::snapshot,strSQL);
for(int i=0;i<3;i++)
{
m_pSet->MoveFirst();//從第一條記錄開始
if(m_dlg.DoModal()==IDOK)//IDOK
{
if(m_dlg.m_name.IsEmpty()||(m_dlg.m_password.IsEmpty()))
{
AfxMessageBox("請輸入您的用戶名與密碼!");
continue;
}
else
{
while(!m_pSet->IsEOF())
{
user=m_pSet->m_PASSWORD;//取密碼表字段的成員變量值
user.TrimRight();
user.TrimLeft();
password=m_pSet->m_NAME;//取密碼表字段的成員變量值
password.TrimRight();
password.TrimLeft();
if((m_dlg.m_name==user)&&(m_dlg.m_password==password))
{
passwordflag=true;
m_pSet->Close();//關閉數據庫
break;
}
else
{
m_pSet->MoveNext();//指向下一個記錄
}
}
if(!passwordflag)
{
AfxMessageBox("登陸出現錯誤,請檢查您的用戶名與密碼,重新登陸!");
continue;
}
else
break;
}
}
else// IDCANCEL
{
return ;
}
}
if(!passwordflag)
{
AfxMessageBox("您登陸錯誤超過3次,無權再輸入!");
return ;
}
else
{
SYSTEMDLG dlg;
dlg.DoModal();
}
}
void FormDlgView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
CDC memDC;//定義一個兼容DC
memDC.CreateCompatibleDC(&dc);//創建DC
CBitmap bmpDraw;
bmpDraw.LoadBitmap(ID_BMP);//裝入DDB
CBitmap* pbmpOld=memDC.SelectObject(&bmpDraw);//保存原有DDB,并選入新DDB入DC
dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);//將源DC中(0,0,20,20)復制到目的DC(0,0,20,20)
// pDC->BitBlt(20,20,40,40,&memDC,0,0,SRCAND);//將源DC中(0,0,20,20)和目的DC(20,20,40,40)中區域進行AND操作
memDC.SelectObject(pbmpOld);//選入原DDB
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -