?? syncconfigview.cpp
字號:
// SyncConfigView.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "SyncConfigView.h"
#include "MainFrm.h"
#include "SQLCEDemo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSyncConfigView
IMPLEMENT_DYNCREATE(CSyncConfigView, CFormView)
CSyncConfigView::CSyncConfigView()
: CFormView(CSyncConfigView::IDD)
{
//{{AFX_DATA_INIT(CSyncConfigView)
m_strDBLoginID = _T("");
m_strDBPassword = _T("");
m_strDBName = _T("");
m_strDBServerName = _T("");
m_strURL = _T("");
//}}AFX_DATA_INIT
}
CSyncConfigView::~CSyncConfigView()
{
}
void CSyncConfigView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSyncConfigView)
DDX_Text(pDX, IDC_EDIT_DBLOGINID, m_strDBLoginID);
DDX_Text(pDX, IDC_EDIT_DBPASSWORD, m_strDBPassword);
DDX_Text(pDX, IDC_EDIT_DBNAME, m_strDBName);
DDX_Text(pDX, IDC_EDIT_DBSERVERNAME, m_strDBServerName);
DDX_Text(pDX, IDC_EDIT_URL, m_strURL);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSyncConfigView, CFormView)
//{{AFX_MSG_MAP(CSyncConfigView)
ON_BN_CLICKED(IDC_BUTTON_DEFAULT, OnButtonDefault)
ON_BN_CLICKED(IDC_BUTTON_RETURN, OnButtonReturn)
ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
ON_BN_CLICKED(IDC_BUTTON_DELDB, OnButtonDeldb)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSyncConfigView diagnostics
#ifdef _DEBUG
void CSyncConfigView::AssertValid() const
{
CFormView::AssertValid();
}
void CSyncConfigView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSyncConfigView message handlers
void CSyncConfigView::OnButtonDefault()
{
// TODO: Add your control notification handler code here
if (AfxMessageBox(L"使用默認下載配置將替換當前的配置,確定嗎?", MB_YESNO | MB_ICONQUESTION) == IDNO)
{
return;
}
m_strURL = L"http://172.20.16.64/ce2/sscesa20.dll";
m_strDBServerName = L"ssm1";
m_strDBName = L"cnemb";
m_strDBLoginID = L"cnemb";
m_strDBPassword = L"cnemb";
UpdateData(FALSE);
}
void CSyncConfigView::OnButtonReturn()
{
// TODO: Add your control notification handler code here
::PostMessage(AfxGetMainWnd()->m_hWnd,WM_USER_COMMAND, CMainFrame.RDAForm, 0);
}
void CSyncConfigView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// TODO: Add your specialized code here and/or call the base class
if (bActivate &&
pActivateView->GetRuntimeClass() == RUNTIME_CLASS(CSyncConfigView) &&
pDeactiveView->GetRuntimeClass() != RUNTIME_CLASS(CSyncConfigView))
{
CSQLCEDemoApp* pTheApp = (CSQLCEDemoApp*)AfxGetApp();
//每次均去查注冊表,取出保存的值
CString strSection = L"Sync";
CString strStringItem = L"DBServerName";
m_strDBServerName = pTheApp->GetProfileString(strSection, strStringItem);
strStringItem = L"DBName";
m_strDBName = pTheApp->GetProfileString(strSection, strStringItem);
strStringItem = L"DBLoginID";
m_strDBLoginID = pTheApp->GetProfileString(strSection, strStringItem);
strStringItem = L"DBPassword";
m_strDBPassword = pTheApp->GetProfileString(strSection, strStringItem);
strStringItem = L"URL";
//如果地址沒有就寫一個
strSection = pTheApp->GetProfileString(strSection, strStringItem);
if (strSection.GetLength() <= 1)
{
m_strURL = L"http://192.168.0.1/ce2/sscesa20.dll";
}
else
{
m_strURL = strSection;
}
UpdateData(FALSE);
}
//CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
void CSyncConfigView::OnButtonSave()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString strSection;
CString strStringItem;
CSQLCEDemoApp* pTheApp = (CSQLCEDemoApp*)AfxGetApp();
strSection = L"Sync";
strStringItem = L"DBServerName";
pTheApp->WriteProfileString(strSection, strStringItem, m_strDBServerName);
strStringItem = L"DBName";
pTheApp->WriteProfileString(strSection, strStringItem, m_strDBName);
strStringItem = L"DBLoginID";
pTheApp->WriteProfileString(strSection, strStringItem, m_strDBLoginID);
strStringItem = L"DBPassword";
pTheApp->WriteProfileString(strSection, strStringItem, m_strDBPassword);
strStringItem = L"URL";
pTheApp->WriteProfileString(strSection, strStringItem, m_strURL);
::PostMessage(AfxGetMainWnd()->m_hWnd,WM_USER_COMMAND, CMainFrame.RDAForm, 0);
}
void CSyncConfigView::OnButtonDeldb()
{
// TODO: Add your control notification handler code here
CString strMsg = CString(L"將要刪除數據庫,所以未上傳數據將丟失,是否確認?");
if (AfxMessageBox(strMsg, MB_YESNO | MB_ICONQUESTION) == IDYES)
{
CSQLCEDemoApp* pTheApp = (CSQLCEDemoApp*)AfxGetApp();
if (pTheApp->m_pADORs->IsOpened())
pTheApp->m_pADORs->Close();
if (pTheApp->m_pADOConn->IsConnected())
pTheApp->m_pADOConn->Close();
DeleteFile(L"\\palmheart.sdf");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -