12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109 |
- //---------------------------------------------------------------------------
- #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"
- #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 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)
- {
- }
- //--------------------------------------------------------------------------
- /*
- * form 초기화
- *
- * arguments
- *
- * return
- * 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(...) {}
- }
- //---------------------------------------------------------------------------
- /*
- * form을 보여줄때 호출되는 event 메서드이다.
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TIST00401::FormShow(TObject *Sender)
- {
- FormInit();
- Refresh();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- /*
- * 최초 1회 수행되는 타이머 이벤트
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- 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);
- }
- //---------------------------------------------------------------------------
- /*
- * Refresh Data Event Function
- * arguments
- *
- * return
- * void
- */
- 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 &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 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
- {
- sTypeNm = FrmLang->lblInc0->Caption;//"기타";
- pInci->FIncid[5][0] += nIncd;
- pInci->FIncid[5][1] += nFtlt;
- pInci->FIncid[5][2] += nInjr;
- pInci->FIncid[5][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)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
- }
- 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;
- 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->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];
- 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)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- 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_NODEID + "] ";
- pNode = ItsNodeManager->FLists.Find(pLink->F_NODEID);
- if (pNode) sFNode = sFNode + pNode->NODE_NAME;
- sTNode = "[" + pLink->T_NODEID + "] ";
- pNode = ItsNodeManager->FLists.Find(pLink->T_NODEID);
- 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)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
- }
- 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();
- }
- //---------------------------------------------------------------------------
- /*
- * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
- * Form과 DataModule class를 delete시킨다.
- * arguments
- *
- * return
- * void
- */
- 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; //전체
- }
- }
- //---------------------------------------------------------------------------
|