123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #include "WindowMsgF.h"
- #pragma hdrstop
- #include "DSRH0301F.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCheckBox"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- TDSRH0301 *DSRH0301 = NULL;
- //---------------------------------------------------------------------------
- __fastcall TDSRH0301::TDSRH0301(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
- : TForm(Owner)
- {
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- FParent = hHandle;
- FStDateTime = sFrom;
- FEdDateTime = sTo;
- FIdList = sIdList;
- Caption = "DSRC-RSE 제어 이력";
- }
- //---------------------------------------------------------------------------
- __fastcall TDSRH0301::~TDSRH0301(void)
- {
- }
- //--------------------------------------------------------------------------
- /*
- * form 초기화
- *
- * arguments
- *
- * return
- * void
- */
- void __fastcall TDSRH0301::FormInit()
- {
- ADOQry->Connection = ITSDb_GetConnection();
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC-RSE 제어 이력 정보>";
- //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
- LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
- }
- //---------------------------------------------------------------------------
- /*
- * form을 보여줄때 호출되는 event 메서드이다.
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TDSRH0301::FormShow(TObject *Sender)
- {
- FormInit();
- Refresh();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- /*
- * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
- * Form과 DataModule class를 delete시킨다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TDSRH0301::CommClose()
- {
- CMM_SaveForm(g_sFormsDir, this);
- //DSRH0301 = NULL;
- }
- //---------------------------------------------------------------------------
- /*
- * 최초 1회 수행되는 타이머 이벤트
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TDSRH0301::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- Application->ProcessMessages();
- SelHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TDSRH0301::ChkExpandClick(TObject *Sender)
- {
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- /*
- * Refresh Data Event Function
- * arguments
- *
- * return
- * void
- */
- void __fastcall TDSRH0301::SelHistory()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- #if 1
- sQry = "SELECT A.ID, B.RSE_ID, B.ISTL_LCTN_NM, \r\n"
- " A.CNTL_DT, A.DEVC_TYPE, A.CNTL_TYPE, A.RSPS_TYPE \r\n"
- " FROM TB_RSE_CNTL_HS A, TB_RSE_MSTR B \r\n"
- " WHERE CNTL_DT BETWEEN :p01 AND :p02 \r\n"
- " AND A.ID = B.ID \r\n"
- " AND B.ID IN(" + FIdList + ") \r\n"
- " ORDER BY A.ID, A.CNTL_DT \r\n";
- //" ORDER BY TO_NUMBER(ID), CNTL_DT \r\n";
- #else
- sQry = "SELECT ID, CNTL_DT, DEVC_TYPE, CNTL_TYPE, RSPS_TYPE \r\n"
- " FROM TB_RSE_CNTL_HS \r\n"
- " WHERE CNTL_DT BETWEEN :p01 AND :p02 \r\n"
- " AND ID IN(" + FIdList + ") \r\n"
- " ORDER BY ID, CNTL_DT \r\n";
- //" ORDER BY TO_NUMBER(ID), CNTL_DT \r\n";
- #endif
- try
- {
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", FStDateTime);
- ITSDb_SQLBind(pADO, "p02", FEdDateTime);
- ITSDb_SQLOpen(pADO);
- DspHistory();
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TDSRH0301::DspHistory()
- {
- TADOQuery *pADO = ADOQry;
- try
- {
- TcxGridChartSeries *pChart = NULL;
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- int nDataCnt = 0;
- try {
- TvList->BeginUpdate();
- nDataCnt = pADO->RecordCount;
- //m_pGDC->RecordCount = nDataCnt;
- //for( ; !pADO->Eof; pADO->Next(), nRow++)
- for( ; !pADO->Eof; pADO->Next())
- {
- String sDevcType = pADO->FieldByName("DEVC_TYPE")->AsString;
- if (sDevcType == "2" ||
- sDevcType == "3" ||
- sDevcType == "4" ) continue;
- nRow = m_pGDC->AppendRecord();
- m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("ID")->AsString;
- m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("RSE_ID")->AsString;
- m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
- String sDbDate = pADO->FieldByName("CNTL_DT")->AsString;
- m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
- String sCntlType = pADO->FieldByName("CNTL_TYPE")->AsString;
- String sRspsType = pADO->FieldByName("RSPS_TYPE")->AsString;
- if (sDevcType == "0") sDevcType = "제어부";
- else if (sDevcType == "1") sDevcType = "안테나 1";
- m_pGDC->Values[nRow][Column02->Index] = sDevcType;
- if (sCntlType == "1") sCntlType = "시스템 리셋요청";
- else if (sCntlType == "2") sCntlType = "PUSH 방송정보 삭제";
- else if (sCntlType == "3") sCntlType = "방송정보 삭제";
- else if (sCntlType == "4") sCntlType = "무선송출 중단";
- else if (sCntlType == "5") sCntlType = "무선송출 개시";
- m_pGDC->Values[nRow][Column03->Index] = sCntlType;
- if (sRspsType == "0") sRspsType = "수용";
- else if (sRspsType == "1") sRspsType = "거절";
- else if (sRspsType == "2") sRspsType = "응답없음";
- m_pGDC->Values[nRow][Column04->Index] = sRspsType;
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- TvList->EndUpdate();
- //CxList->SetFocus();
- LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
- String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
- Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TDSRH0301::OnMessage(TMessage &Msg)
- {
- switch (Msg.Msg)
- {
- case WM_PARAM_DATABASE:
- if (WP_DB_SELECT_OK == Msg.WParam)
- {
- //ShowMessage("Select Ok");
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TDSRH0301::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle = "DSRC-RSE 제어이력";
- CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TDSRH0301::FormClose(TObject *Sender, TCloseAction &Action)
- {
- POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
- CommClose();
- //DSRH0301 = NULL;
- }
- //---------------------------------------------------------------------------
|