FrmInitializeF.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "DMDbF.h"
  5. #include "CDSCctvCtlrF.h"
  6. #pragma hdrstop
  7. #include "FrmInitializeF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxContainer"
  11. #pragma link "cxControls"
  12. #pragma link "cxEdit"
  13. #pragma link "cxGraphics"
  14. #pragma link "cxLabel"
  15. #pragma link "cxLookAndFeelPainters"
  16. #pragma link "cxLookAndFeels"
  17. #pragma link "cxProgressBar"
  18. #pragma link "dxSkinBlack"
  19. #pragma link "dxSkinBlue"
  20. #pragma link "dxSkinsCore"
  21. #pragma link "dxSkinMcSkin"
  22. #pragma resource "*.dfm"
  23. TFrmInitialize *FrmInitialize = NULL;
  24. //---------------------------------------------------------------------------
  25. __fastcall TFrmInitialize::TFrmInitialize(TComponent* Owner)
  26. : TForm(Owner)
  27. {
  28. if (g_AppCfg.sLang != "kr")
  29. {
  30. Caption = "Program initialize";
  31. LblStatus->Caption = "Initialize...";
  32. }
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TFrmInitialize::FormShow(TObject *Sender)
  36. {
  37. Refresh();
  38. TmrShow->Enabled = true;
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TFrmInitialize::TmrShowTimer(TObject *Sender)
  42. {
  43. TmrShow->Enabled = false;
  44. Refresh();
  45. Application->ProcessMessages();
  46. cxProgressBar1->Properties->Max = 100;
  47. try
  48. {
  49. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Connect database...";
  50. else LblStatus->Caption = "데이터베이스 연결 중...";
  51. Application->ProcessMessages();
  52. cxProgressBar1->Position = 10;
  53. if (g_AppCfg.itsdb.sConnectStr == "")
  54. {
  55. DMDb->SetConnectString(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
  56. }
  57. else
  58. {
  59. DMDb->SetConnectString(g_AppCfg.itsdb.sConnectStr);
  60. }
  61. if (!DMDb->Connect())
  62. {
  63. if (g_AppCfg.sLang != "kr")
  64. {
  65. Application->MessageBox(L"Database connection failed.\r\n\r\nPlease restart the program.",
  66. L"Database connection error !!!",
  67. MB_OK|MB_ICONERROR);
  68. }
  69. else
  70. {
  71. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
  72. L"데이터베이스 연결 오류!!!",
  73. MB_OK|MB_ICONERROR);
  74. }
  75. return;
  76. }
  77. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Loading basic informations...";
  78. else LblStatus->Caption = "기본 정보 로딩 중...";
  79. Application->ProcessMessages();
  80. cxProgressBar1->Position = 20;
  81. CctvCtlrManager->LoadFromDb(DMDb->GetConnection());
  82. if (g_AppCfg.sLang != "kr") LblStatus->Caption = "Loading status informations...";
  83. else LblStatus->Caption = "상태 정보 로딩 중...";
  84. Application->ProcessMessages();
  85. cxProgressBar1->Position = 100;
  86. Application->ProcessMessages();
  87. CctvCtlrManager->LoadStatusFromDb(DMDb->GetConnection());
  88. DMDb->Close();
  89. }
  90. catch(...)
  91. {
  92. }
  93. Close();
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TFrmInitialize::FormClose(TObject *Sender, TCloseAction &Action)
  97. {
  98. Action = caFree;
  99. }
  100. //---------------------------------------------------------------------------