1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #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 <jpeg.hpp>
- 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; //전체
- }
- }
- //---------------------------------------------------------------------------
|