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

📄 userinfoview.cpp

📁 这是一个关于数据库的例子
💻 CPP
字号:
// UserinfoView.cpp : implementation file
//

#include "stdafx.h"
#include "Inhabitants.h"
#include "UserinfoView.h"
#include "InhabitantsDoc.h"
#include "House.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUserinfoView

IMPLEMENT_DYNCREATE(CUserinfoView, CFormView)

CUserinfoView::CUserinfoView()
	: CFormView(CUserinfoView::IDD)
{
	//{{AFX_DATA_INIT(CUserinfoView)
	m_nBuildingnum = 0;
	m_nCellnum = 0;
	m_strHousemaster = _T("");
	m_nRoomnum = 0;
	m_strSectionname = _T("");
	m_strBeeppager = _T("");
	m_strEmail = _T("");
	m_strHouseTel = _T("");
	m_strMobile = "";
	m_strOffice = _T("");
	m_strOfficeTel = _T("");
	//}}AFX_DATA_INIT
}

CUserinfoView::~CUserinfoView()
{
}

void CUserinfoView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserinfoView)
	DDX_Text(pDX, IDC_EDIT_BUILDINGNUM, m_nBuildingnum);
	DDX_Text(pDX, IDC_EDIT_CELLNUM, m_nCellnum);
	DDX_Text(pDX, IDC_EDIT_HOUSEMASTER, m_strHousemaster);
	DDX_Text(pDX, IDC_EDIT_ROOMNUM, m_nRoomnum);
	DDX_Text(pDX, IDC_EDIT_SECTIONNAME, m_strSectionname);
	DDX_Text(pDX, IDC_EDIT_BEEPPAGER, m_strBeeppager);
	DDX_Text(pDX, IDC_EDIT_EMAIL, m_strEmail);
	DDX_Text(pDX, IDC_EDIT_HOMETEL, m_strHouseTel);
	DDX_Text(pDX, IDC_EDIT_MOBILE, m_strMobile);
	DDX_Text(pDX, IDC_EDIT_OFFICE, m_strOffice);
	DDX_Text(pDX, IDC_EDIT_OFFICETEL, m_strOfficeTel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserinfoView, CFormView)
	//{{AFX_MSG_MAP(CUserinfoView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserinfoView diagnostics

#ifdef _DEBUG
void CUserinfoView::AssertValid() const
{
	CFormView::AssertValid();
}

void CUserinfoView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CUserinfoView message handlers

//显示住址为strSectionName小区nBuildingNum号楼nCellNum单元nRoomNum房间的住户的详细信息
void CUserinfoView::UpdateUserInfo(CString strSectionName,int nBuildingNum,int nCellNum,int nRoomNum)
{
	//查询该住户
	CString strSql;
	strSql.Format("select * from house where sectionname = '%s' and buildingnum = %d and cellnum = %d and roomnum = %d",
		strSectionName,nBuildingNum,nCellNum,nRoomNum);
	CInhabitantsDoc* pDoc = (CInhabitantsDoc*)GetDocument();
	CCommand<CAccessor<CHouseAccessor> > dbHouse;
	long* pCount = new long;
	if(dbHouse.Open(pDoc->m_dbHouse.m_session,strSql,NULL,pCount) != S_OK)
	{
		AfxMessageBox("error");
		delete pCount;
		return;
	}

	//显示信息
	if(dbHouse.MoveFirst() == S_OK)
	{
		m_strHousemaster = dbHouse.m_housemaster;
		m_strSectionname = dbHouse.m_sectionname;
		m_nBuildingnum = dbHouse.m_buildingnum;
		m_nCellnum = dbHouse.m_cellnum;
		m_nRoomnum = dbHouse.m_roomnum;
		m_strHouseTel = dbHouse.m_housetel;
		m_strOffice = dbHouse.m_office;
		m_strOfficeTel = dbHouse.m_officetel;
		m_strBeeppager = dbHouse.m_beeppager;
		m_strMobile = dbHouse.m_mobile;
		m_strEmail = dbHouse.m_email;
	}
	dbHouse.Close();
	UpdateData(FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -