Click here to Skip to main content
15,886,518 members
Articles / Desktop Programming / MFC

The alxBase classes for work with DBF files

Rate me:
Please Sign up or sign in to vote.
5.00/5 (22 votes)
5 Nov 20021 min read 361.6K   3.8K   57  
The alxBase classes for work with dbf files.
// DBFCursorset.h : interface of the CDBFCursorset class
//
/////////////////////////////////////////////////////////////////////////////
/*
�����:              �������� �.�.
����������:         alxsoft@gazinter.net
*/
/////////////////////////////////////////////////////////////////////////////

#if !defined(ALX_DBFCURSORSET_H__INCLUDED_)
#define ALX_DBFCURSORSET_H__INCLUDED_

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

#include <afxtempl.h>
#include "DBFRecordset.h"

////////////////////////////////////////////////////////////////////////
// CDBFCursorset - the result of a query or base table browse

class ALX_EXT_CLASS CDBFCursorset : public CDBFRecordset
{
	DECLARE_DYNAMIC(CDBFCursorset)

// Constructor
public:
	CDBFCursorset(CDBFTableDef* pDBFTable = NULL);

	void Open(LPCTSTR lpszFileName, UINT nOpenFlag = ALX_DBF_USE_SHARED);
	void Close();

// Attributes
public:
	BOOL IsOpen() const;	// ������ �� �����
	BOOL IsBOF() const;		// ������ �� ������
	BOOL IsEOF() const;		// ��������� �� ������

	long GetRecordCount();	// ���������� �������

protected:
	long m_nCurCursorRecN;	// ������ ������� ������

	BOOL m_bBOF;			
	BOOL m_bEOF;

// Operations
public:
	// Cursor operations
	void MoveNext();		// ������� �� ��������� ������
	void MovePrev();		// ������� �� ���������� ������
	void MoveFirst();		// ������� �� ������ ������
	void MoveLast();		// ������� �� ��������� ������
	void Move(long lOffsetRec); // ������� �� ������ �� ��������


	long GetAbsolutePosition();					// ���������� ������� ���. ������
	void SetAbsolutePosition(long lPosition);	// ������� �� ���������� ������� � ������

	// edit buffer operations
	virtual void AddNew();		// �������� ������
	virtual void Edit();		// �������� ������

	virtual void Update();		// ��������� ���������
	virtual void CancelUpdate();// �����

	virtual void Remove();		// ������� ������ �� ������

	// Recordset operations
	void Requery();				// �������� ����� �������

	// ���������� ���������� ��� ��� ���������� �� �������� ������
	void SetDelete(BOOL bHideDeleteRec = TRUE);
	BOOL GetDelete();
	// �������� ��������� �� ������� �������
	void SetFilter(BOOL (FAR * lpfnIsInclude) (DBF_CHAR*, CDBFFields* pDBFFields));
	// ����������
	void SortByField(int nIndex, BOOL bDesc = FALSE);
	void SortByField(LPCTSTR lpszName, BOOL bDesc = FALSE);

// Overridables
public:


// Implementation
public:
	virtual ~CDBFCursorset();

	// Out-of-date functions kept for backward compatability

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif


protected:
	virtual void ThrowDBFException(long nError = NO_ALX_DBF_ERROR);

private:
	void SetRecord(long lRecNumber, const DBF_CHAR* lpBuffer);	// �������� ������

	void qsort (int from, int to);						// �������� ���������� �������
	int compare(const long elem1, const long elem2 );	// �������� ��������� �������

	CArray<long, long> m_RecPtr;// ������ ���������� �� ������ �������

	int m_nSortedField;			// ������ ���� �� �������� ������������� �������
	BOOL m_bDesc;				// ���� ����� ����������� �� �������� TRUE

	BOOL m_bShowDeletedRec;		// ���������� �������� �� ���������� �� �������� ������

	// ��������� �� ������� �������
	BOOL (FAR * m_lpfnIsInclude) (DBF_CHAR*, CDBFFields* pDBFFields);
};

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

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

#endif // !defined(ALX_DBFCURSORSET_H__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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
Year of birth - 1974.
Eeducation - was ended by Kaliningrad State University in 1997.
Now I work as the engineer-programmer in Kaliningrad (RUSSIA).

Comments and Discussions