123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #include "WindowMsgF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "IHS0010MF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCalendar"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxDropDownEdit"
- #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 "cxMaskEdit"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "cxSpinEdit"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "cxTimeEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- TIHS0010M *IHS0010M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TIHS0010M::TIHS0010M(TComponent* Owner)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- FTitle = Caption;//"운영자 접속 이력조회";
- }
- //---------------------------------------------------------------------------
- /*
- * form을 보여줄때 호출되는 event 메서드이다.
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TIHS0010M::FormShow(TObject *Sender)
- {
- PgList->ActivePageIndex = 0;
- // form 초기화
- FormInit();
- }
- //---------------------------------------------------------------------------
- /*
- * form 초기화
- * arguments
- *
- * return
- * void
- */
- void __fastcall TIHS0010M::FormInit()
- {
- ADOQry->Connection = ITSDb_GetConnection();
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<운영자 접속 이력 정보>";
- DtStDate->Date = Now() - 30;
- DtEdDate->Date = Now() - 1;
- //DtEdTime->EditValue = Now().FormatString("hh");
- DtStTime->Time = StrToDateTime("00:00");
- DtEdTime->Time = StrToDateTime("23:59");
- if (BtnSearch->Enabled)
- BtnSearch->SetFocus();
- }
- //---------------------------------------------------------------------------
- /*
- * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
- * Form과 DataModule class를 delete시킨다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TIHS0010M::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- /*
- * 화면이 로딩된 후 리스트 목록을 조회하도록 한다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TIHS0010M::TmrRefreshTimer(TObject *Sender)
- {
- TmrRefresh->Enabled = false;
- }
- //---------------------------------------------------------------------------
- /*
- * Excel Button Click Event Handler
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TIHS0010M::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= Caption;//"운영자 접속이력";
- CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
- }
- //---------------------------------------------------------------------------
- /*
- * Refresh Button Click Event Handler
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TIHS0010M::BtnSearchClick(TObject *Sender)
- {
- Application->ProcessMessages();
- TSqlCursor sqlCrs((TControl*)BtnSearch);
- RefreshData();
- }
- //---------------------------------------------------------------------------
- /*
- * Refresh Data Event Function
- * arguments
- *
- * return
- * void
- */
- void __fastcall TIHS0010M::RefreshData()
- {
- #if 0
- FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
- FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
- #else
- FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
- FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
- #endif
- if (wcscmp(FStDateTime.c_str(), FEdDateTime.c_str()) >= 0)
- {
- Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"시작 시각이 종료 시각 보다 작거나 같습니다.",
- FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- ActiveControl = DtStDate;
- return;
- }
- #if 0
- FStDateTime = FStDateTime + "0000";
- FEdDateTime = FEdDateTime + "5959";
- #else
- FStDateTime = FStDateTime + "00";
- FEdDateTime = FEdDateTime + "59";
- #endif
- SelHistory();
- }
- //---------------------------------------------------------------------------
- /*
- * 이력 데이터 조회/출력
- * arguments
- *
- * return
- * void
- */
- void __fastcall TIHS0010M::SelHistory()
- {
- String sQry;
- TADOQuery *pADO = ADOQry;
- sQry = "SELECT USER_ID, LOGIN_HMS, LOGOUT_HMS \r\n"
- " FROM TB_USERCNNC_HS \r\n"
- " WHERE LOGIN_HMS BETWEEN :p01 \r\n"
- " AND :p02 \r\n"
- " ORDER BY USER_ID, LOGIN_HMS \r\n";
- try
- {
- //pADO->Connection = ITSDb_GetConnection();
- 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 TIHS0010M::DspHistory()
- {
- TADOQuery *pADO = ADOQry;
- try
- {
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- try {
- TvList->BeginUpdate();
- m_pGDC->RecordCount = pADO->RecordCount;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- String sUsId = pADO->FieldByName("USER_ID")->AsString;
- String sInDt = pADO->FieldByName("LOGIN_HMS")->AsString;
- String sOuDt = pADO->FieldByName("LOGOUT_HMS")->AsString;
- m_pGDC->Values[nRow][Column01->Index] = sUsId;
- if (sInDt.IsEmpty())
- m_pGDC->Values[nRow][Column02->Index] = "-";
- else
- m_pGDC->Values[nRow][Column02->Index] = sInDt.SubString( 1, 4) + "-" +
- sInDt.SubString( 5, 2) + "-" +
- sInDt.SubString( 7, 2) + " " +
- sInDt.SubString( 9, 2) + ":" +
- sInDt.SubString(11, 2) + ":" +
- sInDt.SubString(13, 2);
- if (sOuDt.IsEmpty())
- m_pGDC->Values[nRow][Column03->Index] = "-";
- else
- m_pGDC->Values[nRow][Column03->Index] = sOuDt.SubString( 1, 4) + "-" +
- sOuDt.SubString( 5, 2) + "-" +
- sOuDt.SubString( 7, 2) + " " +
- sOuDt.SubString( 9, 2) + ":" +
- sOuDt.SubString(11, 2) + ":" +
- sOuDt.SubString(13, 2);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- TvList->EndUpdate();
- CxList->SetFocus();
- LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
- String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
- Application->MessageBox(sEnd.c_str(),
- FrmLang->lblQryEnd->Caption.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);//"알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- /*
- * Close 버튼 클릭 이벤트 핸들러
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TIHS0010M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TIHS0010M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- IHS0010M = NULL;
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIHS0010M::OnMessage(TMessage &Msg)
- {
- switch (Msg.Msg)
- {
- case WM_PARAM_DATABASE:
- if (WP_DB_SELECT_OK == Msg.WParam)
- {
- //ShowMessage("Select Ok");
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIHS0010M::TvListDataControllerFilterChanged(TObject *Sender)
- {
- CMM_SetFilterLike(TvList);
- }
- //---------------------------------------------------------------------------
|