DSRH0301F.cpp 9.3 KB

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