123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "CDSVmsFormF.h"
- #include "ITS_OPLibF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- void TCDSVmsForm::Init()
- {
- }
- //---------------------------------------------------------------------------
- TCDSVmsFormManager *CDSVmsFormManager = NULL;
- //---------------------------------------------------------------------------
- /*
- * Manager
- */
- TCDSVmsFormManager::TCDSVmsFormManager()
- {
- }
- //---------------------------------------------------------------------------
- TCDSVmsFormManager::~TCDSVmsFormManager()
- {
- FLists.RemoveAll();
- }
- //---------------------------------------------------------------------------
- void TCDSVmsFormManager::Init()
- {
- FOR_STL(TCDSVmsForm*, pObj, FLists)
- {
- pObj->Init();
- }
- }
- //---------------------------------------------------------------------------
- bool TCDSVmsFormManager::LoadFromDb(TADOConnection *ADbConn)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT VMS_FORM_ID, VALID_YN \r\n"
- " FROM TB_VMS_FORM \r\n";
- FLists.Lock();
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next())
- {
- String VMS_FORM_ID = pADO->FieldByName("VMS_FORM_ID")->AsString.Trim();
- TCDSVmsForm *pObj = FLists.Find(VMS_FORM_ID);
- if (!pObj)
- {
- pObj = new TCDSVmsForm();
- pObj->VMS_FORM_ID = VMS_FORM_ID;
- FLists.Push(pObj->VMS_FORM_ID, pObj);
- }
- pObj->VALID_YN = pADO->FieldByName("VALID_YN")->AsString.Trim();
- }
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("TCDSVmsFormManager::LoadFromDb", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("TCDSVmsFormManager::LoadFromDb", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- FLists.UnLock();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void TCDSVmsFormManager::AddVmsForm(String AVMS_FORM_ID, String AVALID_YN)
- {
- TCDSVmsForm *pObj = FLists.Find(AVMS_FORM_ID);
- if (!pObj)
- {
- pObj = new TCDSVmsForm();
- pObj->VMS_FORM_ID = AVMS_FORM_ID;
- FLists.Push(pObj->VMS_FORM_ID, pObj);
- }
- pObj->VALID_YN = AVALID_YN;
- }
- //---------------------------------------------------------------------------
- bool TCDSVmsFormManager::IsValid(String AVMS_FORM_ID)
- {
- TCDSVmsForm *pObj = FLists.Find(AVMS_FORM_ID);
- if (!pObj)
- {
- return false;
- }
- return pObj->VALID_YN == "Y" ? true : false;
- }
- //---------------------------------------------------------------------------
|