DSRH0301F.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 "ITS_OPLibF.h"
  9. #pragma hdrstop
  10. #include "DSRH0301F.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 "cxTextEdit"
  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. TDSRH0301 *DSRH0301 = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TDSRH0301::TDSRH0301(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 = "DSRC 제어 이력";
  53. }
  54. //---------------------------------------------------------------------------
  55. __fastcall TDSRH0301::~TDSRH0301(void)
  56. {
  57. }
  58. //--------------------------------------------------------------------------
  59. void __fastcall TDSRH0301::FormInit()
  60. {
  61. ADOQry->Connection = ITSDb_GetConnection();
  62. m_pGDC = TvList->DataController;
  63. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC 제어 이력 정보>";
  64. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  65. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TDSRH0301::FormShow(TObject *Sender)
  69. {
  70. FormInit();
  71. Refresh();
  72. TmrShow->Enabled = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TDSRH0301::CommClose()
  76. {
  77. CMM_SaveForm(g_sFormsDir, this);
  78. //DSRH0301 = NULL;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TDSRH0301::TmrShowTimer(TObject *Sender)
  82. {
  83. TmrShow->Enabled = false;
  84. Application->ProcessMessages();
  85. SelHistory();
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TDSRH0301::ChkExpandClick(TObject *Sender)
  89. {
  90. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TDSRH0301::SelHistory()
  94. {
  95. TSqlCursor sqlCrs;
  96. String sQry;
  97. TADOQuery *pADO = ADOQry;
  98. #if 1
  99. sQry = "SELECT A.ID, B.RSE_ID, B.ISTL_LCTN_NM, \r\n"
  100. " A.CNTL_DT, A.DEVC_TYPE, A.CNTL_TYPE, A.RSPS_TYPE \r\n"
  101. " FROM TB_RSE_CNTL_HS A, TB_RSE_MSTR B \r\n"
  102. " WHERE CNTL_DT BETWEEN :p01 AND :p02 \r\n"
  103. " AND A.ID = B.ID \r\n"
  104. " AND B.ID IN(" + FIdList + ") \r\n"
  105. " ORDER BY A.ID, A.CNTL_DT \r\n";
  106. //" ORDER BY TO_NUMBER(ID), CNTL_DT \r\n";
  107. #else
  108. sQry = "SELECT ID, CNTL_DT, DEVC_TYPE, CNTL_TYPE, RSPS_TYPE \r\n"
  109. " FROM TB_RSE_CNTL_HS \r\n"
  110. " WHERE CNTL_DT BETWEEN :p01 AND :p02 \r\n"
  111. " AND ID IN(" + FIdList + ") \r\n"
  112. " ORDER BY ID, CNTL_DT \r\n";
  113. //" ORDER BY TO_NUMBER(ID), CNTL_DT \r\n";
  114. #endif
  115. try
  116. {
  117. ITSDb_SQLText(pADO, sQry);
  118. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  119. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  120. ITSDb_SQLOpen(pADO);
  121. DspHistory();
  122. }
  123. catch(EDatabaseError &E)
  124. {
  125. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  126. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  127. throw Exception(String(E.ClassName()) + E.Message);
  128. }
  129. catch(Exception &exception)
  130. {
  131. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  132. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  133. throw Exception(String(exception.ClassName()) + exception.Message);
  134. }
  135. }
  136. //---------------------------------------------------------------------------
  137. void __fastcall TDSRH0301::DspHistory()
  138. {
  139. TADOQuery *pADO = ADOQry;
  140. try
  141. {
  142. TcxGridChartSeries *pChart = NULL;
  143. CMM_ClearGridTableView(TvList);
  144. int nRow = 0;
  145. int nDataCnt = 0;
  146. try {
  147. TvList->BeginUpdate();
  148. nDataCnt = pADO->RecordCount;
  149. //m_pGDC->RecordCount = nDataCnt;
  150. //for( ; !pADO->Eof; pADO->Next(), nRow++)
  151. for( ; !pADO->Eof; pADO->Next())
  152. {
  153. String sDevcType = pADO->FieldByName("DEVC_TYPE")->AsString;
  154. if (sDevcType == "2" ||
  155. sDevcType == "3" ||
  156. sDevcType == "4" ) continue;
  157. nRow = m_pGDC->AppendRecord();
  158. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("ID")->AsString;
  159. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("RSE_ID")->AsString;
  160. m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
  161. String sDbDate = pADO->FieldByName("CNTL_DT")->AsString;
  162. //m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  163. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_StrToDateTime(sDbDate).FormatString(STR_DATETIME);
  164. String sCntlType = pADO->FieldByName("CNTL_TYPE")->AsString;
  165. String sRspsType = pADO->FieldByName("RSPS_TYPE")->AsString;
  166. if (sDevcType == "0") sDevcType = "제어부";
  167. else// if (sDevcType == "1") sDevcType = "안테나 1";
  168. sDevcType = "안테나 " + sDevcType;
  169. m_pGDC->Values[nRow][Column02->Index] = sDevcType;
  170. if (sCntlType == "1") sCntlType = "시스템 리셋요청";
  171. else if (sCntlType == "2") sCntlType = "PUSH 방송정보 삭제";
  172. else if (sCntlType == "3") sCntlType = "방송정보 삭제";
  173. else if (sCntlType == "4") sCntlType = "무선송출 중단";
  174. else if (sCntlType == "5") sCntlType = "무선송출 개시";
  175. m_pGDC->Values[nRow][Column03->Index] = sCntlType;
  176. if (sRspsType == "0") sRspsType = "수용";
  177. else if (sRspsType == "1") sRspsType = "거절";
  178. else if (sRspsType == "2") sRspsType = "응답없음";
  179. m_pGDC->Values[nRow][Column04->Index] = sRspsType;
  180. }
  181. }
  182. __finally
  183. {
  184. if (pADO)
  185. {
  186. pADO->Close();
  187. }
  188. TvList->EndUpdate();
  189. //CxList->SetFocus();
  190. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  191. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  192. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  193. }
  194. }
  195. catch(EDatabaseError &E)
  196. {
  197. throw Exception(String(E.ClassName()) + E.Message);
  198. }
  199. catch(...)
  200. {
  201. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  202. }
  203. }
  204. //---------------------------------------------------------------------------
  205. void __fastcall TDSRH0301::OnMessage(TMessage &Msg)
  206. {
  207. switch (Msg.Msg)
  208. {
  209. case WM_PARAM_DATABASE:
  210. if (WP_DB_SELECT_OK == Msg.WParam)
  211. {
  212. //ShowMessage("Select Ok");
  213. }
  214. break;
  215. }
  216. }
  217. //---------------------------------------------------------------------------
  218. void __fastcall TDSRH0301::BtnExlSaveClick(TObject *Sender)
  219. {
  220. TcxGrid *pGrid = CxList;
  221. TcxGridTableView *pView = TvList;
  222. String sTitle = "DSRC 제어이력";
  223. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  224. }
  225. //---------------------------------------------------------------------------
  226. void __fastcall TDSRH0301::FormClose(TObject *Sender, TCloseAction &Action)
  227. {
  228. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  229. CommClose();
  230. //DSRH0301 = NULL;
  231. }
  232. //---------------------------------------------------------------------------