CDSVmsTextItemF.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "CDSVmsTextItemF.h"
  4. #include "VmsCommonLibF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. TVmsTextItem::TVmsTextItem()
  8. {
  9. }
  10. //---------------------------------------------------------------------------
  11. TVmsTextItem::~TVmsTextItem()
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. //---------------------------------------------------------------------------
  16. TVmsTextItemManager *VmsTextItemManager = NULL;
  17. //---------------------------------------------------------------------------
  18. /*
  19. * Manager
  20. */
  21. TVmsTextItemManager::TVmsTextItemManager()
  22. {
  23. }
  24. //---------------------------------------------------------------------------
  25. TVmsTextItemManager::~TVmsTextItemManager()
  26. {
  27. }
  28. //---------------------------------------------------------------------------
  29. bool TVmsTextItemManager::LoadFromDb(TADOConnection *ADbConn/*=NULL*/)
  30. {
  31. String sQry;
  32. TADOQuery *pADO = NULL;
  33. sQry = "SELECT T.VMS_TXT_ITEM_ID AS TXT_ITEM_ID, \r\n"
  34. " T.VMS_TXT_ITEM_NM AS TXT_ITEM_NM, \r\n"
  35. " TRIM(T.VMS_TXT_ITEM_NM) AS TXT_ITEM_FILLIN \r\n"
  36. " FROM TB_VMS_TXT_ITEM T \r\n";
  37. FLists.Lock();
  38. FFillInLists.Lock();
  39. try
  40. {
  41. FLists.RemoveAll();
  42. FFillInLists.RemoveAll();
  43. try
  44. {
  45. pADO = new TADOQuery(NULL);
  46. pADO->Close();
  47. pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
  48. pADO->SQL->Clear();
  49. pADO->SQL->Text = sQry;
  50. pADO->Prepared = true;
  51. pADO->Open();
  52. for( ; !pADO->Eof; pADO->Next())
  53. {
  54. TVmsTextItem *pObj = new TVmsTextItem();
  55. pObj->TXT_ITEM_ID = pADO->FieldByName("TXT_ITEM_ID")->AsString;
  56. pObj->TXT_ITEM_NM = pADO->FieldByName("TXT_ITEM_NM")->AsString;
  57. String FILL_IN = pADO->FieldByName("TXT_ITEM_FILLIN")->AsString.Trim();
  58. if (pObj->TXT_ITEM_ID == DFLT_TEXT_TYPE) {
  59. FILL_IN = "¹®ÀÚ¿­";
  60. }
  61. if (pObj->TXT_ITEM_ID != DFLT_TEXT_TYPE && !FILL_IN.Pos("[") && !FILL_IN.Pos("]")) {
  62. FILL_IN = "[" + FILL_IN + "]";
  63. }
  64. pObj->TXT_ITEM_FILLIN = FILL_IN;
  65. FLists.Push(pObj->TXT_ITEM_ID, pObj);
  66. FFillInLists.Push(pObj->TXT_ITEM_FILLIN, pObj);
  67. }
  68. }
  69. catch(EDatabaseError &E)
  70. {
  71. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  72. DBERRORMSG("TVmsTextItemManager::LoadFromDb", String(E.ClassName()), E.Message, sQry);
  73. throw Exception(String(E.ClassName()) + E.Message);
  74. }
  75. catch(Exception &exception)
  76. {
  77. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  78. DBERRORMSG("TVmsTextItemManager::LoadFromDb", String(exception.ClassName()), exception.Message, sQry);
  79. throw Exception(String(exception.ClassName()) + exception.Message);
  80. }
  81. }
  82. __finally
  83. {
  84. if (pADO)
  85. {
  86. pADO->Close();
  87. delete pADO;
  88. }
  89. FLists.UnLock();
  90. FFillInLists.UnLock();
  91. }
  92. return true;
  93. }
  94. //---------------------------------------------------------------------------