BDS0020MF.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "BDS0020MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxClasses"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxCustomData"
  16. #pragma link "cxData"
  17. #pragma link "cxDataStorage"
  18. #pragma link "cxEdit"
  19. #pragma link "cxFilter"
  20. #pragma link "cxGraphics"
  21. #pragma link "cxGrid"
  22. #pragma link "cxGridCustomTableView"
  23. #pragma link "cxGridCustomView"
  24. #pragma link "cxGridLevel"
  25. #pragma link "cxGridTableView"
  26. #pragma link "cxGroupBox"
  27. #pragma link "cxLookAndFeelPainters"
  28. #pragma link "cxLookAndFeels"
  29. #pragma link "cxSpinEdit"
  30. #pragma link "cxStyles"
  31. #pragma link "cxTextEdit"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma resource "*.dfm"
  37. TBDS0020M *BDS0020M = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TBDS0020M::TBDS0020M(TComponent* Owner)
  40. : TForm(Owner)
  41. {
  42. ITSSkin_Load(this);
  43. CMM_LoadForm(g_sFormsDir, this);
  44. Col16->Visible = false;
  45. Col16->VisibleForCustomization = false;
  46. }
  47. //---------------------------------------------------------------------------
  48. /*
  49. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  50. * Form과 DataModule class를 delete시킨다.
  51. * arguments
  52. *
  53. * return
  54. * void
  55. */
  56. void __fastcall TBDS0020M::CommClose()
  57. {
  58. try
  59. {
  60. TmrQry->Enabled = false;
  61. CMM_SaveForm(g_sFormsDir, this);
  62. }
  63. catch(...)
  64. {
  65. }
  66. }
  67. //---------------------------------------------------------------------------
  68. /*
  69. * Form을 보여줄때 호출되는 event 메서드이다.
  70. * arguments
  71. * Sender : event handler 객체
  72. * return
  73. * void
  74. */
  75. void __fastcall TBDS0020M::FormShow(TObject *Sender)
  76. {
  77. Refresh();
  78. FormInit();
  79. TmrShow->Enabled = true;
  80. }
  81. //---------------------------------------------------------------------------
  82. /*
  83. * form 초기화
  84. *
  85. * arguments
  86. *
  87. * return
  88. * void
  89. */
  90. void __fastcall TBDS0020M::FormInit()
  91. {
  92. }
  93. //---------------------------------------------------------------------------
  94. /*
  95. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  96. * arguments
  97. * Sender : event handler 객체
  98. * return
  99. * void
  100. */
  101. void __fastcall TBDS0020M::TmrShowTimer(TObject *Sender)
  102. {
  103. TmrShow->Enabled = false;
  104. TmrQry->Interval = 100;
  105. TmrQry->Enabled = true;
  106. }
  107. //---------------------------------------------------------------------------
  108. /*
  109. * Refresh Data Event Function
  110. * arguments
  111. *
  112. * return
  113. * void
  114. */
  115. void __fastcall TBDS0020M::RefreshData()
  116. {
  117. // 검색조건에 의한 링크 데이터 조회
  118. String sQry;
  119. TADOQuery *pADO = NULL;
  120. sQry = "SELECT A.*, \r\n"
  121. " B.UPDT_DT, \r\n"
  122. " B.TRMN_ID, \r\n"
  123. " B.EVT_TYPE, \r\n"
  124. " DECODE(B.EVT_TYPE, '1', '1.주기보고', \r\n"
  125. " '2', '2.사용자전송', \r\n"
  126. " '3', '3.긴급전송', \r\n"
  127. " '---') AS EVT_DESC, \r\n"
  128. " B.X_CRDN, \r\n"
  129. " B.Y_CRDN, \r\n"
  130. " B.GPS_DRCT, \r\n"
  131. " B.SPED, \r\n"
  132. " B.VHRN_MODE, \r\n"
  133. " DECODE(B.VHRN_MODE, '1', '1.주행모드', \r\n"
  134. " '2', '2.주차모드', \r\n"
  135. " '---') AS VHRN_DESC, \r\n"
  136. " B.TRMN_VER, \r\n"
  137. " B.LINK_ID, C.ROAD_NAME \r\n"
  138. " FROM TB_BDS_TRMN A, \r\n"
  139. " TB_BDS_RAW_PNST B, \r\n"
  140. " TB_LINK C \r\n"
  141. " WHERE A.BDS_MNGM_NMBR = B.BDS_MNGM_NMBR(+) \r\n"
  142. " AND B.LINK_ID = C.LINK_ID(+) \r\n"
  143. " ORDER BY B.UPDT_DT, A.BDS_MNGM_NMBR \r\n";
  144. CMM_ClearGridTableView(TvList);
  145. try
  146. {
  147. int nRow;
  148. TvList->BeginUpdate();
  149. try
  150. {
  151. int nORD;
  152. pADO = new TADOQuery(NULL);
  153. pADO->Close();
  154. pADO->Connection = ITSDb_GetConnection();
  155. pADO->SQL->Clear();
  156. pADO->SQL->Text = sQry;
  157. pADO->Open();
  158. for( ; !pADO->Eof; pADO->Next())
  159. {
  160. nRow = TvList->DataController->AppendRecord();
  161. TvList->DataController->Values[nRow][Col00->Index] = pADO->FieldByName("BDS_MNGM_NMBR")->AsInteger;
  162. TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("OPNC_NMBR")->AsString;
  163. TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("MDM_NMBR")->AsString;
  164. TvList->DataController->Values[nRow][Col03->Index] = pADO->FieldByName("USIM_NMBR")->AsString;
  165. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("VHCL_NMBR")->AsString;
  166. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("OWNR_NM")->AsString;
  167. TvList->DataController->Values[nRow][Col06->Index] = pADO->FieldByName("PRCT_NM")->AsString;
  168. TvList->DataController->Values[nRow][Col07->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("UPDT_DT")->AsString).FormatString(STR_DATETIME);
  169. TvList->DataController->Values[nRow][Col16->Index] = pADO->FieldByName("TRMN_ID")->AsString;
  170. TvList->DataController->Values[nRow][Col08->Index] = pADO->FieldByName("EVT_DESC")->AsString;
  171. TvList->DataController->Values[nRow][Col09->Index] = pADO->FieldByName("X_CRDN")->AsString;
  172. TvList->DataController->Values[nRow][Col10->Index] = pADO->FieldByName("Y_CRDN")->AsString;
  173. TvList->DataController->Values[nRow][Col11->Index] = pADO->FieldByName("GPS_DRCT")->AsString;
  174. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("SPED")->AsString;
  175. TvList->DataController->Values[nRow][Col13->Index] = pADO->FieldByName("VHRN_DESC")->AsString;
  176. TvList->DataController->Values[nRow][Col14->Index] = pADO->FieldByName("TRMN_VER")->AsString;
  177. String LINK_ID = pADO->FieldByName("LINK_ID")->AsString;
  178. if (LINK_ID.Trim() == "0") LINK_ID = "";
  179. TvList->DataController->Values[nRow][Col20->Index] = LINK_ID;
  180. TvList->DataController->Values[nRow][Col21->Index] = pADO->FieldByName("ROAD_NAME")->AsString;
  181. }
  182. }
  183. catch(EDatabaseError &E)
  184. {
  185. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  186. DBERRORMSG("블랙박스 원시현황 조회", String(E.ClassName()), E.Message, sQry);
  187. throw Exception(String(E.ClassName()) + E.Message);
  188. }
  189. catch(Exception &exception)
  190. {
  191. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  192. DBERRORMSG("블랙박스 원시현황 조회", String(exception.ClassName()), exception.Message, sQry);
  193. throw Exception(String(exception.ClassName()) + exception.Message);
  194. }
  195. }
  196. __finally
  197. {
  198. if (pADO)
  199. {
  200. pADO->Close();
  201. delete pADO;
  202. }
  203. TvList->EndUpdate();
  204. }
  205. }
  206. //---------------------------------------------------------------------------
  207. /*
  208. * Close 버튼 클릭 이벤트 핸들러
  209. * arguments
  210. * Sender : event handler 객체
  211. * return
  212. * void
  213. */
  214. void __fastcall TBDS0020M::BtnCloseClick(TObject *Sender)
  215. {
  216. Close();
  217. }
  218. //---------------------------------------------------------------------------
  219. void __fastcall TBDS0020M::FormClose(TObject *Sender, TCloseAction &Action)
  220. {
  221. CommClose();
  222. BDS0020M = NULL;
  223. Action = caFree;
  224. }
  225. //---------------------------------------------------------------------------
  226. void __fastcall TBDS0020M::TmrQryTimer(TObject *Sender)
  227. {
  228. TmrQry->Enabled = false;
  229. RefreshData();
  230. TmrQry->Interval = 60 * 1000;
  231. TmrQry->Enabled = true;
  232. BtnSearch->Enabled = true;
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TBDS0020M::BtnSearchClick(TObject *Sender)
  236. {
  237. Application->ProcessMessages();
  238. //TSqlCursor sqlCrs((TControl*)BtnSearch);
  239. BtnSearch->Enabled = false;
  240. TmrQry->Interval = 100;
  241. TmrQry->Enabled = true;
  242. }
  243. //---------------------------------------------------------------------------
  244. void __fastcall TBDS0020M::TvListDataControllerFilterChanged(TObject *Sender)
  245. {
  246. CMM_SetFilterLike(TvList);
  247. }
  248. //---------------------------------------------------------------------------