//--------------------------------------------------------------------------- #include #include "ITSSkinF.h" #include "ITSUtilF.h" #include "ITSDbF.h" #include "AppGlobalF.h" #include "WindowMsgF.h" #include "CDSNodeF.h" #include "CDSLinkF.h" #include "ITSLangTransF.h" #include "ITS_OPLibF.h" #pragma hdrstop #include "IST00401F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxButtons" #pragma link "cxCalc" #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 "cxGridChartView" #pragma link "cxGridCustomTableView" #pragma link "cxGridCustomView" #pragma link "cxGridLevel" #pragma link "cxGridTableView" #pragma link "cxLabel" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "cxPC" #pragma link "cxPCdxBarPopupMenu" #pragma link "cxSplitter" #pragma link "cxStyles" #pragma link "cxTextEdit" #pragma link "cxTrackBar" #pragma link "dxSkinBlack" #pragma link "dxSkinBlue" #pragma link "dxSkinsCore" #pragma link "dxSkinscxPCPainter" #pragma link "dxSkinMcSkin" #pragma resource "*.dfm" TIST00401 *IST00401 = NULL; //--------------------------------------------------------------------------- __fastcall TIST00401::TIST00401(TComponent* Owner, HWND hHandle, int AStatType, int ATermType, String AStTime, String AEdTime, bool AChkInciType, String AIncidentType, String ATitle) : TForm(Owner) { LangTrans->Translate(this, ITSDb_GetConnection()); ITSSkin_Load(this); CMM_LoadForm(g_sFormsDir, this); FParent = hHandle; FStatType = AStatType; FTermType = ATermType; FStTime = AStTime; FEdTime = AEdTime; FChkInciType = AChkInciType; FIncidentType = AIncidentType; FTitle = ATitle; FCodeIDTU = ItsCodeManager->FLists.Find("IDTU"); pMngrInci = new TItsStaIncidentManager(); } //--------------------------------------------------------------------------- __fastcall TIST00401::~TIST00401(void) { } //-------------------------------------------------------------------------- void __fastcall TIST00401::FormInit() { ADOQry->Connection = ITSDb_GetConnection(); m_pGDC = TvList->DataController; TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<µ¹¹ß Åë°è Á¤º¸>"; LblSearch->Caption = FTitle; if (FStatType == 0) { //À¯Çüº° cxTabSheet1->Caption = lblDesc1->Caption;//"±â°£º° µ¹¹ß¹ß»ý °Ç¼öº° "; cxTabSheet2->Caption = lblDesc2->Caption;//"±â°£º° µ¹¹ß¹ß»ý À¯Çüº° "; Column02->Visible = false; Column03->Visible = false; Column11->Visible = false; //Column04->Visible = true; Column05->Visible = false; SetChartLegend(TvChart1, FrmLang->lblStatTm->Caption, lblCnt->Caption);//"Åë°è½Ã°¢", "¹ß»ý°Ç¼ö(·®)"); SetChartLegend(TvChart2, FrmLang->lblStatTm->Caption, lblCnt->Caption);//"Åë°è½Ã°¢", "¹ß»ý°Ç¼ö(·®)"); ChartValueDisplay(TvChart1, ChkDisplayVal1->Checked); ChartValueDisplay(TvChart2, ChkDisplayVal2->Checked); TvChart1->ToolBox->CustomizeButton = true; TvChart2->ToolBox->CustomizeButton = true; TvChart1->Legend->Position = cppDefault; TvChart2->Legend->Position = cppDefault; } else { //±¸°£º° cxTabSheet2->TabVisible = false; cxTabSheet1->Caption = lblDesc1->Caption;//"±¸°£º° µ¹¹ß¹ß»ý °Ç¼öº° "; cxTabSheet2->Caption = lblDesc2->Caption;//"±¸°£º° µ¹¹ß¹ß»ý À¯Çüº° "; //Column02->Visible = true; //Column03->Visible = true; Column04->Visible = false; Column05->Visible = false; SetChartLegend(TvChart1, lblSect->Caption, lblCnt->Caption);//"±¸°£", "¹ß»ý°Ç¼ö(·®)"); SetChartLegend(TvChart2, lblSect->Caption, lblCnt->Caption);//"±¸°£", "¹ß»ý°Ç¼ö(·®)"); ChartValueDisplay(TvChart1, ChkDisplayVal1->Checked); ChartValueDisplay(TvChart2, ChkDisplayVal2->Checked); TvChart1->ToolBox->CustomizeButton = true; TvChart2->ToolBox->CustomizeButton = true; TvChart1->Legend->Position = cppDefault; TvChart2->Legend->Position = cppDefault; } } //--------------------------------------------------------------------------- void __fastcall TIST00401::SetChartLegend(TcxGridChartView *ATvChart, String ACategory, String AValue) { try { ATvChart->DiagramArea->AxisCategory->Title->Text = ACategory; ATvChart->DiagramArea->AxisValue->Title->Text = AValue; ATvChart->DiagramBar->AxisCategory->Title->Text = ACategory; ATvChart->DiagramBar->AxisValue->Title->Text = AValue; ATvChart->DiagramColumn->AxisCategory->Title->Text = ACategory; ATvChart->DiagramColumn->AxisValue->Title->Text = AValue; ATvChart->DiagramLine->AxisCategory->Title->Text = ACategory; ATvChart->DiagramLine->AxisValue->Title->Text = AValue; ATvChart->DiagramStackedArea->AxisCategory->Title->Text = ACategory; ATvChart->DiagramStackedArea->AxisValue->Title->Text = AValue; ATvChart->DiagramStackedBar->AxisCategory->Title->Text = ACategory; ATvChart->DiagramStackedBar->AxisValue->Title->Text = AValue; ATvChart->DiagramStackedColumn->AxisCategory->Title->Text = ACategory; ATvChart->DiagramStackedColumn->AxisValue->Title->Text = AValue; } catch(...) {} } //--------------------------------------------------------------------------- void __fastcall TIST00401::ChartValueDisplay(TcxGridChartView *ATvChart, bool FDisplayValue) { try { ATvChart->DiagramArea->Values->CaptionPosition = FDisplayValue ? ldvcpAbove : ldvcpNone; ATvChart->DiagramBar->Values->CaptionPosition = FDisplayValue ? cdvcpOutsideEnd : cdvcpNone; ATvChart->DiagramColumn->Values->CaptionPosition = FDisplayValue ? cdvcpOutsideEnd : cdvcpNone; ATvChart->DiagramLine->Values->CaptionPosition = FDisplayValue ? ldvcpAbove : ldvcpNone; ATvChart->DiagramPie->Values->CaptionPosition = FDisplayValue ? pdvcpOutsideEndWithLeaderLines : pdvcpNone; ATvChart->DiagramStackedArea->Values->CaptionPosition = FDisplayValue ? ldvcpRight : ldvcpNone; ATvChart->DiagramStackedBar->Values->CaptionPosition = FDisplayValue ? cdvcpCenter : cdvcpNone; ATvChart->DiagramStackedColumn->Values->CaptionPosition = FDisplayValue ? cdvcpCenter : cdvcpNone; } catch(...) {} } //--------------------------------------------------------------------------- void __fastcall TIST00401::FormShow(TObject *Sender) { FormInit(); Refresh(); TmrShow->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TIST00401::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; TvChart1->ClearSeries(); TvChart2->ClearSeries(); pMngrInci->FLists.RemoveAll(); Application->ProcessMessages(); if (FStatType == 0) { SelIncidentType(); } else { SelIncidentSect(); } } //--------------------------------------------------------------------------- void __fastcall TIST00401::ChkExpandClick(TObject *Sender) { CMM_ExpandCollapseChk(TvList, ChkExpand->Checked); } //--------------------------------------------------------------------------- void __fastcall TIST00401::SelIncidentType() { TSqlCursor sqlCrs; String sQry; TADOQuery *pADO = ADOQry; switch(FTermType) { case 0: sQry = "SELECT SUBSTR(STAT_DT, 1, 8) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 8), 'YYYYMMDD'), 'YYYY-MM-DD') AS STAT_DTNM, \r\n" " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_TYPE_DD_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n" // " FROM TB_CMMN_CD a \r\n" // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 8), INCD_TYPE_CD) \r\n" " ORDER BY STAT_DT \r\n"; break; case 1: sQry = "SELECT SUBSTR(STAT_DT, 1, 6) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 6), 'YYYYMM'), 'YYYY-MM') AS STAT_DTNM, \r\n" " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_TYPE_MN_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n" // " FROM TB_CMMN_CD a \r\n" // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 6), INCD_TYPE_CD) \r\n" " ORDER BY STAT_DT \r\n"; break; case 2: sQry = "SELECT SUBSTR(STAT_DT, 1, 4) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " SUBSTR(STAT_DT, 1, 4) AS STAT_DTNM, \r\n" " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_TYPE_MN_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n" // " FROM TB_CMMN_CD a \r\n" // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 4), INCD_TYPE_CD) \r\n" " ORDER BY STAT_DT \r\n"; break; default: return; } sQry = "SELECT NVL(STAT_DT, 'X') AS STAT_DT, \r\n" " NVL(DATA_CNT, 0) AS DATA_CNT, \r\n" " NVL(STAT_DTNM, 'X') AS STAT_DTNM, \r\n" " NVL(INCD_TYPE_CD, '-') AS INCD_TYPE_CD, \r\n" " NVL(INCD_OCRR_NUM, 0) AS INCD_OCRR_NUM, \r\n" " NVL(FTLT_PNUM, 0) AS FTLT_PNUM, \r\n" " NVL(INJR_PNUM, 0) AS INJR_PNUM, \r\n" " NVL(PRPR_DMGE_AMT, 0) AS PRPR_DMGE_AMT \r\n" " FROM (" + sQry + ")"; try { ITSDb_SQLClose(pADO); ITSDb_SQLText(pADO, sQry); ITSDb_SQLBind(pADO, "p01", FStTime); ITSDb_SQLBind(pADO, "p02", FEdTime); ITSDb_SQLOpen(pADO); DspIncidentTypeList(); } 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 &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); } } //--------------------------------------------------------------------------- void __fastcall TIST00401::DspIncidentTypeList() { TADOQuery *pADO = ADOQry; try { CMM_ClearGridTableView(TvList); int nRow = 0; int nDataCnt = 0; try { TvList->BeginUpdate(); nDataCnt = pADO->RecordCount; m_pGDC->RecordCount = nDataCnt; String sRowType = ""; String sTypeNm = ""; int nIncd, nFtlt, nInjr, nPrpr; for( ; !pADO->Eof; pADO->Next(), nRow++) { String sDate = pADO->FieldByName("STAT_DTNM")->AsString; String sType = pADO->FieldByName("INCD_TYPE_CD")->AsString; nIncd = pADO->FieldByName("INCD_OCRR_NUM")->AsInteger; //¹ß»ý°Ç¼ö nFtlt = pADO->FieldByName("FTLT_PNUM")->AsInteger; //»ç¸ÁÀÚ¼ö nInjr = pADO->FieldByName("INJR_PNUM")->AsInteger; //ºÎ»óÀÚ¼ö nPrpr = pADO->FieldByName("PRPR_DMGE_AMT")->AsInteger; //ÇÇÇØ±Ý¾× sRowType = "0"; if (sDate == "X") { sRowType = "2"; sDate = FrmLang->lblChartTotal->Caption;//"Àüü"; sType = "-"; sTypeNm = "-"; } else { TItsStaIncident *pInci = pMngrInci->FLists.Find(sDate); if (!pInci) { pInci = new TItsStaIncident(); pMngrInci->FLists.Push(sDate, pInci); pInci->FDate = sDate; } if (sType == "-") { sRowType = "1"; sType = "+"; sTypeNm = FrmLang->lblChartSoge->Caption;//"¼Ò°è"; pInci->FIncid[0][0] = nIncd; pInci->FIncid[0][1] = nFtlt; pInci->FIncid[0][2] = nInjr; pInci->FIncid[0][3] = nPrpr; } else { if (sType == "1") { sTypeNm = FrmLang->lblInc1->Caption;//"»ç°í"; pInci->FIncid[1][0] += nIncd; pInci->FIncid[1][1] += nFtlt; pInci->FIncid[1][2] += nInjr; pInci->FIncid[1][3] += nPrpr; } else if (sType == "2") { sTypeNm = FrmLang->lblInc2->Caption;//"°ø»ç"; pInci->FIncid[2][0] += nIncd; pInci->FIncid[2][1] += nFtlt; pInci->FIncid[2][2] += nInjr; pInci->FIncid[2][3] += nPrpr; } else if (sType == "3") { sTypeNm = FrmLang->lblInc3->Caption;//"Çà»ç"; pInci->FIncid[3][0] += nIncd; pInci->FIncid[3][1] += nFtlt; pInci->FIncid[3][2] += nInjr; pInci->FIncid[3][3] += nPrpr; } else if (sType == "4") { sTypeNm = FrmLang->lblInc4->Caption;//"±â»ó"; pInci->FIncid[4][0] += nIncd; pInci->FIncid[4][1] += nFtlt; pInci->FIncid[4][2] += nInjr; pInci->FIncid[4][3] += nPrpr; } else if (sType == "5") { sTypeNm = FrmLang->lblInc5->Caption;//"ÅëÁ¦"; pInci->FIncid[5][0] += nIncd; pInci->FIncid[5][1] += nFtlt; pInci->FIncid[5][2] += nInjr; pInci->FIncid[5][3] += nPrpr; } else if (sType == "6") { sTypeNm = FrmLang->lblInc6->Caption;//"Àç³­"; pInci->FIncid[6][0] += nIncd; pInci->FIncid[6][1] += nFtlt; pInci->FIncid[6][2] += nInjr; pInci->FIncid[6][3] += nPrpr; } else { sTypeNm = FrmLang->lblInc0->Caption;//"±âŸ"; pInci->FIncid[7][0] += nIncd; pInci->FIncid[7][1] += nFtlt; pInci->FIncid[7][2] += nInjr; pInci->FIncid[7][3] += nPrpr; } sTypeNm = "[" + sType + "] " + sTypeNm; } } m_pGDC->Values[nRow][Column01->Index] = sDate; m_pGDC->Values[nRow][Column02->Index] = ""; m_pGDC->Values[nRow][Column03->Index] = ""; m_pGDC->Values[nRow][Column04->Index] = sTypeNm; m_pGDC->Values[nRow][Column05->Index] = sType; m_pGDC->Values[nRow][Column06->Index] = nIncd; m_pGDC->Values[nRow][Column07->Index] = nFtlt; m_pGDC->Values[nRow][Column08->Index] = nInjr; m_pGDC->Values[nRow][Column09->Index] = nPrpr; m_pGDC->Values[nRow][Column10->Index] = sRowType; } } __finally { if (pADO) { pADO->Close(); } TvList->EndUpdate(); //CxList->SetFocus(); LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" °Ç"; } } catch(EDatabaseError &E) { ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2); DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2); DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text); throw Exception(String(e.ClassName()) + e.Message); } DspIncidentTypeChart(); 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); } //--------------------------------------------------------------------------- void __fastcall TIST00401::DspIncidentTypeChart() { try { TcxGridChartSeries *pChart11 = NULL; TcxGridChartSeries *pChart12 = NULL; TcxGridChartSeries *pChart13 = NULL; TcxGridChartSeries *pChart14 = NULL; TcxGridChartSeries *pChart21 = NULL; TcxGridChartSeries *pChart22 = NULL; TcxGridChartSeries *pChart23 = NULL; TcxGridChartSeries *pChart24 = NULL; TcxGridChartSeries *pChart25 = NULL; TcxGridChartSeries *pChart26 = NULL; TcxGridChartSeries *pChart27 = NULL; TvChart1->ClearSeries(); TvChart2->ClearSeries(); int nRow = 0; int nDataCnt = 0; try { TvChart1->BeginUpdate(); TvChart2->BeginUpdate(); nDataCnt = pMngrInci->FLists.Size(); TvChart1->DataController->RecordCount = nDataCnt; TvChart2->DataController->RecordCount = nDataCnt; pChart11 = TvChart1->CreateSeries(); pChart11->DataBinding->ValueType = "Integer"; pChart11->DisplayText = Column06->Caption;//"µ¹¹ß¹ß»ý°Ç¼ö"; pChart12 = TvChart1->CreateSeries(); pChart12->DataBinding->ValueType = "Integer"; pChart12->DisplayText = Column07->Caption;//"»ç¸ÁÀÚ¼ö"; pChart13 = TvChart1->CreateSeries(); pChart13->DataBinding->ValueType = "Integer"; pChart13->DisplayText = Column08->Caption;//"ºÎ»óÀÚ¼ö"; #if 0 pChart14 = TvChart1->CreateSeries(); pChart14->DataBinding->ValueType = "Integer"; pChart14->DisplayText = Column09->Caption;//"Àç»êÇÇÇØ±Ý¾×"; #endif pChart21 = TvChart2->CreateSeries(); pChart21->DataBinding->ValueType = "Integer"; pChart21->DisplayText = FrmLang->lblInc1->Caption;//"»ç°í"; pChart22 = TvChart2->CreateSeries(); pChart22->DataBinding->ValueType = "Integer"; pChart22->DisplayText = FrmLang->lblInc2->Caption;//"°ø»ç"; pChart23 = TvChart2->CreateSeries(); pChart23->DataBinding->ValueType = "Integer"; pChart23->DisplayText = FrmLang->lblInc3->Caption;//"Çà»ç"; pChart24 = TvChart2->CreateSeries(); pChart24->DataBinding->ValueType = "Integer"; pChart24->DisplayText = FrmLang->lblInc4->Caption;//"±â»ó"; pChart25 = TvChart2->CreateSeries(); pChart25->DataBinding->ValueType = "Integer"; pChart25->DisplayText = FrmLang->lblInc5->Caption;//"ÅëÁ¦"; pChart26 = TvChart2->CreateSeries(); pChart26->DataBinding->ValueType = "Integer"; pChart26->DisplayText = FrmLang->lblInc6->Caption;//"Àç³­"; pChart27 = TvChart2->CreateSeries(); pChart27->DataBinding->ValueType = "Integer"; pChart27->DisplayText = FrmLang->lblInc0->Caption;//"±âŸ"; FOR_STL(TItsStaIncident*, pInci, pMngrInci->FLists) { pChart11->Values[nRow] = pInci->FIncid[0][0]; pChart12->Values[nRow] = pInci->FIncid[0][1]; pChart13->Values[nRow] = pInci->FIncid[0][2]; //pChart14->Values[nRow] = pInci->FIncid[0][3]; TvChart1->Categories->Values[nRow] = pInci->FDate; pChart21->Values[nRow] = pInci->FIncid[1][0]; pChart22->Values[nRow] = pInci->FIncid[2][0]; pChart23->Values[nRow] = pInci->FIncid[3][0]; pChart24->Values[nRow] = pInci->FIncid[4][0]; pChart25->Values[nRow] = pInci->FIncid[5][0]; pChart26->Values[nRow] = pInci->FIncid[6][0]; pChart27->Values[nRow] = pInci->FIncid[7][0]; TvChart2->Categories->Values[nRow] = pInci->FDate; nRow++; } } __finally { TvChart1->EndUpdate(); TvChart2->EndUpdate(); pMngrInci->FLists.RemoveAll(); } } catch(...) { throw Exception(FrmLang->lblDbErr->Caption);//"[DspIncidentTypeChart]¾Ë¼ö¾ø´Â ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù."); } } //--------------------------------------------------------------------------- void __fastcall TIST00401::SelIncidentSect() { TSqlCursor sqlCrs; String sQry; TADOQuery *pADO = ADOQry; switch(FTermType) { case 0: sQry = "SELECT SUBSTR(STAT_DT, 1, 8) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 8), 'YYYYMMDD'), 'YYYY-MM-DD') AS STAT_DTNM, \r\n" " LINK_ID AS LINK_ID, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_SECT_DD_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 8), LINK_ID) \r\n" " ORDER BY STAT_DT \r\n"; break; case 1: sQry = "SELECT SUBSTR(STAT_DT, 1, 6) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 6), 'YYYYMM'), 'YYYY-MM') AS STAT_DTNM, \r\n" " LINK_ID AS LINK_ID, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_SECT_MN_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 6), LINK_ID) \r\n" " ORDER BY STAT_DT \r\n"; break; case 2: sQry = "SELECT SUBSTR(STAT_DT, 1, 4) AS STAT_DT, COUNT(1) DATA_CNT, \r\n" " SUBSTR(STAT_DT, 1, 4) AS STAT_DTNM, \r\n" " LINK_ID AS LINK_ID, \r\n" " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n" " SUM(FTLT_PNUM) FTLT_PNUM, \r\n" " SUM(INJR_PNUM) INJR_PNUM, \r\n" " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n" " FROM TB_INCD_SECT_MN_STAT \r\n" " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n" " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 4), LINK_ID) \r\n" " ORDER BY STAT_DT \r\n"; break; default: return; } sQry = "SELECT NVL(STAT_DT, 'X') AS STAT_DT, \r\n" " NVL(DATA_CNT, 0) AS DATA_CNT, \r\n" " NVL(STAT_DTNM, 'X') AS STAT_DTNM, \r\n" " NVL(LINK_ID, 0) AS LINK_ID, \r\n" " NVL(INCD_OCRR_NUM, 0) AS INCD_OCRR_NUM, \r\n" " NVL(FTLT_PNUM, 0) AS FTLT_PNUM, \r\n" " NVL(INJR_PNUM, 0) AS INJR_PNUM, \r\n" " NVL(PRPR_DMGE_AMT, 0) AS PRPR_DMGE_AMT \r\n" " FROM (" + sQry + ")"; try { ITSDb_SQLText(pADO, sQry); ITSDb_SQLBind(pADO, "p01", FStTime); ITSDb_SQLBind(pADO, "p02", FEdTime); ITSDb_SQLOpen(pADO); DspIncidentSectList(); } 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 &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); } } //--------------------------------------------------------------------------- void __fastcall TIST00401::DspIncidentSectList() { TADOQuery *pADO = ADOQry; try { CMM_ClearGridTableView(TvList); int nRow = 0; int nDataCnt = 0; try { TvList->BeginUpdate(); nDataCnt = pADO->RecordCount; m_pGDC->RecordCount = nDataCnt; String sRowType = ""; int nIncd, nFtlt, nInjr, nPrpr; TItsNode *pNode; TItsLink *pLink; String sFNode, sTNode; for( ; !pADO->Eof; pADO->Next(), nRow++) { sFNode = sTNode = ""; String sDate = pADO->FieldByName("STAT_DTNM")->AsString; //Åë°è½Ã°¢ String sLink = pADO->FieldByName("LINK_ID")->AsString; //±¸°£ID nIncd = pADO->FieldByName("INCD_OCRR_NUM")->AsInteger; //¹ß»ý°Ç¼ö nFtlt = pADO->FieldByName("FTLT_PNUM")->AsInteger; //»ç¸ÁÀÚ¼ö nInjr = pADO->FieldByName("INJR_PNUM")->AsInteger; //ºÎ»óÀÚ¼ö nPrpr = pADO->FieldByName("PRPR_DMGE_AMT")->AsInteger; //ÇÇÇØ±Ý¾× sRowType = "0"; if (sDate == "X") { sRowType = "2"; sDate = FrmLang->lblChartTotal->Caption;//"Àüü"; sLink = "-"; sFNode = sTNode = "-"; } else { if (sLink == "0") { sRowType = "1"; sLink = FrmLang->lblChartSoge->Caption;//"¼Ò°è"; sFNode = sTNode = "-"; } else { sFNode = sTNode = ""; pLink = ItsLinkManager->FLists.Find(sLink); if (pLink) { sFNode = "[" + pLink->F_NODE_ID + "] "; pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID); if (pNode) sFNode = sFNode + pNode->NODE_NAME; sTNode = "[" + pLink->T_NODE_ID + "] "; pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID); if (pNode) sTNode = sTNode + pNode->NODE_NAME; } TItsStaIncident *pInci = pMngrInci->FLists.Find(sLink); if (!pInci) { pInci = new TItsStaIncident(); pMngrInci->FLists.Push(sLink, pInci); pInci->FDate = sLink; } pInci->FIncid[0][0] += nIncd; pInci->FIncid[0][1] += nFtlt; pInci->FIncid[0][2] += nInjr; pInci->FIncid[0][3] += nPrpr; } } m_pGDC->Values[nRow][Column01->Index] = sDate; m_pGDC->Values[nRow][Column02->Index] = sLink; m_pGDC->Values[nRow][Column03->Index] = sFNode; m_pGDC->Values[nRow][Column11->Index] = sTNode; m_pGDC->Values[nRow][Column06->Index] = nIncd; m_pGDC->Values[nRow][Column07->Index] = nFtlt; m_pGDC->Values[nRow][Column08->Index] = nInjr; m_pGDC->Values[nRow][Column09->Index] = nPrpr; m_pGDC->Values[nRow][Column10->Index] = sRowType; } } __finally { if (pADO) { pADO->Close(); } TvList->EndUpdate(); //CxList->SetFocus(); LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" °Ç"; } } catch(EDatabaseError &E) { ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2); DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2); DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text); throw Exception(String(e.ClassName()) + e.Message); } DspIncidentSectChart(); 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); } //--------------------------------------------------------------------------- void __fastcall TIST00401::DspIncidentSectChart() { try { TcxGridChartSeries *pChart11 = NULL; TcxGridChartSeries *pChart12 = NULL; TcxGridChartSeries *pChart13 = NULL; TcxGridChartSeries *pChart14 = NULL; TvChart1->ClearSeries(); int nRow = 0; int nDataCnt = 0; try { TvChart1->BeginUpdate(); nDataCnt = pMngrInci->FLists.Size(); TvChart1->DataController->RecordCount = nDataCnt; pChart11 = TvChart1->CreateSeries(); pChart11->DataBinding->ValueType = "Integer"; pChart11->DisplayText = Column06->Caption;//"µ¹¹ß¹ß»ý°Ç¼ö"; pChart12 = TvChart1->CreateSeries(); pChart12->DataBinding->ValueType = "Integer"; pChart12->DisplayText = Column07->Caption;//"»ç¸ÁÀÚ¼ö"; pChart13 = TvChart1->CreateSeries(); pChart13->DataBinding->ValueType = "Integer"; pChart13->DisplayText = Column08->Caption;//"ºÎ»óÀÚ¼ö"; #if 0 pChart14 = TvChart1->CreateSeries(); pChart14->DataBinding->ValueType = "Integer"; pChart14->DisplayText = Column09->Caption;//"Àç»êÇÇÇØ±Ý¾×"; #endif FOR_STL(TItsStaIncident*, pInci, pMngrInci->FLists) { pChart11->Values[nRow] = pInci->FIncid[0][0]; pChart12->Values[nRow] = pInci->FIncid[0][1]; pChart13->Values[nRow] = pInci->FIncid[0][2]; //pChart14->Values[nRow] = pInci->FIncid[0][3]; TvChart1->Categories->Values[nRow] = pInci->FDate; nRow++; } } __finally { TvChart1->EndUpdate(); pMngrInci->FLists.RemoveAll(); } } catch(...) { throw Exception(FrmLang->lblDbErr->Caption);//"[DspIncidentTypeChart]¾Ë¼ö¾ø´Â ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù."); } } //--------------------------------------------------------------------------- void __fastcall TIST00401::OnMessage(TMessage &Msg) { switch (Msg.Msg) { case WM_PARAM_DATABASE: if (WP_DB_SELECT_OK == Msg.WParam) { //ShowMessage("Select Ok"); } break; } } //--------------------------------------------------------------------------- void __fastcall TIST00401::BtnExlSaveClick(TObject *Sender) { TcxGrid *pGrid = CxList; TcxGridTableView *pView = TvList; String sTitle= Caption;//"µ¹¹ß»óȲÅë°è"; CMM_ExportToExcelFile(sTitle, pGrid, pView, this); } //--------------------------------------------------------------------------- void __fastcall TIST00401::FormClose(TObject *Sender, TCloseAction &Action) { POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0); CommClose(); //IST00401 = NULL; } //--------------------------------------------------------------------------- void __fastcall TIST00401::FormDestroy(TObject *Sender) { if (pMngrInci) { delete pMngrInci; pMngrInci = NULL; } CommClose(); } //--------------------------------------------------------------------------- void __fastcall TIST00401::CommClose() { if (pMngrInci) { delete pMngrInci; pMngrInci = NULL; } CMM_SaveForm(g_sFormsDir, this); //IST00401 = NULL; } //--------------------------------------------------------------------------- void __fastcall TIST00401::cxTrackBarMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { try { TcxTrackBar *pTrack = (TcxTrackBar*)Sender; TcxLabel *pLabel = LblPage1; TcxGridChartView *pChart = TvChart1; if (pTrack->Tag == 2) { pLabel = LblPage2; pChart = TvChart2; } if (pTrack->Position == pTrack->Properties->Max) { pChart->OptionsView->CategoriesPerPage = 0; pLabel->Caption = lblAll->Caption;//"All "; } else { pChart->OptionsView->CategoriesPerPage = pTrack->Position; pLabel->Caption = String(pTrack->Position) + " "; } } catch(...) {} } //--------------------------------------------------------------------------- void __fastcall TIST00401::cxTrackBarPropertiesChange(TObject *Sender) { try { TcxTrackBar *pTrack = (TcxTrackBar*)Sender; TcxLabel *pLabel = LblPage1; if (pTrack->Tag == 2) { pLabel = LblPage2; } if (pTrack->Position == pTrack->Properties->Max) { pLabel->Caption = lblAll->Caption;//"Àüü "; } else { pLabel->Caption = String(pTrack->Position) + " "; } } catch(...) {} } //--------------------------------------------------------------------------- void __fastcall TIST00401::BtnGraphSaveClick(TObject *Sender) { String sTitle; TcxButton *pBtn = (TcxButton*)Sender; TcxGridChartView *pChart = TvChart1; if (pBtn->Tag == 2) { pChart = TvChart2; } TSaveDialog *SaveDialog1 = NULL; String sNewFile, sDate; sTitle = cxPageControl1->Properties->ActivePage->Caption; sDate = Now().FormatString("YYYYMMDDhhnn"); sNewFile = FTitle + "_" + sDate; int nFilterIndex = 0; try { SaveDialog1 = new TSaveDialog(Application); SaveDialog1->Title = sTitle + lblImgSave->Caption;//" Â÷Æ® À̹ÌÁö ÀúÀå"; //SaveDialog1->InitialDir = ExtractFilePath(Application->ExeName); SaveDialog1->Filter = "BMP (*.bmp)|*.bmp|" "JPG (*.jpg)|*.jpg|" //"PNG (*.png)|*.png|" "WMF (*.wmf)|*.wmf|" "EMF (*.emf)|*.emf"; SaveDialog1->FileName = sNewFile; if (SaveDialog1->Execute() == false) { return ; } sNewFile = SaveDialog1->FileName; if (sNewFile == "") { return ; } nFilterIndex = SaveDialog1->FilterIndex; } __finally { if (SaveDialog1) delete SaveDialog1; ChDir(ExtractFilePath(Application->ExeName)); } TWaitCursor waitCsr; #include TGraphic *pGraphic = NULL; TGraphic *pTmpImage = NULL; try { Application->ProcessMessages(); try { bool bMetafile = false; switch (nFilterIndex) { case 1: sNewFile = ChangeFileExt(sNewFile, ".bmp"); bMetafile = false; break; case 2: sNewFile = ChangeFileExt(sNewFile, ".jpg"); bMetafile = false; break; //case 3: sNewFile = ChangeFileExt(sNewFile, ".png"); bMetafile = false; break; case 3: sNewFile = ChangeFileExt(sNewFile, ".wmf"); bMetafile = true; break; case 4: sNewFile = ChangeFileExt(sNewFile, ".emf"); bMetafile = true; break; default: sNewFile = ChangeFileExt(sNewFile, ".bmp"); bMetafile = false; break; } // (TdxPNGImage) if (nFilterIndex == 3 || nFilterIndex == 4) { pGraphic = pChart->CreateImage(__classid(Graphics::TMetafile)); ((Graphics::TMetafile*)pGraphic)->Enhanced = nFilterIndex == 4 ? true : false; } else { pGraphic = pChart->CreateImage(__classid(Graphics::TBitmap)); } //TPNGImage *pPng = new TPNGImage(); switch (nFilterIndex) { case 2: pTmpImage = new TJPEGImage(); break; //case 3: pTmpImage = new TdxPNGImage(); break; } if (pTmpImage) { pTmpImage->Assign(pGraphic); pTmpImage->SaveToFile(sNewFile); } else { pGraphic->SaveToFile(sNewFile); } } catch(Exception & E) { String strMsg = lblSaveErr->Caption + "\r\n";//"ÆÄÀÏ·Î ÀúÀåÇÏ´Â Áß¿¡ ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.\r\n"; strMsg += "[" + E.Message + "]\r\n"; ShowMessage(strMsg); return ; } } __finally { if (pGraphic) { delete pGraphic; } if (pTmpImage) { delete pTmpImage; } } String sMsg = ""; //sMsg = "[Â÷Æ® À̹ÌÁö¸¦\r\n" + sNewFile + "\r\n ·Î »ý¼º ÇÏ¿´½À´Ï´Ù."; sMsg = lblSaveOk->Caption + "\r\n[" + sNewFile + "]"; MessageDlg(sMsg, mtInformation, TMsgDlgButtons() << mbOK, 0); } //--------------------------------------------------------------------------- void __fastcall TIST00401::ChkDisplayValPropertiesChange(TObject *Sender) { TcxCheckBox *pChkBox = (TcxCheckBox*)Sender; if (pChkBox->Tag == 1) ChartValueDisplay(TvChart1, pChkBox->Checked); else ChartValueDisplay(TvChart2, pChkBox->Checked); } //--------------------------------------------------------------------------- void __fastcall TIST00401::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone) { if (AViewInfo) { String sType = AViewInfo->GridRecord->DisplayTexts[Column10->Index]; if (sType == "1") ACanvas->Brush->Color = clOlive; //¼Ò°è else if (sType == "2") ACanvas->Brush->Color = clLime; //Àüü } } //---------------------------------------------------------------------------