EVSP200MF.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "ITS_OPLibF.h"
  8. #pragma hdrstop
  9. #include "EVSP200MF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxClasses"
  14. #pragma link "cxContainer"
  15. #pragma link "cxControls"
  16. #pragma link "cxCustomData"
  17. #pragma link "cxData"
  18. #pragma link "cxDataStorage"
  19. #pragma link "cxEdit"
  20. #pragma link "cxFilter"
  21. #pragma link "cxGraphics"
  22. #pragma link "cxGrid"
  23. #pragma link "cxGridBandedTableView"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxGroupBox"
  29. #pragma link "cxLabel"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxStyles"
  33. #pragma link "cxTextEdit"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma link "dxSkinBlack"
  38. #pragma link "dxSkinMcSkin"
  39. #pragma link "cxSpinEdit"
  40. #pragma link "cxDropDownEdit"
  41. #pragma link "cxMaskEdit"
  42. #pragma resource "*.dfm"
  43. TEVSP200M *EVSP200M = NULL;
  44. //---------------------------------------------------------------------------
  45. __fastcall TEVSP200M::TEVSP200M(TComponent* Owner)
  46. : TForm(Owner)
  47. {
  48. LangTrans->Translate(this, ITSDb_GetConnection());
  49. ITSSkin_Load(this);
  50. LoadLocalSkin();
  51. FTitle = Caption;
  52. CMM_LoadForm(g_sFormsDir, this);
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TEVSP200M::CommClose()
  56. {
  57. try
  58. {
  59. CMM_SaveForm(g_sFormsDir, this);
  60. }
  61. catch(...)
  62. {
  63. }
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TEVSP200M::FormCreate(TObject *Sender)
  67. {
  68. //
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TEVSP200M::FormShow(TObject *Sender)
  72. {
  73. APP_FillCode(CbType, "VHCL");
  74. Refresh();
  75. Application->ProcessMessages();
  76. TmrShow->Enabled = true;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TEVSP200M::LoadLocalSkin()
  80. {
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TEVSP200M::TmrShowTimer(TObject *Sender)
  84. {
  85. TmrShow->Enabled = false;
  86. BtnSearchClick(NULL);
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TEVSP200M::FormClose(TObject *Sender, TCloseAction &Action)
  90. {
  91. try {
  92. CommClose();
  93. EVSP200M = NULL;
  94. Action = caFree;
  95. } catch(...) {}
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TEVSP200M::OnMainFormMessage(TMessage &Msg)
  99. {
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TEVSP200M::RefreshDbData()
  103. {
  104. String sQry;
  105. TADOQuery *pADO = NULL;
  106. sQry = "SELECT A.EMRG_VHCL_ID, A.VHCL_NMBR, A.VHCL_KIND, A.USE_YN, \r\n"
  107. " NVL(B.SRVC_ID, '-') AS SRVC_ID, NVL(B.END_YN, '-') AS END_YN \r\n"
  108. " FROM EMRG_VHCL A \r\n"
  109. " LEFT OUTER JOIN PRIO_SGNL_REQ_INFR B \r\n"
  110. " ON A.EMRG_VHCL_ID = B.EMRG_VHCL_ID \r\n";
  111. CMM_ClearGridTableView(TvList);
  112. try
  113. {
  114. int nRow;
  115. TvList->BeginUpdate();
  116. try
  117. {
  118. pADO = new TADOQuery(NULL);
  119. pADO->Close();
  120. pADO->Connection = ITSDb_GetConnection();
  121. pADO->SQL->Clear();
  122. pADO->SQL->Text = sQry;
  123. pADO->Prepared = true;
  124. pADO->Open();
  125. for( ; !pADO->Eof; pADO->Next())
  126. {
  127. nRow = TvList->DataController->AppendRecord();
  128. TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("EMRG_VHCL_ID")->AsInteger;
  129. TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("VHCL_NMBR")->AsInteger;
  130. String VHCL_KIND = pADO->FieldByName("VHCL_KIND")->AsString;
  131. String USE_YN = pADO->FieldByName("USE_YN")->AsString;
  132. String END_YN = pADO->FieldByName("END_YN")->AsString;
  133. if (USE_YN == "Y") USE_YN = "[Y] »ç¿ë";
  134. else if (USE_YN == "N") USE_YN = "[N] ¹Ì»ç¿ë";
  135. if (END_YN == "Y") END_YN = "[Y] Á¾·á";
  136. else if (END_YN == "N") END_YN = "[N] ¿î¿µÁß";
  137. TvList->DataController->Values[nRow][Col03->Index] = "[" + VHCL_KIND + "] " + APP_GetCodeName(CbType, VHCL_KIND);
  138. TvList->DataController->Values[nRow][Col04->Index] = USE_YN;
  139. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("SRVC_ID")->AsString;
  140. TvList->DataController->Values[nRow][Col06->Index] = END_YN;
  141. }
  142. }
  143. catch(EDatabaseError &E)
  144. {
  145. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  146. DBERRORMSG("TEVSP200M::RefreshDbData", String(E.ClassName()), E.Message, sQry);
  147. throw Exception(String(E.ClassName()) + E.Message);
  148. }
  149. catch(Exception &exception)
  150. {
  151. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  152. DBERRORMSG("TEVSP200M::RefreshDbData", String(exception.ClassName()), exception.Message, sQry);
  153. throw Exception(String(exception.ClassName()) + exception.Message);
  154. }
  155. }
  156. __finally
  157. {
  158. if (pADO)
  159. {
  160. pADO->Close();
  161. delete pADO;
  162. }
  163. TvList->EndUpdate();
  164. }
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TEVSP200M::RefreshData()
  168. {
  169. try
  170. {
  171. LockWindowUpdate(Handle);
  172. RefreshDbData();
  173. }
  174. __finally
  175. {
  176. LockWindowUpdate(0);
  177. }
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TEVSP200M::BtnSearchClick(TObject *Sender)
  181. {
  182. RefreshData();
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TEVSP200M::BtnCloseClick(TObject *Sender)
  186. {
  187. Close();
  188. }
  189. //---------------------------------------------------------------------------