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

📄 billadddialog.cpp

📁 我做的日常开销数据库管理系统。使用vc+SQL sever2000开发
💻 CPP
字号:
// BillAddDialog.cpp : implementation file
//

#include "stdafx.h"
#include "MyHomeProject.h"
#include "BillAddDialog.h"

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

extern CMyHomeProjectApp theApp;
extern _ConnectionPtr theConnection;
/////////////////////////////////////////////////////////////////////////////
// CBillAddDialog dialog


CBillAddDialog::CBillAddDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CBillAddDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBillAddDialog)
	m_strBillname = _T("");
	m_strCon = _T("");
	m_strMoney = _T("");
	//}}AFX_DATA_INIT
}


void CBillAddDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBillAddDialog)
	DDX_Control(pDX, IDC_COMBO_HANDLER, m_cbHandler);
	DDX_Control(pDX, IDC_COMBO_SORT, m_cbSort);
	DDX_Control(pDX, IDC_DATETIMEPICKER_BILLDATE, m_dtpBilladd);
	DDX_Text(pDX, IDC_EDIT_BILLNAME, m_strBillname);
	DDX_Text(pDX, IDC_EDIT_ITEMCON, m_strCon);
	DDX_Text(pDX, IDC_EDIT_MONEY, m_strMoney);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBillAddDialog, CDialog)
	//{{AFX_MSG_MAP(CBillAddDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBillAddDialog message handlers

BOOL CBillAddDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here


	_RecordsetPtr initRst;
	initRst.CreateInstance(__uuidof(Recordset));
	
	try
	{
	initRst->Open("select 类型 from type",
		theConnection.GetInterfacePtr(),
		adOpenDynamic,
		adLockOptimistic,
		adCmdText);

	}
	catch(...)
	{
		AfxMessageBox("数据库连接出错!");
	}

	//获得类型字段,并显示到Combo中
	_variant_t var;
	CString strSort;
	while(!initRst->ADOEOF)
	{
		var=initRst->GetCollect("类型");
		if(var.vt!=VT_NULL)
			strSort=(LPCSTR)_bstr_t(var);
		m_cbSort.AddString(strSort);
		initRst->MoveNext();
	}

	initRst->Close();

	//获得人名,并显示
	try
	{
	initRst->Open("select 姓名 from handler",
		theConnection.GetInterfacePtr(),
		adOpenDynamic,
		adLockOptimistic,
		adCmdText);

	}
	catch(...)
	{
		AfxMessageBox("数据库连接出错!");
	}

	CString strName;
	while(!initRst->ADOEOF)
	{
		var=initRst->GetCollect("姓名");
		if(var.vt!=VT_NULL)
			strName=(LPCSTR)_bstr_t(var);
		m_cbHandler.AddString(strName);
		initRst->MoveNext();
	}	
	
	m_cbSort.SetCurSel(0);
	m_cbHandler.SetCurSel(0);


	initRst->Close();	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
	initRst.Release();
	initRst=NULL;
}

⌨️ 快捷键说明

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