You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
3.9 KiB
C++
137 lines
3.9 KiB
C++
// DbData.h: interface for the CDbData class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#if !defined(AFX_DBDATA_H__0D0C1496_4FEC_4915_A5FA_704DFD037931__INCLUDED_)
|
|
#define AFX_DBDATA_H__0D0C1496_4FEC_4915_A5FA_704DFD037931__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
#ifdef BUILD_UTILITYDLL
|
|
#define UTILITYDLL __declspec(dllexport)
|
|
#else
|
|
#define UTILITYDLL __declspec(dllimport)
|
|
#endif
|
|
|
|
#pragma warning ( push )
|
|
#pragma warning ( disable : 4995)
|
|
// TODO: Find alternative to deprecated Dao
|
|
|
|
/**
|
|
* @class CDbData
|
|
*
|
|
* @brief An utility class to convert Ole variables to other values.
|
|
*
|
|
*/
|
|
|
|
class UTILITYDLL CDbData
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* @enum DecimalFormatEnum
|
|
*
|
|
* @brief Values that represent the string value returned by the @ref GetValueInString function.
|
|
*
|
|
* @sa GetValueInString
|
|
*/
|
|
|
|
enum DecimalFormatEnum
|
|
{
|
|
/// Return float with one decimal (%.1f)
|
|
DECIMAL_PLACES_1 = 1,
|
|
/// Return float with two decimals (%.2f)
|
|
DECIMAL_PLACES_2,
|
|
/// Return float with 3 decimals (%.3f)
|
|
DECIMAL_PLACES_3,
|
|
/// Return float (%f)
|
|
DEFAULT_PLACES,
|
|
};
|
|
|
|
/**
|
|
* @enum BoolFormatEnum
|
|
*
|
|
* @brief Values that represent BoolFormatEnum value returned by the @ref GetValueInString function.
|
|
*
|
|
* @sa GetValueInString
|
|
*/
|
|
enum BoolFormatEnum
|
|
{
|
|
/// Return as OLE BOOL: AFX_OLE_TRUE(-1) and AFX_OLE_FALSE(0)
|
|
BOOL_IN_NUM = 0,
|
|
/// Return "Yes" for true and "No" for false
|
|
YES_NO,
|
|
/// Return "Enable" for true and "Disable" for false
|
|
ENABLE_DISABLE,
|
|
};
|
|
|
|
public:
|
|
static COleVariant ConvertToOleVariant(short nType, CString csValue);
|
|
|
|
static CString GetValueInString(short nType, COleVariant ovFieldValue,
|
|
DecimalFormatEnum iDecPlaces = CDbData::DECIMAL_PLACES_1,
|
|
BoolFormatEnum iBoolFormat = CDbData::BOOL_IN_NUM);
|
|
|
|
static CString GetBoolValueAsYesNo(COleVariant ovFieldValue);
|
|
|
|
/**
|
|
* get dbBoolean data in "Enable" or "Disable" Format.
|
|
*
|
|
* @param ovFieldValue The ov field value.
|
|
*
|
|
* @return Returns "Enable" for true and "Disable" for false.
|
|
*/
|
|
|
|
static CString GetBoolValueAsEnableDisable(COleVariant ovFieldValue);
|
|
|
|
#if _MSC_VER > 1200
|
|
#pragma deprecated(GetValueAsBOOl)
|
|
#endif
|
|
// get dbBoolean data in BOOL data type
|
|
static BOOL GetValueAsBOOl(COleVariant ovFieldValue);
|
|
|
|
// get dbBoolean data in BOOL data type
|
|
static BOOL GetValueAsBOOL(COleVariant ovFieldValue);
|
|
|
|
// get dbBoolean data as bool
|
|
static bool GetValueAsBool(COleVariant ovFieldValue);
|
|
|
|
// get dbByte data in BYTE data type
|
|
static BYTE GetValueAsBYTE(COleVariant ovFieldValue);
|
|
|
|
// get dbInteger data in BYTE data type
|
|
static int GetValueAsInt(COleVariant ovFieldValue);
|
|
|
|
// get dbLong data in long data type
|
|
static long GetValueAsLong(COleVariant ovFieldValue);
|
|
|
|
// get dbCurrency data in COleCurrent data type
|
|
static COleCurrency GetValueAsCOleCurrency(COleVariant ovFieldValue);
|
|
|
|
// get dbSingle data in Single data type
|
|
static float GetValueAsSingle(COleVariant ovFieldValue);
|
|
|
|
// get dbDouble data in double data type
|
|
static double GetValueAsDouble(COleVariant ovFieldValue);
|
|
|
|
// get dbDate data in COleDateTime data type
|
|
static COleDateTime GetValueAsCOleDateTime(COleVariant ovFieldValue);
|
|
|
|
// get dbText in CString data type
|
|
static CString GetValueAsString(COleVariant ovFieldValue);
|
|
|
|
static CString GetFieldData(CDaoRecordset &ExistPkgRS, CDaoFieldInfo daoFieldInfo);
|
|
|
|
private:
|
|
// default constructor
|
|
CDbData();
|
|
|
|
// default destructor
|
|
virtual ~CDbData();
|
|
};
|
|
#pragma warning( pop )
|
|
|
|
#endif // !defined(AFX_DBDATA_H__0D0C1496_4FEC_4915_A5FA_704DFD037931__INCLUDED_)
|