PISH0101F.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 "PISH0101F.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. TPISH0101 *PISH0101 = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TPISH0101::TPISH0101(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 TPISH0101::~TPISH0101(void)
  56. {
  57. }
  58. //--------------------------------------------------------------------------
  59. void __fastcall TPISH0101::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 TPISH0101::FormShow(TObject *Sender)
  69. {
  70. FormInit();
  71. Refresh();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TPISH0101::CommClose()
  76. {
  77. CMM_SaveForm(g_sFormsDir, this);
  78. //PISH0101 = NULL;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TPISH0101::TmrShowTimer(TObject *Sender)
  82. {
  83. TmrShow->Enabled = false;
  84. Application->ProcessMessages();
  85. SelHistory();
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TPISH0101::ChkExpandClick(TObject *Sender)
  89. {
  90. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TPISH0101::SelHistory()
  94. {
  95. TSqlCursor sqlCrs;
  96. String sQry;
  97. TADOQuery *pADO = ADOQry;
  98. sQry = "SELECT A.PRLT_CTLR_NMBR, A.PRLT_CTLR_ID, A.PRLT_NM, \r\n"
  99. " H.* \r\n"
  100. " FROM TB_PRLT_CTLR A, \r\n"
  101. " TB_PRLT_RT_INFR_HS H \r\n"
  102. " WHERE A.PRLT_CTLR_NMBR IN(" + FIdList + ") \r\n"
  103. " AND A.PRLT_CTLR_NMBR = H.PRLT_CTLR_NMBR \r\n"
  104. " AND H.CRTN_DT BETWEEN :p01 AND :p02 \r\n";
  105. //" ORDER BY A.PRLT_CTLR_NMBR, H.FLOR_NMBR, H.UPDT_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 TPISH0101::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("PRLT_CTLR_ID")->AsString;
  144. TvList->DataController->Values[nRow][Col12->Index] = pADO->FieldByName("PRLT_NM")->AsString;
  145. TvList->DataController->Values[nRow][Col00->Index] = pADO->FieldByName("FLOR_NMBR")->AsString;
  146. //TvList->DataController->Values[nRow][Col01->Index] = pADO->FieldByName("FLORNM")->AsString;
  147. //TvList->DataController->Values[nRow][Col02->Index] = pADO->FieldByName("CRTN_DT")->AsString;
  148. TvList->DataController->Values[nRow][Col02->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  149. TvList->DataController->Values[nRow][Col03->Index] = pADO->FieldByName("GNRL_RMND_PRZN_NUM")->AsString;
  150. TvList->DataController->Values[nRow][Col04->Index] = pADO->FieldByName("LGVH_RMND_PRZN_NUM")->AsString;
  151. TvList->DataController->Values[nRow][Col05->Index] = pADO->FieldByName("HVVH_RMND_PRZN_NUM")->AsString;
  152. TvList->DataController->Values[nRow][Col06->Index] = pADO->FieldByName("EMVH_RMND_PRZN_NUM")->AsString;
  153. TvList->DataController->Values[nRow][Col07->Index] = pADO->FieldByName("HNDC_RMND_PRZN_NUM")->AsString;
  154. TvList->DataController->Values[nRow][Col08->Index] = pADO->FieldByName("WMON_RMND_PRZN_NUM")->AsString;
  155. TvList->DataController->Values[nRow][Col09->Index] = pADO->FieldByName("ELVH_RMND_PRZN_NUM")->AsString;
  156. TvList->DataController->Values[nRow][Col10->Index] = pADO->FieldByName("ETC_RMND_PRZN_NUM")->AsString;
  157. }
  158. }
  159. __finally
  160. {
  161. if (pADO)
  162. {
  163. pADO->Close();
  164. }
  165. TvList->EndUpdate();
  166. //CxList->SetFocus();
  167. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  168. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  169. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  170. }
  171. }
  172. catch(EDatabaseError &E)
  173. {
  174. throw Exception(String(E.ClassName()) + E.Message);
  175. }
  176. catch(...)
  177. {
  178. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  179. }
  180. }
  181. //---------------------------------------------------------------------------
  182. void __fastcall TPISH0101::OnMessage(TMessage &Msg)
  183. {
  184. switch (Msg.Msg)
  185. {
  186. case WM_PARAM_DATABASE:
  187. if (WP_DB_SELECT_OK == Msg.WParam)
  188. {
  189. //ShowMessage("Select Ok");
  190. }
  191. break;
  192. }
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TPISH0101::BtnExlSaveClick(TObject *Sender)
  196. {
  197. TcxGrid *pGrid = CxList;
  198. TcxGridTableView *pView = TvList;
  199. String sTitle = "주차장 실시간정보 이력";
  200. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TPISH0101::FormClose(TObject *Sender, TCloseAction &Action)
  204. {
  205. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  206. CommClose();
  207. //PISH0101 = NULL;
  208. }
  209. //---------------------------------------------------------------------------