CDSVmsFormF.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "CDSVmsFormF.h"
  4. #include "VMSOprMainLibF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. //---------------------------------------------------------------------------
  8. void TCDSVmsForm::Init()
  9. {
  10. }
  11. //---------------------------------------------------------------------------
  12. TCDSVmsFormManager *CDSVmsFormManager = NULL;
  13. //---------------------------------------------------------------------------
  14. /*
  15. * Manager
  16. */
  17. TCDSVmsFormManager::TCDSVmsFormManager()
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. TCDSVmsFormManager::~TCDSVmsFormManager()
  22. {
  23. FLists.RemoveAll();
  24. }
  25. //---------------------------------------------------------------------------
  26. void TCDSVmsFormManager::Init()
  27. {
  28. FOR_STL(TCDSVmsForm*, pObj, FLists)
  29. {
  30. pObj->Init();
  31. }
  32. }
  33. //---------------------------------------------------------------------------
  34. bool TCDSVmsFormManager::LoadFromDb(TADOConnection *ADbConn)
  35. {
  36. String sQry;
  37. TADOQuery *pADO = NULL;
  38. sQry = "SELECT VMS_FORM_ID, VALID_YN \r\n"
  39. " FROM TB_VMS_FORM \r\n";
  40. FLists.Lock();
  41. try
  42. {
  43. try
  44. {
  45. pADO = new TADOQuery(NULL);
  46. pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
  47. pADO->SQL->Clear();
  48. pADO->SQL->Text = sQry;
  49. pADO->Prepared = true;
  50. pADO->Open();
  51. for( ; !pADO->Eof; pADO->Next())
  52. {
  53. String VMS_FORM_ID = pADO->FieldByName("VMS_FORM_ID")->AsString.Trim();
  54. TCDSVmsForm *pObj = FLists.Find(VMS_FORM_ID);
  55. if (!pObj)
  56. {
  57. pObj = new TCDSVmsForm();
  58. pObj->VMS_FORM_ID = VMS_FORM_ID;
  59. FLists.Push(pObj->VMS_FORM_ID, pObj);
  60. }
  61. pObj->VALID_YN = pADO->FieldByName("VALID_YN")->AsString.Trim();
  62. }
  63. }
  64. catch(EDatabaseError &E)
  65. {
  66. DBERRORMSG("TCDSVmsFormManager::LoadFromDb", String(E.ClassName()), E.Message, sQry);
  67. throw Exception(String(E.ClassName()) + E.Message);
  68. }
  69. catch(Exception &e)
  70. {
  71. DBERRORMSG("TCDSVmsFormManager::LoadFromDb", String(e.ClassName()), e.Message, sQry);
  72. throw Exception(String(e.ClassName()) + e.Message);
  73. }
  74. }
  75. __finally
  76. {
  77. if (pADO)
  78. {
  79. pADO->Close();
  80. delete pADO;
  81. }
  82. FLists.UnLock();
  83. }
  84. return true;
  85. }
  86. //---------------------------------------------------------------------------
  87. void TCDSVmsFormManager::AddVmsForm(String AVMS_FORM_ID, String AVALID_YN)
  88. {
  89. TCDSVmsForm *pObj = FLists.Find(AVMS_FORM_ID);
  90. if (!pObj)
  91. {
  92. pObj = new TCDSVmsForm();
  93. pObj->VMS_FORM_ID = AVMS_FORM_ID;
  94. FLists.Push(pObj->VMS_FORM_ID, pObj);
  95. }
  96. pObj->VALID_YN = AVALID_YN;
  97. }
  98. //---------------------------------------------------------------------------
  99. bool TCDSVmsFormManager::IsValid(String AVMS_FORM_ID)
  100. {
  101. TCDSVmsForm *pObj = FLists.Find(AVMS_FORM_ID);
  102. if (!pObj)
  103. {
  104. return false;
  105. }
  106. return pObj->VALID_YN == "Y" ? true : false;
  107. }
  108. //---------------------------------------------------------------------------