TypesTable.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // TypesTable.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "cp_main.h"
  5. #include "TypesTable.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CTypesTable
  13. IMPLEMENT_DYNAMIC(CTypesTable, CDaoRecordset)
  14. CTypesTable::CTypesTable(CDaoDatabase* pdb)
  15. : CDaoRecordset(pdb)
  16. {
  17. //{{AFX_FIELD_INIT(CTypesTable)
  18. m_ID = 0;
  19. m_TypeText = _T("");
  20. m_nFields = 2;
  21. //}}AFX_FIELD_INIT
  22. m_nDefaultType = dbOpenDynaset;
  23. }
  24. CString CTypesTable::GetDefaultDBName()
  25. {
  26. return _T("C:\\Projects\\Ditto\\CP_Shared\\Release_DLL\\97.mdb");
  27. }
  28. CString CTypesTable::GetDefaultSQL()
  29. {
  30. return _T("[Types]");
  31. }
  32. void CTypesTable::DoFieldExchange(CDaoFieldExchange* pFX)
  33. {
  34. //{{AFX_FIELD_MAP(CTypesTable)
  35. pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  36. DFX_Long(pFX, _T("[ID]"), m_ID);
  37. DFX_Text(pFX, _T("[TypeText]"), m_TypeText);
  38. //}}AFX_FIELD_MAP
  39. }
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CTypesTable diagnostics
  42. #ifdef _DEBUG
  43. void CTypesTable::AssertValid() const
  44. {
  45. CDaoRecordset::AssertValid();
  46. }
  47. void CTypesTable::Dump(CDumpContext& dc) const
  48. {
  49. CDaoRecordset::Dump(dc);
  50. }
  51. #endif //_DEBUG
  52. BOOL CTypesTable::DeleteAll()
  53. {
  54. BOOL bRet = FALSE;
  55. try
  56. {
  57. theApp.EnsureOpenDB();
  58. theApp.m_pDatabase->Execute("DELETE * FROM Types", dbFailOnError);
  59. bRet = TRUE;
  60. }
  61. catch(CDaoException* e)
  62. {
  63. AfxMessageBox(e->m_pErrorInfo->m_strDescription);
  64. e->Delete();
  65. }
  66. return bRet;
  67. }
  68. void CTypesTable::Open(int nOpenType, LPCTSTR lpszSql, int nOptions)
  69. {
  70. m_pDatabase = theApp.EnsureOpenDB();
  71. CDaoRecordset::Open(nOpenType, lpszSql, nOptions);
  72. }