BDSH0101F.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #pragma hdrstop
  9. #include "BDSH0101F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCheckBox"
  14. #pragma link "cxClasses"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLookAndFeelPainters"
  29. #pragma link "cxLookAndFeels"
  30. #pragma link "cxSpinEdit"
  31. #pragma link "cxStyles"
  32. #pragma link "cxTextEdit"
  33. #pragma link "dxSkinBlack"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma resource "*.dfm"
  38. TBDSH0101 *BDSH0101 = NULL;
  39. //---------------------------------------------------------------------------
  40. __fastcall TBDSH0101::TBDSH0101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  41. : TForm(Owner)
  42. {
  43. ITSSkin_Load(this);
  44. CMM_LoadForm(g_sFormsDir, this);
  45. FParent = hHandle;
  46. FStDateTime = sFrom;
  47. FEdDateTime = sTo;
  48. FIdList = sIdList;
  49. Caption = "블랙박스 원시 수집 이력";
  50. Col16->Visible = false;
  51. Col16->VisibleForCustomization = false;
  52. }
  53. //---------------------------------------------------------------------------
  54. __fastcall TBDSH0101::~TBDSH0101(void)
  55. {
  56. }
  57. //--------------------------------------------------------------------------
  58. /*
  59. * form 초기화
  60. *
  61. * arguments
  62. *
  63. * return
  64. * void
  65. */
  66. void __fastcall TBDSH0101::FormInit()
  67. {
  68. ADOQry->Connection = ITSDb_GetConnection();
  69. m_pGDC = TvList->DataController;
  70. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<블랙박스 원시 수집 이력>";
  71. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  72. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  73. }
  74. //---------------------------------------------------------------------------
  75. /*
  76. * form을 보여줄때 호출되는 event 메서드이다.
  77. * arguments
  78. * Sender : event handler 객체
  79. * return
  80. * void
  81. */
  82. void __fastcall TBDSH0101::FormShow(TObject *Sender)
  83. {
  84. FormInit();
  85. Refresh();
  86. TmrShow->Enabled = true;
  87. }
  88. //---------------------------------------------------------------------------
  89. /*
  90. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  91. * Form과 DataModule class를 delete시킨다.
  92. * arguments
  93. *
  94. * return
  95. * void
  96. */
  97. void __fastcall TBDSH0101::CommClose()
  98. {
  99. CMM_SaveForm(g_sFormsDir, this);
  100. //BDSH0101 = NULL;
  101. }
  102. //---------------------------------------------------------------------------
  103. /*
  104. * 최초 1회 수행되는 타이머 이벤트
  105. * arguments
  106. * Sender : event handler 객체
  107. * return
  108. * void
  109. */
  110. void __fastcall TBDSH0101::TmrShowTimer(TObject *Sender)
  111. {
  112. TmrShow->Enabled = false;
  113. Application->ProcessMessages();
  114. SelHistory();
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TBDSH0101::ChkExpandClick(TObject *Sender)
  118. {
  119. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  120. }
  121. //---------------------------------------------------------------------------
  122. /*
  123. * Refresh Data Event Function
  124. * arguments
  125. *
  126. * return
  127. * void
  128. */
  129. void __fastcall TBDSH0101::SelHistory()
  130. {
  131. TSqlCursor sqlCrs;
  132. String sQry;
  133. TADOQuery *pADO = ADOQry;
  134. sQry = "SELECT A.*, \r\n"
  135. " B.OCRR_DT, \r\n"
  136. " B.TRMN_ID, \r\n"
  137. " B.EVT_TYPE, \r\n"
  138. " DECODE(B.EVT_TYPE, '1', '1.주기보고', \r\n"
  139. " '2', '2.사용자전송', \r\n"
  140. " '3', '3.긴급전송', \r\n"
  141. " '---') AS EVT_DESC, \r\n"
  142. " B.X_CRDN, \r\n"
  143. " B.Y_CRDN, \r\n"
  144. " B.GPS_DRCT, \r\n"
  145. " B.SPED, \r\n"
  146. " B.VHRN_MODE, \r\n"
  147. " DECODE(B.VHRN_MODE, '1', '1.주행모드', \r\n"
  148. " '2', '2.주차모드', \r\n"
  149. " '---') AS VHRN_DESC, \r\n"
  150. " B.TRMN_VER, \r\n"
  151. " B.LINK_ID, C.ROAD_NAME \r\n"
  152. " FROM TB_BDS_TRMN A, \r\n"
  153. " TB_BDS_RAW_CLCT B, \r\n"
  154. " TB_LINK C \r\n"
  155. " WHERE A.BDS_MNGM_NMBR IN(" + FIdList + ") \r\n"
  156. " AND A.BDS_MNGM_NMBR = B.BDS_MNGM_NMBR \r\n"
  157. " AND B.LINK_ID = C.LINK_ID(+) \r\n"
  158. " AND B.OCRR_DT BETWEEN :p01 \r\n"
  159. " AND :p02 \r\n";
  160. //" ORDER BY A.BDS_MNGM_NMBR, B.OCRR_DT \r\n";
  161. try
  162. {
  163. ITSDb_SQLText(pADO, sQry);
  164. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  165. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  166. ITSDb_SQLOpen(pADO);
  167. DspHistory();
  168. }
  169. catch(EDatabaseError &E)
  170. {
  171. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  172. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  173. throw Exception(String(E.ClassName()) + E.Message);
  174. }
  175. catch(Exception &exception)
  176. {
  177. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  178. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  179. throw Exception(String(exception.ClassName()) + exception.Message);
  180. }
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TBDSH0101::DspHistory()
  184. {
  185. TADOQuery *pADO = ADOQry;
  186. try
  187. {
  188. TcxGridChartSeries *pChart = NULL;
  189. CMM_ClearGridTableView(TvList);
  190. int nRow = 0;
  191. int nDataCnt = 0;
  192. try {
  193. TvList->BeginUpdate();
  194. nDataCnt = pADO->RecordCount;
  195. m_pGDC->RecordCount = nDataCnt;
  196. for( ; !pADO->Eof; pADO->Next(), nRow++)
  197. {
  198. TvList->DataController->Values[nRow][Col00->Index] = pADO->FieldByName("BDS_MNGM_NMBR")->AsInteger;
  199. TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("OPNC_NMBR")->AsString;
  200. TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("MDM_NMBR")->AsString;
  201. TvList->DataController->Values[nRow][Col03->Index] = pADO->FieldByName("USIM_NMBR")->AsString;
  202. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("VHCL_NMBR")->AsString;
  203. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("OWNR_NM")->AsString;
  204. TvList->DataController->Values[nRow][Col06->Index] = pADO->FieldByName("PRCT_NM")->AsString;
  205. TvList->DataController->Values[nRow][Col07->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("OCRR_DT")->AsString).FormatString(STR_DATETIME);
  206. TvList->DataController->Values[nRow][Col16->Index] = pADO->FieldByName("TRMN_ID")->AsString;
  207. TvList->DataController->Values[nRow][Col08->Index] = pADO->FieldByName("EVT_DESC")->AsString;
  208. TvList->DataController->Values[nRow][Col09->Index] = pADO->FieldByName("X_CRDN")->AsString;
  209. TvList->DataController->Values[nRow][Col10->Index] = pADO->FieldByName("Y_CRDN")->AsString;
  210. TvList->DataController->Values[nRow][Col11->Index] = pADO->FieldByName("GPS_DRCT")->AsString;
  211. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("SPED")->AsString;
  212. TvList->DataController->Values[nRow][Col13->Index] = pADO->FieldByName("VHRN_DESC")->AsString;
  213. TvList->DataController->Values[nRow][Col14->Index] = pADO->FieldByName("TRMN_VER")->AsString;
  214. String LINK_ID = pADO->FieldByName("LINK_ID")->AsString;
  215. if (LINK_ID.Trim() == "0") LINK_ID = "";
  216. TvList->DataController->Values[nRow][Col20->Index] = LINK_ID;
  217. TvList->DataController->Values[nRow][Col21->Index] = pADO->FieldByName("ROAD_NAME")->AsString;
  218. }
  219. }
  220. __finally
  221. {
  222. if (pADO)
  223. {
  224. pADO->Close();
  225. }
  226. TvList->EndUpdate();
  227. //CxList->SetFocus();
  228. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  229. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  230. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  231. }
  232. }
  233. catch(EDatabaseError &E)
  234. {
  235. throw Exception(String(E.ClassName()) + E.Message);
  236. }
  237. catch(...)
  238. {
  239. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  240. }
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TBDSH0101::OnMessage(TMessage &Msg)
  244. {
  245. switch (Msg.Msg)
  246. {
  247. case WM_PARAM_DATABASE:
  248. if (WP_DB_SELECT_OK == Msg.WParam)
  249. {
  250. //ShowMessage("Select Ok");
  251. }
  252. break;
  253. }
  254. }
  255. //---------------------------------------------------------------------------
  256. void __fastcall TBDSH0101::BtnExlSaveClick(TObject *Sender)
  257. {
  258. TcxGrid *pGrid = CxList;
  259. TcxGridTableView *pView = TvList;
  260. String sTitle = "블랙박스 원시 수집 이력";
  261. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  262. }
  263. //---------------------------------------------------------------------------
  264. void __fastcall TBDSH0101::FormClose(TObject *Sender, TCloseAction &Action)
  265. {
  266. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  267. CommClose();
  268. //BDSH0101 = NULL;
  269. }
  270. //---------------------------------------------------------------------------