Click here to Skip to main content
15,884,176 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.6K   808   21  
How to use CRecordset with the Northwind database to create an invoice.
#if !defined(AFX_INVOICEVIEW_H__BA25E9FF_29F8_44C2_8305_B8772D5BA446__INCLUDED_)
#define AFX_INVOICEVIEW_H__BA25E9FF_29F8_44C2_8305_B8772D5BA446__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "InvoiceSet.h"
#include "HeaderCtrlEx.h"
#include "StaticEx.h"

class CInvoiceView : public CRecordView
{
protected: // create from serialization only
	CInvoiceView();
	DECLARE_DYNCREATE(CInvoiceView)

public:
	//{{AFX_DATA(CInvoiceView)
	enum { IDD = IDD_INVOICE_FORM };
	CStaticEx	m_lblShipTo;
	CStaticEx	m_lblBillTo;
	CStatic	m_lblBillCityStZip;
	CStatic	m_lblBillName;
	CStatic	m_lblBillCountry;
	CStatic	m_lblBillAddress;
	CStatic	m_lblShipCountry;
	CStatic	m_lblShipCityStZip;
	CStatic	m_lblShipAddress;
	CStatic	m_lblShipName;
	CListCtrl	m_lcDetails;
	CListCtrl	m_lcFooter;
	CListCtrl	m_lcHeader;
	//}}AFX_DATA
    
    CHeaderCtrlEx   m_ctrlHeader;

// Attributes
public:
	CInvoiceDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CInvoiceView)
	public:
	virtual CRecordset* OnGetRecordset();
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual void OnInitialUpdate(); // called first time after construct
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CInvoiceView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CInvoiceView)
	//}}AFX_MSG
    afx_msg BOOL OnMove(UINT nIDMoveCommand);
	DECLARE_MESSAGE_MAP()

private:
	COrderSet		*m_pOrderSet;
	CInvoiceSet		m_InvoiceSet;

    bool    FormatLocaleDate( const CTime date, CString &strDate );
    bool    FormatLocaleCurrency( const double dAmount, CString &strAmount );
    void    UpdateAddress( void );
    void    UpdateHeader( void );
    void    UpdateDetails( double &dSubtotal );
    void    UpdateFooter( const double &dSubtotal );
};

#ifndef _DEBUG  // debug version in InvoiceView.cpp
inline CInvoiceDoc* CInvoiceView::GetDocument()
   { return (CInvoiceDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_INVOICEVIEW_H__BA25E9FF_29F8_44C2_8305_B8772D5BA446__INCLUDED_)

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