Click here to Skip to main content
15,896,308 members
Articles / Desktop Programming / MFC

Recordsets and invoices

Rate me:
Please Sign up or sign in to vote.
3.96/5 (9 votes)
23 Sep 2005CPOL10 min read 52.8K   808   21  
How to use CRecordset with the Northwind database to create an invoice.
#include "stdafx.h"
#include "Invoice.h"
#include "OrderSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// COrderSet

IMPLEMENT_DYNAMIC(COrderSet, CRecordset)

COrderSet::COrderSet(CDatabase* pdb)
	: CRecordset(pdb)
{
	//{{AFX_FIELD_INIT(COrderSet)
	m_lOrderID = 0;
	m_nFields = 1;
	//}}AFX_FIELD_INIT
	m_nDefaultType = snapshot;
    m_strSort      = _T("OrderID");
}


CString COrderSet::GetDefaultConnect()
{
	return _T("ODBC;DSN=Northwind");
}

CString COrderSet::GetDefaultSQL()
{
	return _T("[Orders]");
}

void COrderSet::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(COrderSet)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Long(pFX, _T("[OrderID]"), m_lOrderID);
	//}}AFX_FIELD_MAP
}

/////////////////////////////////////////////////////////////////////////////
// COrderSet diagnostics

#ifdef _DEBUG
void COrderSet::AssertValid() const
{
	CRecordset::AssertValid();
}

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

//====================================================================

bool COrderSet::IsOnFirstRecord( void ) const
{
	ASSERT_VALID(this);

	CRecordsetStatus status;
	GetStatus(status);
	
    return (0 == status.m_lCurrentRecord);
}

//====================================================================
 
bool COrderSet::IsOnLastRecord( void ) const
{	
    ASSERT_VALID(this);

	CRecordsetStatus status;
	GetStatus(status);

    if (! status.m_bRecordCountFinal)
		return (false);

    return (status.m_lCurrentRecord + 1 == GetRecordCount());
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Pinnacle Business Systems
United States United States

The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

HTTP 404 - File not found
Internet Information Services

Comments and Discussions