PISH0101F.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 "PISH0101F.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 "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma resource "*.dfm"
  37. TPISH0101 *PISH0101 = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TPISH0101::TPISH0101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  40. : TForm(Owner)
  41. {
  42. ITSSkin_Load(this);
  43. CMM_LoadForm(g_sFormsDir, this);
  44. FParent = hHandle;
  45. FStDateTime = sFrom;
  46. FEdDateTime = sTo;
  47. FIdList = sIdList;
  48. Caption = "주차장 실시간정보 이력";
  49. }
  50. //---------------------------------------------------------------------------
  51. __fastcall TPISH0101::~TPISH0101(void)
  52. {
  53. }
  54. //--------------------------------------------------------------------------
  55. /*
  56. * form 초기화
  57. *
  58. * arguments
  59. *
  60. * return
  61. * void
  62. */
  63. void __fastcall TPISH0101::FormInit()
  64. {
  65. ADOQry->Connection = ITSDb_GetConnection();
  66. m_pGDC = TvList->DataController;
  67. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<주차장 실시간정보 이력>";
  68. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  69. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  70. }
  71. //---------------------------------------------------------------------------
  72. /*
  73. * form을 보여줄때 호출되는 event 메서드이다.
  74. * arguments
  75. * Sender : event handler 객체
  76. * return
  77. * void
  78. */
  79. void __fastcall TPISH0101::FormShow(TObject *Sender)
  80. {
  81. FormInit();
  82. Refresh();
  83. TmrShow->Enabled = true;
  84. }
  85. //---------------------------------------------------------------------------
  86. /*
  87. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  88. * Form과 DataModule class를 delete시킨다.
  89. * arguments
  90. *
  91. * return
  92. * void
  93. */
  94. void __fastcall TPISH0101::CommClose()
  95. {
  96. CMM_SaveForm(g_sFormsDir, this);
  97. //PISH0101 = NULL;
  98. }
  99. //---------------------------------------------------------------------------
  100. /*
  101. * 최초 1회 수행되는 타이머 이벤트
  102. * arguments
  103. * Sender : event handler 객체
  104. * return
  105. * void
  106. */
  107. void __fastcall TPISH0101::TmrShowTimer(TObject *Sender)
  108. {
  109. TmrShow->Enabled = false;
  110. Application->ProcessMessages();
  111. SelHistory();
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TPISH0101::ChkExpandClick(TObject *Sender)
  115. {
  116. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * Refresh Data Event Function
  121. * arguments
  122. *
  123. * return
  124. * void
  125. */
  126. void __fastcall TPISH0101::SelHistory()
  127. {
  128. TSqlCursor sqlCrs;
  129. String sQry;
  130. TADOQuery *pADO = ADOQry;
  131. sQry = "SELECT A.CTLR_MNGM_NMBR, A.CTLR_MNGM_NM, \r\n"
  132. " B.FLOR_NMBR AS FLORID, B.FLOR_NM AS FLORNM, \r\n"
  133. " H.* \r\n"
  134. " FROM TB_PRLT_CTLR A, \r\n"
  135. " TB_PRLT_FLOR B, \r\n"
  136. " TB_PRLT_RT_INFR_HS H \r\n"
  137. " WHERE A.CTLR_MNGM_NMBR IN(" + FIdList + ") \r\n"
  138. " AND A.CTLR_MNGM_NMBR = B.CTLR_MNGM_NMBR \r\n"
  139. " AND B.CTLR_MNGM_NMBR = H.CTLR_MNGM_NMBR \r\n"
  140. " AND B.FLOR_NMBR = H.FLOR_NMBR \r\n"
  141. " AND H.CRTN_DT BETWEEN :p01 AND :p02 \r\n";
  142. //" ORDER BY A.CTLR_MNGM_NMBR, B.FLOR_NMBR, H.UPDT_DT \r\n";
  143. try
  144. {
  145. ITSDb_SQLText(pADO, sQry);
  146. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  147. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  148. ITSDb_SQLOpen(pADO);
  149. DspHistory();
  150. }
  151. catch(EDatabaseError &E)
  152. {
  153. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  154. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  155. throw Exception(String(E.ClassName()) + E.Message);
  156. }
  157. catch(Exception &exception)
  158. {
  159. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  160. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  161. throw Exception(String(exception.ClassName()) + exception.Message);
  162. }
  163. }
  164. //---------------------------------------------------------------------------
  165. void __fastcall TPISH0101::DspHistory()
  166. {
  167. TADOQuery *pADO = ADOQry;
  168. try
  169. {
  170. TcxGridChartSeries *pChart = NULL;
  171. CMM_ClearGridTableView(TvList);
  172. int nRow = 0;
  173. int nDataCnt = 0;
  174. try {
  175. TvList->BeginUpdate();
  176. nDataCnt = pADO->RecordCount;
  177. m_pGDC->RecordCount = nDataCnt;
  178. for( ; !pADO->Eof; pADO->Next(), nRow++)
  179. {
  180. TvList->DataController->Values[nRow][Col11->Index] = pADO->FieldByName("CTLR_MNGM_NMBR")->AsString;
  181. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("CTLR_MNGM_NM")->AsString;
  182. TvList->DataController->Values[nRow][Col00->Index] = pADO->FieldByName("FLORID")->AsString;
  183. TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("FLORNM")->AsString;
  184. //TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("CRTN_DT")->AsString;
  185. TvList->DataController->Values[nRow][Col02->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  186. TvList->DataController->Values[nRow][Col03->Index] = pADO->FieldByName("GNRL_RMND_PRZN_NUM")->AsString;
  187. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("LGVH_RMND_PRZN_NUM")->AsString;
  188. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("HVVH_RMND_PRZN_NUM")->AsString;
  189. TvList->DataController->Values[nRow][Col06->Index] = pADO->FieldByName("EMVH_RMND_PRZN_NUM")->AsString;
  190. TvList->DataController->Values[nRow][Col07->Index] = pADO->FieldByName("HNDC_RMND_PRZN_NUM")->AsString;
  191. TvList->DataController->Values[nRow][Col08->Index] = pADO->FieldByName("WMON_RMND_PRZN_NUM")->AsString;
  192. TvList->DataController->Values[nRow][Col09->Index] = pADO->FieldByName("ETC_RMND_PRZN_NUM")->AsString;
  193. }
  194. }
  195. __finally
  196. {
  197. if (pADO)
  198. {
  199. pADO->Close();
  200. }
  201. TvList->EndUpdate();
  202. //CxList->SetFocus();
  203. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  204. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  205. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  206. }
  207. }
  208. catch(EDatabaseError &E)
  209. {
  210. throw Exception(String(E.ClassName()) + E.Message);
  211. }
  212. catch(...)
  213. {
  214. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  215. }
  216. }
  217. //---------------------------------------------------------------------------
  218. void __fastcall TPISH0101::OnMessage(TMessage &Msg)
  219. {
  220. switch (Msg.Msg)
  221. {
  222. case WM_PARAM_DATABASE:
  223. if (WP_DB_SELECT_OK == Msg.WParam)
  224. {
  225. //ShowMessage("Select Ok");
  226. }
  227. break;
  228. }
  229. }
  230. //---------------------------------------------------------------------------
  231. void __fastcall TPISH0101::BtnExlSaveClick(TObject *Sender)
  232. {
  233. TcxGrid *pGrid = CxList;
  234. TcxGridTableView *pView = TvList;
  235. String sTitle = "주차장 실시간정보 이력";
  236. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  237. }
  238. //---------------------------------------------------------------------------
  239. void __fastcall TPISH0101::FormClose(TObject *Sender, TCloseAction &Action)
  240. {
  241. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  242. CommClose();
  243. //PISH0101 = NULL;
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TPISH0101::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  247. bool &ADone)
  248. {
  249. if( AViewInfo )
  250. {
  251. if(AViewInfo->Text == "정상")
  252. {
  253. ACanvas->Canvas->Font->Color = clTeal;
  254. }
  255. else if(AViewInfo->Text == "장애")
  256. {
  257. ACanvas->Canvas->Font->Color = clFuchsia;
  258. }
  259. else
  260. {
  261. ACanvas->Canvas->Font->Color = clGray;
  262. }
  263. }
  264. }
  265. //---------------------------------------------------------------------------