PISH0101F.cpp 8.3 KB

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