FrmInitializeF.cpp 3.6 KB

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