PRKH0101F.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. #include "ITSLangTransF.h"
  9. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "PRKH0101F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLabel"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxStyles"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma link "dxSkinMcSkin"
  39. #pragma resource "*.dfm"
  40. TPRKH0101 *PRKH0101 = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TPRKH0101::TPRKH0101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  43. : TForm(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. ITSSkin_Load(this);
  47. CMM_LoadForm(g_sFormsDir, this);
  48. FParent = hHandle;
  49. FStDateTime = sFrom;
  50. FEdDateTime = sTo;
  51. FIdList = sIdList;
  52. Caption = "주차장 실시간정보 이력";
  53. }
  54. //---------------------------------------------------------------------------
  55. __fastcall TPRKH0101::~TPRKH0101(void)
  56. {
  57. }
  58. //--------------------------------------------------------------------------
  59. void __fastcall TPRKH0101::FormInit()
  60. {
  61. ADOQry->Connection = ITSDb_GetConnection();
  62. m_pGDC = TvList->DataController;
  63. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<주차장 실시간정보 이력>";
  64. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  65. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TPRKH0101::FormShow(TObject *Sender)
  69. {
  70. FormInit();
  71. Refresh();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TPRKH0101::CommClose()
  76. {
  77. CMM_SaveForm(g_sFormsDir, this);
  78. //PRKH0101 = NULL;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TPRKH0101::TmrShowTimer(TObject *Sender)
  82. {
  83. TmrShow->Enabled = false;
  84. Application->ProcessMessages();
  85. SelHistory();
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TPRKH0101::ChkExpandClick(TObject *Sender)
  89. {
  90. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TPRKH0101::SelHistory()
  94. {
  95. TSqlCursor sqlCrs;
  96. String sQry;
  97. TADOQuery *pADO = ADOQry;
  98. sQry = "SELECT A.prk_plce_nmbr, A.prk_plce_manage_no, A.prk_plce_nm, \r\n"
  99. " H.* \r\n"
  100. " FROM TB_PRK_PLCE A, \r\n"
  101. " TB_PRK_PLCE_RT_HS H \r\n"
  102. " WHERE A.prk_plce_nmbr IN(" + FIdList + ") \r\n"
  103. " AND A.prk_plce_nmbr = H.prk_plce_nmbr \r\n"
  104. " AND H.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  105. " ORDER BY A.prk_plce_nmbr, H.CRTN_DT \r\n";
  106. try
  107. {
  108. ITSDb_SQLText(pADO, sQry);
  109. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  110. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  111. ITSDb_SQLOpen(pADO);
  112. DspHistory();
  113. }
  114. catch(EDatabaseError &E)
  115. {
  116. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  117. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  118. throw Exception(String(E.ClassName()) + E.Message);
  119. }
  120. catch(Exception &exception)
  121. {
  122. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  123. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  124. throw Exception(String(exception.ClassName()) + exception.Message);
  125. }
  126. }
  127. //---------------------------------------------------------------------------
  128. void __fastcall TPRKH0101::DspHistory()
  129. {
  130. TADOQuery *pADO = ADOQry;
  131. try
  132. {
  133. TcxGridChartSeries *pChart = NULL;
  134. CMM_ClearGridTableView(TvList);
  135. int nRow = 0;
  136. int nDataCnt = 0;
  137. try {
  138. TvList->BeginUpdate();
  139. nDataCnt = pADO->RecordCount;
  140. m_pGDC->RecordCount = nDataCnt;
  141. for( ; !pADO->Eof; pADO->Next(), nRow++)
  142. {
  143. TvList->DataController->Values[nRow][Col11->Index] = pADO->FieldByName("prk_plce_manage_no")->AsString;
  144. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("prk_plce_nm")->AsString;
  145. TvList->DataController->Values[nRow][Col02->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  146. int parking_cgs_sttus = pADO->FieldByName("parking_cgs_sttus")->AsInteger;
  147. String parking_cgs_desc = "알수없음";
  148. switch(parking_cgs_sttus)
  149. {
  150. case 0: parking_cgs_desc = "여유"; break;
  151. case 1: parking_cgs_desc = "보통"; break;
  152. case 2: parking_cgs_desc = "혼잡"; break;
  153. case 3: parking_cgs_desc = "만차"; break;
  154. }
  155. TvList->DataController->Values[nRow][Col03->Index] = parking_cgs_desc;
  156. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("prk_cmprt_co")->AsString;
  157. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("remndr_prk_cmprt_co")->AsString;
  158. }
  159. }
  160. __finally
  161. {
  162. if (pADO)
  163. {
  164. pADO->Close();
  165. }
  166. TvList->EndUpdate();
  167. //CxList->SetFocus();
  168. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  169. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  170. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  171. }
  172. }
  173. catch(EDatabaseError &E)
  174. {
  175. throw Exception(String(E.ClassName()) + E.Message);
  176. }
  177. catch(...)
  178. {
  179. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  180. }
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TPRKH0101::OnMessage(TMessage &Msg)
  184. {
  185. switch (Msg.Msg)
  186. {
  187. case WM_PARAM_DATABASE:
  188. if (WP_DB_SELECT_OK == Msg.WParam)
  189. {
  190. //ShowMessage("Select Ok");
  191. }
  192. break;
  193. }
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TPRKH0101::BtnExlSaveClick(TObject *Sender)
  197. {
  198. TcxGrid *pGrid = CxList;
  199. TcxGridTableView *pView = TvList;
  200. String sTitle = "주차장 실시간정보 이력";
  201. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TPRKH0101::FormClose(TObject *Sender, TCloseAction &Action)
  205. {
  206. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  207. CommClose();
  208. //PRKH0101 = NULL;
  209. }
  210. //---------------------------------------------------------------------------