📄 dlgconnectionconfig.cpp
字号:
// DlgConnectionConfig.cpp : implementation file
//
#include "stdafx.h"
#include "BaseFunc.h"
#include "DlgConnectionConfig.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgConnectionConfig dialog
extern CBaseFuncApp theApp;
CDlgConnectionConfig::CDlgConnectionConfig(CWnd* pParent /*=NULL*/)
: CDialog(CDlgConnectionConfig::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgConnectionConfig)
m_edtDataBaseServerName = _T("");
m_edtUserName = _T("");
m_edtUserPassWord = _T("");
//}}AFX_DATA_INIT
}
CDlgConnectionConfig::~CDlgConnectionConfig()
{
m_ADOHandler.Clean();
}
void CDlgConnectionConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgConnectionConfig)
DDX_Text(pDX, IDC_EDIT_DATABASE_SERVERNAME, m_edtDataBaseServerName);
DDV_MaxChars(pDX, m_edtDataBaseServerName, 50);
DDX_Text(pDX, IDC_EDIT_USER_NAME, m_edtUserName);
DDV_MaxChars(pDX, m_edtUserName, 50);
DDX_Text(pDX, IDC_EDIT_USER_PASSWORD, m_edtUserPassWord);
DDV_MaxChars(pDX, m_edtUserPassWord, 50);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgConnectionConfig, CDialog)
//{{AFX_MSG_MAP(CDlgConnectionConfig)
ON_BN_CLICKED(IDC_BUTTON_TEST_CONNECT, OnButtonTestConnect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgConnectionConfig message handlers
int CDlgConnectionConfig::DoModal()
{
HINSTANCE hOld = AfxGetResourceHandle();
AfxSetResourceHandle(theApp.m_hInstance);
int res = CDialog::DoModal();
AfxSetResourceHandle(hOld);
return res;
}
void CDlgConnectionConfig::OnButtonTestConnect()
{
// TODO: Add your control notification handler code here
if(TestConnection())
{
if(MessageBox("测试通过,是否自动关闭配置窗体并使用该配置?\n选[是]关闭","提示",MB_YESNO)==IDYES)
CDialog::OnOK();
}
else
MessageBox("连接失败!\n请查询配置信息是否正确","提示");
}
void CDlgConnectionConfig::OnOK()
{
if(!TestConnection())
{
MessageBox("连接失败!\n请查询配置信息是否正确","提示");
return;
}
CDialog::OnOK();
}
bool CDlgConnectionConfig::TestConnection()
{
UpdateData();
if(m_edtDataBaseServerName.IsEmpty())
{
MessageBox("请输入[数据库服务名]","提示");
GetDlgItem(IDC_EDIT_DATABASE_SERVERNAME)->SetFocus();
return false;
}
if(m_edtUserName.IsEmpty())
{
MessageBox("请输入[用户名称]","提示");
GetDlgItem(IDC_EDIT_USER_NAME)->SetFocus();
return false;
}
EBOraConnectionInfo coninfo;
coninfo.sServerName = m_edtDataBaseServerName;
coninfo.sUserName = m_edtUserName;
coninfo.sPassword = m_edtUserPassWord;
if(!m_ADOHandler.InitInstance(coninfo))
return false;
return true;
}
BOOL CDlgConnectionConfig::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -