|
- #include "StdAfx.h"
- #include "DataBaseAide.h"
- #include "DataBase.h"
-
- //构造函数
- CDataBaseAide::CDataBaseAide(IUnknownEx * pIUnknownEx)
- {
- }
- //析构函数
- CDataBaseAide::~CDataBaseAide()
- {
- }
-
- bool CDataBaseAide::SetDataBase(IUnknownEx *pIUnKnownEx)
- {
- m_pIDataBase = (IDataBase *)pIUnKnownEx;
- if (m_pIDataBase != NULL)
- return true;
- else
- return false;
- }
-
- VOID *CDataBaseAide::GetDataBase(REFGUID Guid, DWORD dwQueryVer)
- {
- if (m_pIDataBase != NULL)
- return m_pIDataBase;
- return NULL;
- }
- /////////////////////////////////
- ////取数据
-
- INT CDataBaseAide::GetValue_INT(LPCTSTR pszItem)
- {
- INT nValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, nValue);
- return nValue;
- }
- return 0;
- }
-
- UINT CDataBaseAide::GetValue_UINT(LPCTSTR pszItem)
- {
- UINT ulValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, ulValue);
- return ulValue;
-
- }
- return 0;
- }
-
- DOUBLE CDataBaseAide::GetValue_DOUBLE(LPCTSTR pszItem)
- {
- DOUBLE dbValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, dbValue);
- return dbValue;
-
- }
- return 0;
- }
-
- BYTE CDataBaseAide::GetValue_BYTE(LPCTSTR pszItem)
- {
- BYTE bValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, bValue);
- return bValue;
- }
-
- return 0;
- }
-
- LONG CDataBaseAide::GetValue_LONG(LPCTSTR pszItem)
- {
- LONG lValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, lValue);
- return lValue;
-
- }
- return 0;
-
- }
-
- WORD CDataBaseAide::GetValue_WORD(LPCTSTR pszItem)
- {
- WORD wValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, wValue);
- return wValue;
-
- }
- return 0;
-
- }
-
- DWORD CDataBaseAide::GetValue_DWORD(LPCTSTR pszItem)
- {
- DWORD ulValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, ulValue);
- return ulValue;
-
- }
- return 0;
- }
-
- FLOAT CDataBaseAide::GetValue_FLOAT(LPCTSTR pszItem)
- {
- /*float fValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, fValue);
- return fValue;
-
- }*/
- return 0.0f;
-
- }
-
- LONGLONG CDataBaseAide::GetValue_LONGLONG(LPCTSTR pszItem)
- {
- __int64 llValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, llValue);
- return llValue;
-
- }
- return 0;
- }
-
- VOID CDataBaseAide::GetValue_VarValue(LPCTSTR pszItem, CDBVarValue & DBVarValue)
- {
- ((CDataBase*)m_pIDataBase)->GetRecordsetValue(pszItem, DBVarValue);
- return;
- }
-
- VOID CDataBaseAide::GetValue_SystemTime(LPCTSTR pszItem, SYSTEMTIME & SystemTime)
- {
- COleDateTime dt;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, dt);
- dt.GetAsSystemTime(SystemTime);
-
- }
- return;
- }
-
-
- //获取参数
- VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, CDBVarValue & DBVarValue)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
- }
-
- }
-
- //获取参数
- VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, LPSTR pszString, UINT uSize)
- {
- CDBVarValue DBVarValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
- if (DBVarValue.vt != VT_NULL)
- {
- lstrcpynA(pszString, (_bstr_t)DBVarValue, uSize);
- }
- }
-
- }
-
- //获取参数
- VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, LPWSTR pszString, UINT uSize)
- {
- CDBVarValue DBVarValue;
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
- if (DBVarValue.vt != VT_NULL)
- {
- lstrcpynW(pszString, (_bstr_t)DBVarValue, uSize);
- }
- }
-
- }
-
- //重置参数
- VOID CDataBaseAide::ResetParameter()
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->ClearParameters();
- ((CDataBase*)m_pIDataBase)->AddParameter(TEXT("RETURN_VALUE"), adInteger, adParamReturnValue, sizeof(long), _variant_t((long)0));
- }
-
- }
-
- //获取字符
- VOID CDataBaseAide::GetValue_String(LPCTSTR pszItem, LPSTR pszString, UINT uMaxCount)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, (TCHAR*)pszString, uMaxCount);
- }
- }
-
- //获取字符
- VOID CDataBaseAide::GetValue_String(LPCTSTR pszItem, LPWSTR pszString, UINT uMaxCount)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, (TCHAR*)pszString, uMaxCount);
- }
- }
-
- //存储过程
- LONG CDataBaseAide::ExecuteProcess(LPCTSTR pszSPName, bool bRecordset)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->ExecuteProcess(pszSPName, bRecordset);
- return ((CDataBase*)m_pIDataBase)->GetReturnValue();
- }
- return -1;
-
- }
-
- //返回数值
- LONG CDataBaseAide::GetReturnValue()
- {
- if (m_pIDataBase != NULL)
- {
- return ((CDataBase*)m_pIDataBase)->GetReturnValue();
- }
- return -1;
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, INT nValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(int), _variant_t((long)nValue));
- }
- }
-
-
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCSTR pszString, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarChar, ParameterDirection, strlen(pszString) + 1, _variant_t(pszString));
- }
- }
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCSTR pszString, UINT uSize, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBinary, ParameterDirection, uSize, _variant_t(pszString));
- }
- }
-
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCWSTR pszString, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, ParameterDirection, wcslen(pszString) + 1, _variant_t(pszString));
- }
- }
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCWSTR pszString, UINT uSize, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBinary, ParameterDirection, uSize, _variant_t(pszString));
- }
- }
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, SYSTEMTIME & SystemTime, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- TCHAR szSystemTime[128];
- _snwprintf(szSystemTime, 128, TEXT("%d-%02d-%02d %02d:%02d:%02d.%03d"), SystemTime.wYear,
- SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds);
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, adParamInput, 128, _variant_t(szSystemTime));
- }
-
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, UINT uValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(UINT), _variant_t((long)uValue));
- }
-
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LONG lValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)lValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LONGLONG lValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBigInt, ParameterDirection, sizeof(__int64), _variant_t((__int64)lValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, BYTE cbValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)cbValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, WORD wValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)wValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, DWORD dwValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(int), _variant_t((long)dwValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, FLOAT fValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(float), _variant_t((long)fValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, DOUBLE dValue, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adDouble, ParameterDirection, sizeof(double), _variant_t((double)dValue));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameterOutput(LPCTSTR pszItem, LPSTR pszString, UINT nSize, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarChar, adParamInputOutput, nSize, _variant_t(pszString));
- }
- }
-
- //插入参数
- VOID CDataBaseAide::AddParameterOutput(LPCTSTR pszItem, LPWSTR pszString, UINT nSize, ADOCG::ParameterDirectionEnum ParameterDirection)
- {
- if (m_pIDataBase != NULL)
- {
- ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, adParamInputOutput, nSize, _variant_t(pszString));
- return;
- }
- }
-
-
-
-
-
-
-
-
-
|