123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "CDSVmsTextItemF.h"
- #include "VmsCommonLibF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- TVmsTextItem::TVmsTextItem()
- {
- }
- //---------------------------------------------------------------------------
- TVmsTextItem::~TVmsTextItem()
- {
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- TVmsTextItemManager *VmsTextItemManager = NULL;
- //---------------------------------------------------------------------------
- /*
- * Manager
- */
- TVmsTextItemManager::TVmsTextItemManager()
- {
- }
- //---------------------------------------------------------------------------
- TVmsTextItemManager::~TVmsTextItemManager()
- {
- }
- //---------------------------------------------------------------------------
- bool TVmsTextItemManager::LoadFromDb(TADOConnection *ADbConn/*=NULL*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT T.VMS_TXT_ITEM_ID AS TXT_ITEM_ID, \r\n"
- " T.VMS_TXT_ITEM_NM AS TXT_ITEM_NM, \r\n"
- " TRIM(T.VMS_TXT_ITEM_NM) AS TXT_ITEM_FILLIN \r\n"
- " FROM TB_VMS_TXT_ITEM T \r\n";
- FLists.Lock();
- FFillInLists.Lock();
- try
- {
- FLists.RemoveAll();
- FFillInLists.RemoveAll();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next())
- {
- TVmsTextItem *pObj = new TVmsTextItem();
- pObj->TXT_ITEM_ID = pADO->FieldByName("TXT_ITEM_ID")->AsString;
- pObj->TXT_ITEM_NM = pADO->FieldByName("TXT_ITEM_NM")->AsString;
- String FILL_IN = pADO->FieldByName("TXT_ITEM_FILLIN")->AsString.Trim();
- if (pObj->TXT_ITEM_ID == DFLT_TEXT_TYPE) {
- FILL_IN = "¹®ÀÚ¿";
- }
- if (pObj->TXT_ITEM_ID != DFLT_TEXT_TYPE && !FILL_IN.Pos("[") && !FILL_IN.Pos("]")) {
- FILL_IN = "[" + FILL_IN + "]";
- }
- pObj->TXT_ITEM_FILLIN = FILL_IN;
- FLists.Push(pObj->TXT_ITEM_ID, pObj);
- FFillInLists.Push(pObj->TXT_ITEM_FILLIN, pObj);
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TVmsTextItemManager::LoadFromDb", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TVmsTextItemManager::LoadFromDb", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- FLists.UnLock();
- FFillInLists.UnLock();
- }
- return true;
- }
- //---------------------------------------------------------------------------
|