?? powerset.cpp
字號(hào):
// PowerSet.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "PowerSet.h"
#include "MainFrm.h"
#include "PowerSetDoc.h"
#include "PowerSetView.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPowerSetApp
BEGIN_MESSAGE_MAP(CPowerSetApp, CWinApp)
//{{AFX_MSG_MAP(CPowerSetApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPowerSetApp construction
CPowerSetApp::CPowerSetApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPowerSetApp object
CPowerSetApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CPowerSetApp initialization
BOOL CPowerSetApp::InitInstance()
{
AfxEnableControlContainer();
/////////////////////////////////////////////////////////
//進(jìn)行COM初始化
//作者:武
//////////////////////////////////////////////////////////
if(!AfxOleInit())
{
AfxMessageBox("OLE初始化錯(cuò)誤!");
return FALSE;
}
/////////////////////////
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
/////////////////////////////////////////////////////////
//連接access2000數(shù)據(jù)庫(kù)。
//作者:武
//////////////////////////////////////////////////////////
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");///創(chuàng)建Connection對(duì)象
if(SUCCEEDED(hr))
{
m_pConnection->ConnectionTimeout=5;///設(shè)置超時(shí)時(shí)間為3秒
// hr = m_pConnection->Open(Filepath,"","",adModeUnknown);
hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=manager.mdb;","","",adModeUnknown);
///連接數(shù)據(jù)庫(kù)
///上面一句中連接字串中的Provider是針對(duì)ACCESS2000環(huán)境的,對(duì)于ACCESS97,需要改為:Provider=Microsoft.Jet.OLEDB.3.51; }
}
}
catch(_com_error e)///捕捉異常
{
CString temp;
temp.Format("連接數(shù)據(jù)庫(kù)錯(cuò)誤信息:%s",e.ErrorMessage());
::MessageBox(NULL,temp,"提示信息",NULL);
return false;
}
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPowerSetDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPowerSetView));
AddDocTemplate(pDocTemplate);
/////////////////////////////////////////////////////////
//用戶登錄,進(jìn)行權(quán)限驗(yàn)證
//作者:武
//////////////////////////////////////////////////////////
CLoginDlg logdlg;
if(logdlg.DoModal()==IDOK)
{
CString sql="SELECT * FROM USERS where username='"+theApp.name+"'";
}
else
{
return FALSE;
}
//////////////////////////////////////////////
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
CString title="通用權(quán)限設(shè)置模塊演示";
m_pMainWnd->SetWindowText(title);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CPowerSetApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CPowerSetApp message handlers
int CPowerSetApp::ExitInstance()
{
///如果已經(jīng)打開(kāi)了連接則關(guān)閉它
if(m_pConnection->State)
{
m_pConnection->Close();
}
return CWinApp::ExitInstance();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -