PISH0201F.cpp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 "PISH0201F.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 link "cxTextEdit"
  38. #pragma resource "*.dfm"
  39. TPISH0201 *PISH0201 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TPISH0201::TPISH0201(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  42. : TForm(Owner)
  43. {
  44. LangTrans->Translate(this, ITSDb_GetConnection());
  45. ITSSkin_Load(this);
  46. CMM_LoadForm(g_sFormsDir, this);
  47. FParent = hHandle;
  48. FStDateTime = sFrom;
  49. FEdDateTime = sTo;
  50. FIdList = sIdList;
  51. Caption = "주차장 실시간정보 이력";
  52. }
  53. //---------------------------------------------------------------------------
  54. __fastcall TPISH0201::~TPISH0201(void)
  55. {
  56. }
  57. //--------------------------------------------------------------------------
  58. void __fastcall TPISH0201::FormInit()
  59. {
  60. ADOQry->Connection = ITSDb_GetConnection();
  61. m_pGDC = TvList->DataController;
  62. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<주차장 실시간정보 이력>";
  63. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  64. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TPISH0201::FormShow(TObject *Sender)
  68. {
  69. FormInit();
  70. Refresh();
  71. TmrShow->Enabled = true;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TPISH0201::CommClose()
  75. {
  76. CMM_SaveForm(g_sFormsDir, this);
  77. //PISH0201 = NULL;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TPISH0201::TmrShowTimer(TObject *Sender)
  81. {
  82. TmrShow->Enabled = false;
  83. Application->ProcessMessages();
  84. SelHistory();
  85. }
  86. //---------------------------------------------------------------------------
  87. void __fastcall TPISH0201::ChkExpandClick(TObject *Sender)
  88. {
  89. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TPISH0201::SelHistory()
  93. {
  94. TSqlCursor sqlCrs;
  95. String sQry;
  96. TADOQuery *pADO = ADOQry;
  97. sQry = "SELECT A.*, B.PRLT_CTLR_ID, B.PRLT_NM \r\n"
  98. " FROM TB_PRLT_CTLR_STTS_HS A, TB_PRLT_CTLR B \r\n"
  99. " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  100. " AND B.PRLT_CTLR_NMBR IN(" + FIdList + ") \r\n"
  101. " AND A.PRLT_CTLR_NMBR = B.PRLT_CTLR_NMBR \r\n"
  102. " ORDER BY A.PRLT_CTLR_NMBR, A.CRTN_DT \r\n";
  103. try
  104. {
  105. ITSDb_SQLText(pADO, sQry);
  106. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  107. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  108. ITSDb_SQLOpen(pADO);
  109. DspHistory();
  110. }
  111. catch(EDatabaseError &E)
  112. {
  113. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  114. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  115. throw Exception(String(E.ClassName()) + E.Message);
  116. }
  117. catch(Exception &exception)
  118. {
  119. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  120. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  121. throw Exception(String(exception.ClassName()) + exception.Message);
  122. }
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TPISH0201::DspHistory()
  126. {
  127. TADOQuery *pADO = ADOQry;
  128. try
  129. {
  130. TcxGridChartSeries *pChart = NULL;
  131. CMM_ClearGridTableView(TvList);
  132. int nRow = 0;
  133. int nDataCnt = 0;
  134. try {
  135. TvList->BeginUpdate();
  136. nDataCnt = pADO->RecordCount;
  137. m_pGDC->RecordCount = nDataCnt;
  138. for( ; !pADO->Eof; pADO->Next(), nRow++)
  139. {
  140. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("PRLT_CTLR_NMBR")->AsString;
  141. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("PRLT_CTLR_ID")->AsString;
  142. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("PRLT_NM")->AsString;
  143. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  144. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  145. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  146. if (CMNC_STTS_CD == "CMS0") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm0->Caption;
  147. else
  148. if (CMNC_STTS_CD == "CMS1") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm1->Caption;
  149. else m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblUnknown->Caption;
  150. }
  151. }
  152. __finally
  153. {
  154. if (pADO)
  155. {
  156. pADO->Close();
  157. }
  158. TvList->EndUpdate();
  159. //CxList->SetFocus();
  160. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  161. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  162. Application->MessageBox(sEnd.c_str(),
  163. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  164. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  165. }
  166. }
  167. catch(EDatabaseError &E)
  168. {
  169. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  170. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  171. throw Exception(String(E.ClassName()) + E.Message);
  172. }
  173. catch(Exception &e)
  174. {
  175. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  176. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  177. throw Exception(String(e.ClassName()) + e.Message);
  178. }
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TPISH0201::OnMessage(TMessage &Msg)
  182. {
  183. switch (Msg.Msg)
  184. {
  185. case WM_PARAM_DATABASE:
  186. if (WP_DB_SELECT_OK == Msg.WParam)
  187. {
  188. //ShowMessage("Select Ok");
  189. }
  190. break;
  191. }
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TPISH0201::BtnExlSaveClick(TObject *Sender)
  195. {
  196. TcxGrid *pGrid = CxList;
  197. TcxGridTableView *pView = TvList;
  198. String sTitle = "주차장 상태이력";
  199. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  200. }
  201. //---------------------------------------------------------------------------
  202. void __fastcall TPISH0201::FormClose(TObject *Sender, TCloseAction &Action)
  203. {
  204. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  205. CommClose();
  206. //PISH0201 = NULL;
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TPISH0201::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  210. bool &ADone)
  211. {
  212. TColor tColor = ACanvas->Brush->Color;
  213. TColor tFont = clBlack;
  214. try
  215. {
  216. if (!VarIsNull(AViewInfo->Value))
  217. {
  218. String sTmp = AViewInfo->Value;
  219. if (sTmp == FrmLang->lblComm0->Caption)
  220. {
  221. tColor = clLime;
  222. }
  223. else
  224. if (sTmp == FrmLang->lblComm1->Caption)
  225. {
  226. tColor = clRed;
  227. }
  228. else
  229. {
  230. tColor = clSilver;
  231. }
  232. }
  233. ACanvas->Font->Color = tFont;
  234. ACanvas->SetBrushColor(tColor);
  235. }
  236. catch(...)
  237. {
  238. }
  239. }
  240. //---------------------------------------------------------------------------