诸暨麻将添加redis
您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 
 
 
 

403 行
10 KiB

  1. #include "StdAfx.h"
  2. #include "DataBaseAide.h"
  3. #include "DataBase.h"
  4. //构造函数
  5. CDataBaseAide::CDataBaseAide(IUnknownEx * pIUnknownEx)
  6. {
  7. }
  8. //析构函数
  9. CDataBaseAide::~CDataBaseAide()
  10. {
  11. }
  12. bool CDataBaseAide::SetDataBase(IUnknownEx *pIUnKnownEx)
  13. {
  14. m_pIDataBase = (IDataBase *)pIUnKnownEx;
  15. if (m_pIDataBase != NULL)
  16. return true;
  17. else
  18. return false;
  19. }
  20. VOID *CDataBaseAide::GetDataBase(REFGUID Guid, DWORD dwQueryVer)
  21. {
  22. if (m_pIDataBase != NULL)
  23. return m_pIDataBase;
  24. return NULL;
  25. }
  26. /////////////////////////////////
  27. ////取数据
  28. INT CDataBaseAide::GetValue_INT(LPCTSTR pszItem)
  29. {
  30. INT nValue;
  31. if (m_pIDataBase != NULL)
  32. {
  33. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, nValue);
  34. return nValue;
  35. }
  36. return 0;
  37. }
  38. UINT CDataBaseAide::GetValue_UINT(LPCTSTR pszItem)
  39. {
  40. UINT ulValue;
  41. if (m_pIDataBase != NULL)
  42. {
  43. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, ulValue);
  44. return ulValue;
  45. }
  46. return 0;
  47. }
  48. DOUBLE CDataBaseAide::GetValue_DOUBLE(LPCTSTR pszItem)
  49. {
  50. DOUBLE dbValue;
  51. if (m_pIDataBase != NULL)
  52. {
  53. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, dbValue);
  54. return dbValue;
  55. }
  56. return 0;
  57. }
  58. BYTE CDataBaseAide::GetValue_BYTE(LPCTSTR pszItem)
  59. {
  60. BYTE bValue;
  61. if (m_pIDataBase != NULL)
  62. {
  63. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, bValue);
  64. return bValue;
  65. }
  66. return 0;
  67. }
  68. LONG CDataBaseAide::GetValue_LONG(LPCTSTR pszItem)
  69. {
  70. LONG lValue;
  71. if (m_pIDataBase != NULL)
  72. {
  73. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, lValue);
  74. return lValue;
  75. }
  76. return 0;
  77. }
  78. WORD CDataBaseAide::GetValue_WORD(LPCTSTR pszItem)
  79. {
  80. WORD wValue;
  81. if (m_pIDataBase != NULL)
  82. {
  83. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, wValue);
  84. return wValue;
  85. }
  86. return 0;
  87. }
  88. DWORD CDataBaseAide::GetValue_DWORD(LPCTSTR pszItem)
  89. {
  90. DWORD ulValue;
  91. if (m_pIDataBase != NULL)
  92. {
  93. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, ulValue);
  94. return ulValue;
  95. }
  96. return 0;
  97. }
  98. FLOAT CDataBaseAide::GetValue_FLOAT(LPCTSTR pszItem)
  99. {
  100. /*float fValue;
  101. if (m_pIDataBase != NULL)
  102. {
  103. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, fValue);
  104. return fValue;
  105. }*/
  106. return 0.0f;
  107. }
  108. LONGLONG CDataBaseAide::GetValue_LONGLONG(LPCTSTR pszItem)
  109. {
  110. __int64 llValue;
  111. if (m_pIDataBase != NULL)
  112. {
  113. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, llValue);
  114. return llValue;
  115. }
  116. return 0;
  117. }
  118. VOID CDataBaseAide::GetValue_VarValue(LPCTSTR pszItem, CDBVarValue & DBVarValue)
  119. {
  120. ((CDataBase*)m_pIDataBase)->GetRecordsetValue(pszItem, DBVarValue);
  121. return;
  122. }
  123. VOID CDataBaseAide::GetValue_SystemTime(LPCTSTR pszItem, SYSTEMTIME & SystemTime)
  124. {
  125. COleDateTime dt;
  126. if (m_pIDataBase != NULL)
  127. {
  128. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, dt);
  129. dt.GetAsSystemTime(SystemTime);
  130. }
  131. return;
  132. }
  133. //获取参数
  134. VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, CDBVarValue & DBVarValue)
  135. {
  136. if (m_pIDataBase != NULL)
  137. {
  138. ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
  139. }
  140. }
  141. //获取参数
  142. VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, LPSTR pszString, UINT uSize)
  143. {
  144. CDBVarValue DBVarValue;
  145. if (m_pIDataBase != NULL)
  146. {
  147. ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
  148. if (DBVarValue.vt != VT_NULL)
  149. {
  150. lstrcpynA(pszString, (_bstr_t)DBVarValue, uSize);
  151. }
  152. }
  153. }
  154. //获取参数
  155. VOID CDataBaseAide::GetParameter(LPCTSTR pszItem, LPWSTR pszString, UINT uSize)
  156. {
  157. CDBVarValue DBVarValue;
  158. if (m_pIDataBase != NULL)
  159. {
  160. ((CDataBase*)m_pIDataBase)->GetParameter(pszItem, DBVarValue);
  161. if (DBVarValue.vt != VT_NULL)
  162. {
  163. lstrcpynW(pszString, (_bstr_t)DBVarValue, uSize);
  164. }
  165. }
  166. }
  167. //重置参数
  168. VOID CDataBaseAide::ResetParameter()
  169. {
  170. if (m_pIDataBase != NULL)
  171. {
  172. ((CDataBase*)m_pIDataBase)->ClearParameters();
  173. ((CDataBase*)m_pIDataBase)->AddParameter(TEXT("RETURN_VALUE"), adInteger, adParamReturnValue, sizeof(long), _variant_t((long)0));
  174. }
  175. }
  176. //获取字符
  177. VOID CDataBaseAide::GetValue_String(LPCTSTR pszItem, LPSTR pszString, UINT uMaxCount)
  178. {
  179. if (m_pIDataBase != NULL)
  180. {
  181. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, (TCHAR*)pszString, uMaxCount);
  182. }
  183. }
  184. //获取字符
  185. VOID CDataBaseAide::GetValue_String(LPCTSTR pszItem, LPWSTR pszString, UINT uMaxCount)
  186. {
  187. if (m_pIDataBase != NULL)
  188. {
  189. ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, (TCHAR*)pszString, uMaxCount);
  190. }
  191. }
  192. //存储过程
  193. LONG CDataBaseAide::ExecuteProcess(LPCTSTR pszSPName, bool bRecordset)
  194. {
  195. if (m_pIDataBase != NULL)
  196. {
  197. ((CDataBase*)m_pIDataBase)->ExecuteProcess(pszSPName, bRecordset);
  198. return ((CDataBase*)m_pIDataBase)->GetReturnValue();
  199. }
  200. return -1;
  201. }
  202. //返回数值
  203. LONG CDataBaseAide::GetReturnValue()
  204. {
  205. if (m_pIDataBase != NULL)
  206. {
  207. return ((CDataBase*)m_pIDataBase)->GetReturnValue();
  208. }
  209. return -1;
  210. }
  211. //插入参数
  212. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, INT nValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  213. {
  214. if (m_pIDataBase != NULL)
  215. {
  216. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(int), _variant_t((long)nValue));
  217. }
  218. }
  219. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCSTR pszString, ADOCG::ParameterDirectionEnum ParameterDirection)
  220. {
  221. if (m_pIDataBase != NULL)
  222. {
  223. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarChar, ParameterDirection, strlen(pszString) + 1, _variant_t(pszString));
  224. }
  225. }
  226. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCSTR pszString, UINT uSize, ADOCG::ParameterDirectionEnum ParameterDirection)
  227. {
  228. if (m_pIDataBase != NULL)
  229. {
  230. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBinary, ParameterDirection, uSize, _variant_t(pszString));
  231. }
  232. }
  233. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCWSTR pszString, ADOCG::ParameterDirectionEnum ParameterDirection)
  234. {
  235. if (m_pIDataBase != NULL)
  236. {
  237. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, ParameterDirection, wcslen(pszString) + 1, _variant_t(pszString));
  238. }
  239. }
  240. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LPCWSTR pszString, UINT uSize, ADOCG::ParameterDirectionEnum ParameterDirection)
  241. {
  242. if (m_pIDataBase != NULL)
  243. {
  244. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBinary, ParameterDirection, uSize, _variant_t(pszString));
  245. }
  246. }
  247. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, SYSTEMTIME & SystemTime, ADOCG::ParameterDirectionEnum ParameterDirection)
  248. {
  249. TCHAR szSystemTime[128];
  250. _snwprintf(szSystemTime, 128, TEXT("%d-%02d-%02d %02d:%02d:%02d.%03d"), SystemTime.wYear,
  251. SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds);
  252. if (m_pIDataBase != NULL)
  253. {
  254. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, adParamInput, 128, _variant_t(szSystemTime));
  255. }
  256. }
  257. //插入参数
  258. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, UINT uValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  259. {
  260. if (m_pIDataBase != NULL)
  261. {
  262. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(UINT), _variant_t((long)uValue));
  263. }
  264. }
  265. //插入参数
  266. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LONG lValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  267. {
  268. if (m_pIDataBase != NULL)
  269. {
  270. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)lValue));
  271. }
  272. }
  273. //插入参数
  274. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, LONGLONG lValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  275. {
  276. if (m_pIDataBase != NULL)
  277. {
  278. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adBigInt, ParameterDirection, sizeof(__int64), _variant_t((__int64)lValue));
  279. }
  280. }
  281. //插入参数
  282. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, BYTE cbValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  283. {
  284. if (m_pIDataBase != NULL)
  285. {
  286. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)cbValue));
  287. }
  288. }
  289. //插入参数
  290. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, WORD wValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  291. {
  292. if (m_pIDataBase != NULL)
  293. {
  294. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(long), _variant_t((long)wValue));
  295. }
  296. }
  297. //插入参数
  298. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, DWORD dwValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  299. {
  300. if (m_pIDataBase != NULL)
  301. {
  302. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(int), _variant_t((long)dwValue));
  303. }
  304. }
  305. //插入参数
  306. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, FLOAT fValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  307. {
  308. if (m_pIDataBase != NULL)
  309. {
  310. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adInteger, ParameterDirection, sizeof(float), _variant_t((long)fValue));
  311. }
  312. }
  313. //插入参数
  314. VOID CDataBaseAide::AddParameter(LPCTSTR pszItem, DOUBLE dValue, ADOCG::ParameterDirectionEnum ParameterDirection)
  315. {
  316. if (m_pIDataBase != NULL)
  317. {
  318. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adDouble, ParameterDirection, sizeof(double), _variant_t((double)dValue));
  319. }
  320. }
  321. //插入参数
  322. VOID CDataBaseAide::AddParameterOutput(LPCTSTR pszItem, LPSTR pszString, UINT nSize, ADOCG::ParameterDirectionEnum ParameterDirection)
  323. {
  324. if (m_pIDataBase != NULL)
  325. {
  326. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarChar, adParamInputOutput, nSize, _variant_t(pszString));
  327. }
  328. }
  329. //插入参数
  330. VOID CDataBaseAide::AddParameterOutput(LPCTSTR pszItem, LPWSTR pszString, UINT nSize, ADOCG::ParameterDirectionEnum ParameterDirection)
  331. {
  332. if (m_pIDataBase != NULL)
  333. {
  334. ((CDataBase*)m_pIDataBase)->AddParameter(pszItem, adVarWChar, adParamInputOutput, nSize, _variant_t(pszString));
  335. return;
  336. }
  337. }