⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syncconfigview.cpp

📁 WinCE开发技巧与实例的配套源码
💻 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 + -