IST00401F.cpp 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "CDSNodeF.h"
  9. #include "CDSLinkF.h"
  10. #include "ITSLangTransF.h"
  11. #include "ITS_OPLibF.h"
  12. #pragma hdrstop
  13. #include "IST00401F.h"
  14. //---------------------------------------------------------------------------
  15. #pragma package(smart_init)
  16. #pragma link "cxButtons"
  17. #pragma link "cxCalc"
  18. #pragma link "cxCheckBox"
  19. #pragma link "cxClasses"
  20. #pragma link "cxContainer"
  21. #pragma link "cxControls"
  22. #pragma link "cxCustomData"
  23. #pragma link "cxData"
  24. #pragma link "cxDataStorage"
  25. #pragma link "cxEdit"
  26. #pragma link "cxFilter"
  27. #pragma link "cxGraphics"
  28. #pragma link "cxGrid"
  29. #pragma link "cxGridChartView"
  30. #pragma link "cxGridCustomTableView"
  31. #pragma link "cxGridCustomView"
  32. #pragma link "cxGridLevel"
  33. #pragma link "cxGridTableView"
  34. #pragma link "cxLabel"
  35. #pragma link "cxLookAndFeelPainters"
  36. #pragma link "cxLookAndFeels"
  37. #pragma link "cxPC"
  38. #pragma link "cxPCdxBarPopupMenu"
  39. #pragma link "cxSplitter"
  40. #pragma link "cxStyles"
  41. #pragma link "cxTextEdit"
  42. #pragma link "cxTrackBar"
  43. #pragma link "dxSkinBlack"
  44. #pragma link "dxSkinBlue"
  45. #pragma link "dxSkinsCore"
  46. #pragma link "dxSkinscxPCPainter"
  47. #pragma link "dxSkinMcSkin"
  48. #pragma resource "*.dfm"
  49. TIST00401 *IST00401 = NULL;
  50. //---------------------------------------------------------------------------
  51. __fastcall TIST00401::TIST00401(TComponent* Owner, HWND hHandle,
  52. int AStatType, int ATermType, String AStTime, String AEdTime, bool AChkInciType, String AIncidentType, String ATitle)
  53. : TForm(Owner)
  54. {
  55. LangTrans->Translate(this, ITSDb_GetConnection());
  56. ITSSkin_Load(this);
  57. CMM_LoadForm(g_sFormsDir, this);
  58. FParent = hHandle;
  59. FStatType = AStatType;
  60. FTermType = ATermType;
  61. FStTime = AStTime;
  62. FEdTime = AEdTime;
  63. FChkInciType = AChkInciType;
  64. FIncidentType = AIncidentType;
  65. FTitle = ATitle;
  66. FCodeIDTU = ItsCodeManager->FLists.Find("IDTU");
  67. pMngrInci = new TItsStaIncidentManager();
  68. }
  69. //---------------------------------------------------------------------------
  70. __fastcall TIST00401::~TIST00401(void)
  71. {
  72. }
  73. //--------------------------------------------------------------------------
  74. void __fastcall TIST00401::FormInit()
  75. {
  76. ADOQry->Connection = ITSDb_GetConnection();
  77. m_pGDC = TvList->DataController;
  78. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<돌발 통계 정보>";
  79. LblSearch->Caption = FTitle;
  80. if (FStatType == 0)
  81. {
  82. //유형별
  83. cxTabSheet1->Caption = lblDesc1->Caption;//"기간별 돌발발생 건수별 ";
  84. cxTabSheet2->Caption = lblDesc2->Caption;//"기간별 돌발발생 유형별 ";
  85. Column02->Visible = false;
  86. Column03->Visible = false;
  87. Column11->Visible = false;
  88. //Column04->Visible = true;
  89. Column05->Visible = false;
  90. SetChartLegend(TvChart1, FrmLang->lblStatTm->Caption, lblCnt->Caption);//"통계시각", "발생건수(량)");
  91. SetChartLegend(TvChart2, FrmLang->lblStatTm->Caption, lblCnt->Caption);//"통계시각", "발생건수(량)");
  92. ChartValueDisplay(TvChart1, ChkDisplayVal1->Checked);
  93. ChartValueDisplay(TvChart2, ChkDisplayVal2->Checked);
  94. TvChart1->ToolBox->CustomizeButton = true;
  95. TvChart2->ToolBox->CustomizeButton = true;
  96. TvChart1->Legend->Position = cppDefault;
  97. TvChart2->Legend->Position = cppDefault;
  98. }
  99. else
  100. {
  101. //구간별
  102. cxTabSheet2->TabVisible = false;
  103. cxTabSheet1->Caption = lblDesc1->Caption;//"구간별 돌발발생 건수별 ";
  104. cxTabSheet2->Caption = lblDesc2->Caption;//"구간별 돌발발생 유형별 ";
  105. //Column02->Visible = true;
  106. //Column03->Visible = true;
  107. Column04->Visible = false;
  108. Column05->Visible = false;
  109. SetChartLegend(TvChart1, lblSect->Caption, lblCnt->Caption);//"구간", "발생건수(량)");
  110. SetChartLegend(TvChart2, lblSect->Caption, lblCnt->Caption);//"구간", "발생건수(량)");
  111. ChartValueDisplay(TvChart1, ChkDisplayVal1->Checked);
  112. ChartValueDisplay(TvChart2, ChkDisplayVal2->Checked);
  113. TvChart1->ToolBox->CustomizeButton = true;
  114. TvChart2->ToolBox->CustomizeButton = true;
  115. TvChart1->Legend->Position = cppDefault;
  116. TvChart2->Legend->Position = cppDefault;
  117. }
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TIST00401::SetChartLegend(TcxGridChartView *ATvChart, String ACategory, String AValue)
  121. {
  122. try {
  123. ATvChart->DiagramArea->AxisCategory->Title->Text = ACategory;
  124. ATvChart->DiagramArea->AxisValue->Title->Text = AValue;
  125. ATvChart->DiagramBar->AxisCategory->Title->Text = ACategory;
  126. ATvChart->DiagramBar->AxisValue->Title->Text = AValue;
  127. ATvChart->DiagramColumn->AxisCategory->Title->Text = ACategory;
  128. ATvChart->DiagramColumn->AxisValue->Title->Text = AValue;
  129. ATvChart->DiagramLine->AxisCategory->Title->Text = ACategory;
  130. ATvChart->DiagramLine->AxisValue->Title->Text = AValue;
  131. ATvChart->DiagramStackedArea->AxisCategory->Title->Text = ACategory;
  132. ATvChart->DiagramStackedArea->AxisValue->Title->Text = AValue;
  133. ATvChart->DiagramStackedBar->AxisCategory->Title->Text = ACategory;
  134. ATvChart->DiagramStackedBar->AxisValue->Title->Text = AValue;
  135. ATvChart->DiagramStackedColumn->AxisCategory->Title->Text = ACategory;
  136. ATvChart->DiagramStackedColumn->AxisValue->Title->Text = AValue;
  137. } catch(...) {}
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TIST00401::ChartValueDisplay(TcxGridChartView *ATvChart, bool FDisplayValue)
  141. {
  142. try {
  143. ATvChart->DiagramArea->Values->CaptionPosition = FDisplayValue ? ldvcpAbove : ldvcpNone;
  144. ATvChart->DiagramBar->Values->CaptionPosition = FDisplayValue ? cdvcpOutsideEnd : cdvcpNone;
  145. ATvChart->DiagramColumn->Values->CaptionPosition = FDisplayValue ? cdvcpOutsideEnd : cdvcpNone;
  146. ATvChart->DiagramLine->Values->CaptionPosition = FDisplayValue ? ldvcpAbove : ldvcpNone;
  147. ATvChart->DiagramPie->Values->CaptionPosition = FDisplayValue ? pdvcpOutsideEndWithLeaderLines : pdvcpNone;
  148. ATvChart->DiagramStackedArea->Values->CaptionPosition = FDisplayValue ? ldvcpRight : ldvcpNone;
  149. ATvChart->DiagramStackedBar->Values->CaptionPosition = FDisplayValue ? cdvcpCenter : cdvcpNone;
  150. ATvChart->DiagramStackedColumn->Values->CaptionPosition = FDisplayValue ? cdvcpCenter : cdvcpNone;
  151. } catch(...) {}
  152. }
  153. //---------------------------------------------------------------------------
  154. void __fastcall TIST00401::FormShow(TObject *Sender)
  155. {
  156. FormInit();
  157. Refresh();
  158. TmrShow->Enabled = true;
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TIST00401::TmrShowTimer(TObject *Sender)
  162. {
  163. TmrShow->Enabled = false;
  164. TvChart1->ClearSeries();
  165. TvChart2->ClearSeries();
  166. pMngrInci->FLists.RemoveAll();
  167. Application->ProcessMessages();
  168. if (FStatType == 0)
  169. {
  170. SelIncidentType();
  171. }
  172. else
  173. {
  174. SelIncidentSect();
  175. }
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TIST00401::ChkExpandClick(TObject *Sender)
  179. {
  180. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TIST00401::SelIncidentType()
  184. {
  185. TSqlCursor sqlCrs;
  186. String sQry;
  187. TADOQuery *pADO = ADOQry;
  188. switch(FTermType)
  189. {
  190. case 0:
  191. sQry = "SELECT SUBSTR(STAT_DT, 1, 8) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  192. " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 8), 'YYYYMMDD'), 'YYYY-MM-DD') AS STAT_DTNM, \r\n"
  193. " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n"
  194. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  195. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  196. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  197. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  198. " FROM TB_INCD_TYPE_DD_STAT \r\n"
  199. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  200. // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n"
  201. // " FROM TB_CMMN_CD a \r\n"
  202. // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n"
  203. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 8), INCD_TYPE_CD) \r\n"
  204. " ORDER BY STAT_DT \r\n";
  205. break;
  206. case 1:
  207. sQry = "SELECT SUBSTR(STAT_DT, 1, 6) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  208. " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 6), 'YYYYMM'), 'YYYY-MM') AS STAT_DTNM, \r\n"
  209. " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n"
  210. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  211. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  212. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  213. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  214. " FROM TB_INCD_TYPE_MN_STAT \r\n"
  215. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  216. // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n"
  217. // " FROM TB_CMMN_CD a \r\n"
  218. // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n"
  219. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 6), INCD_TYPE_CD) \r\n"
  220. " ORDER BY STAT_DT \r\n";
  221. break;
  222. case 2:
  223. sQry = "SELECT SUBSTR(STAT_DT, 1, 4) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  224. " SUBSTR(STAT_DT, 1, 4) AS STAT_DTNM, \r\n"
  225. " INCD_TYPE_CD AS INCD_TYPE_CD, \r\n"
  226. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  227. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  228. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  229. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  230. " FROM TB_INCD_TYPE_MN_STAT \r\n"
  231. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  232. // " AND INCD_TYPE_CD IN (SELECT CMMN_CD \r\n"
  233. // " FROM TB_CMMN_CD a \r\n"
  234. // " WHERE CMMN_CLSF_CD = 'IDTU') \r\n"
  235. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 4), INCD_TYPE_CD) \r\n"
  236. " ORDER BY STAT_DT \r\n";
  237. break;
  238. default: return;
  239. }
  240. sQry = "SELECT NVL(STAT_DT, 'X') AS STAT_DT, \r\n"
  241. " NVL(DATA_CNT, 0) AS DATA_CNT, \r\n"
  242. " NVL(STAT_DTNM, 'X') AS STAT_DTNM, \r\n"
  243. " NVL(INCD_TYPE_CD, '-') AS INCD_TYPE_CD, \r\n"
  244. " NVL(INCD_OCRR_NUM, 0) AS INCD_OCRR_NUM, \r\n"
  245. " NVL(FTLT_PNUM, 0) AS FTLT_PNUM, \r\n"
  246. " NVL(INJR_PNUM, 0) AS INJR_PNUM, \r\n"
  247. " NVL(PRPR_DMGE_AMT, 0) AS PRPR_DMGE_AMT \r\n"
  248. " FROM (" + sQry + ")";
  249. try
  250. {
  251. ITSDb_SQLClose(pADO);
  252. ITSDb_SQLText(pADO, sQry);
  253. ITSDb_SQLBind(pADO, "p01", FStTime);
  254. ITSDb_SQLBind(pADO, "p02", FEdTime);
  255. ITSDb_SQLOpen(pADO);
  256. DspIncidentTypeList();
  257. }
  258. catch(EDatabaseError &E)
  259. {
  260. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  261. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  262. throw Exception(String(E.ClassName()) + E.Message);
  263. }
  264. catch(Exception &e)
  265. {
  266. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  267. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  268. throw Exception(String(e.ClassName()) + e.Message);
  269. }
  270. }
  271. //---------------------------------------------------------------------------
  272. void __fastcall TIST00401::DspIncidentTypeList()
  273. {
  274. TADOQuery *pADO = ADOQry;
  275. try
  276. {
  277. CMM_ClearGridTableView(TvList);
  278. int nRow = 0;
  279. int nDataCnt = 0;
  280. try
  281. {
  282. TvList->BeginUpdate();
  283. nDataCnt = pADO->RecordCount;
  284. m_pGDC->RecordCount = nDataCnt;
  285. String sRowType = "";
  286. String sTypeNm = "";
  287. int nIncd, nFtlt, nInjr, nPrpr;
  288. for( ; !pADO->Eof; pADO->Next(), nRow++)
  289. {
  290. String sDate = pADO->FieldByName("STAT_DTNM")->AsString;
  291. String sType = pADO->FieldByName("INCD_TYPE_CD")->AsString;
  292. nIncd = pADO->FieldByName("INCD_OCRR_NUM")->AsInteger; //발생건수
  293. nFtlt = pADO->FieldByName("FTLT_PNUM")->AsInteger; //사망자수
  294. nInjr = pADO->FieldByName("INJR_PNUM")->AsInteger; //부상자수
  295. nPrpr = pADO->FieldByName("PRPR_DMGE_AMT")->AsInteger; //피해금액
  296. sRowType = "0";
  297. if (sDate == "X")
  298. {
  299. sRowType = "2";
  300. sDate = FrmLang->lblChartTotal->Caption;//"전체";
  301. sType = "-";
  302. sTypeNm = "-";
  303. }
  304. else
  305. {
  306. TItsStaIncident *pInci = pMngrInci->FLists.Find(sDate);
  307. if (!pInci)
  308. {
  309. pInci = new TItsStaIncident();
  310. pMngrInci->FLists.Push(sDate, pInci);
  311. pInci->FDate = sDate;
  312. }
  313. if (sType == "-")
  314. {
  315. sRowType = "1";
  316. sType = "+";
  317. sTypeNm = FrmLang->lblChartSoge->Caption;//"소계";
  318. pInci->FIncid[0][0] = nIncd;
  319. pInci->FIncid[0][1] = nFtlt;
  320. pInci->FIncid[0][2] = nInjr;
  321. pInci->FIncid[0][3] = nPrpr;
  322. }
  323. else
  324. {
  325. if (sType == "1")
  326. {
  327. sTypeNm = FrmLang->lblInc1->Caption;//"사고";
  328. pInci->FIncid[1][0] += nIncd;
  329. pInci->FIncid[1][1] += nFtlt;
  330. pInci->FIncid[1][2] += nInjr;
  331. pInci->FIncid[1][3] += nPrpr;
  332. }
  333. else if (sType == "2")
  334. {
  335. sTypeNm = FrmLang->lblInc2->Caption;//"공사";
  336. pInci->FIncid[2][0] += nIncd;
  337. pInci->FIncid[2][1] += nFtlt;
  338. pInci->FIncid[2][2] += nInjr;
  339. pInci->FIncid[2][3] += nPrpr;
  340. }
  341. else if (sType == "3")
  342. {
  343. sTypeNm = FrmLang->lblInc3->Caption;//"행사";
  344. pInci->FIncid[3][0] += nIncd;
  345. pInci->FIncid[3][1] += nFtlt;
  346. pInci->FIncid[3][2] += nInjr;
  347. pInci->FIncid[3][3] += nPrpr;
  348. }
  349. else if (sType == "4")
  350. {
  351. sTypeNm = FrmLang->lblInc4->Caption;//"기상";
  352. pInci->FIncid[4][0] += nIncd;
  353. pInci->FIncid[4][1] += nFtlt;
  354. pInci->FIncid[4][2] += nInjr;
  355. pInci->FIncid[4][3] += nPrpr;
  356. }
  357. else if (sType == "5")
  358. {
  359. sTypeNm = FrmLang->lblInc5->Caption;//"통제";
  360. pInci->FIncid[5][0] += nIncd;
  361. pInci->FIncid[5][1] += nFtlt;
  362. pInci->FIncid[5][2] += nInjr;
  363. pInci->FIncid[5][3] += nPrpr;
  364. }
  365. else if (sType == "6")
  366. {
  367. sTypeNm = FrmLang->lblInc6->Caption;//"재난";
  368. pInci->FIncid[6][0] += nIncd;
  369. pInci->FIncid[6][1] += nFtlt;
  370. pInci->FIncid[6][2] += nInjr;
  371. pInci->FIncid[6][3] += nPrpr;
  372. }
  373. else
  374. {
  375. sTypeNm = FrmLang->lblInc0->Caption;//"기타";
  376. pInci->FIncid[7][0] += nIncd;
  377. pInci->FIncid[7][1] += nFtlt;
  378. pInci->FIncid[7][2] += nInjr;
  379. pInci->FIncid[7][3] += nPrpr;
  380. }
  381. sTypeNm = "[" + sType + "] " + sTypeNm;
  382. }
  383. }
  384. m_pGDC->Values[nRow][Column01->Index] = sDate;
  385. m_pGDC->Values[nRow][Column02->Index] = "";
  386. m_pGDC->Values[nRow][Column03->Index] = "";
  387. m_pGDC->Values[nRow][Column04->Index] = sTypeNm;
  388. m_pGDC->Values[nRow][Column05->Index] = sType;
  389. m_pGDC->Values[nRow][Column06->Index] = nIncd;
  390. m_pGDC->Values[nRow][Column07->Index] = nFtlt;
  391. m_pGDC->Values[nRow][Column08->Index] = nInjr;
  392. m_pGDC->Values[nRow][Column09->Index] = nPrpr;
  393. m_pGDC->Values[nRow][Column10->Index] = sRowType;
  394. }
  395. }
  396. __finally
  397. {
  398. if (pADO)
  399. {
  400. pADO->Close();
  401. }
  402. TvList->EndUpdate();
  403. //CxList->SetFocus();
  404. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  405. }
  406. }
  407. catch(EDatabaseError &E)
  408. {
  409. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  410. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  411. throw Exception(String(E.ClassName()) + E.Message);
  412. }
  413. catch(Exception &e)
  414. {
  415. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  416. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  417. throw Exception(String(e.ClassName()) + e.Message);
  418. }
  419. DspIncidentTypeChart();
  420. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  421. Application->MessageBox(sEnd.c_str(),
  422. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  423. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  424. }
  425. //---------------------------------------------------------------------------
  426. void __fastcall TIST00401::DspIncidentTypeChart()
  427. {
  428. try
  429. {
  430. TcxGridChartSeries *pChart11 = NULL;
  431. TcxGridChartSeries *pChart12 = NULL;
  432. TcxGridChartSeries *pChart13 = NULL;
  433. TcxGridChartSeries *pChart14 = NULL;
  434. TcxGridChartSeries *pChart21 = NULL;
  435. TcxGridChartSeries *pChart22 = NULL;
  436. TcxGridChartSeries *pChart23 = NULL;
  437. TcxGridChartSeries *pChart24 = NULL;
  438. TcxGridChartSeries *pChart25 = NULL;
  439. TcxGridChartSeries *pChart26 = NULL;
  440. TcxGridChartSeries *pChart27 = NULL;
  441. TvChart1->ClearSeries();
  442. TvChart2->ClearSeries();
  443. int nRow = 0;
  444. int nDataCnt = 0;
  445. try
  446. {
  447. TvChart1->BeginUpdate();
  448. TvChart2->BeginUpdate();
  449. nDataCnt = pMngrInci->FLists.Size();
  450. TvChart1->DataController->RecordCount = nDataCnt;
  451. TvChart2->DataController->RecordCount = nDataCnt;
  452. pChart11 = TvChart1->CreateSeries();
  453. pChart11->DataBinding->ValueType = "Integer";
  454. pChart11->DisplayText = Column06->Caption;//"돌발발생건수";
  455. pChart12 = TvChart1->CreateSeries();
  456. pChart12->DataBinding->ValueType = "Integer";
  457. pChart12->DisplayText = Column07->Caption;//"사망자수";
  458. pChart13 = TvChart1->CreateSeries();
  459. pChart13->DataBinding->ValueType = "Integer";
  460. pChart13->DisplayText = Column08->Caption;//"부상자수";
  461. #if 0
  462. pChart14 = TvChart1->CreateSeries();
  463. pChart14->DataBinding->ValueType = "Integer";
  464. pChart14->DisplayText = Column09->Caption;//"재산피해금액";
  465. #endif
  466. pChart21 = TvChart2->CreateSeries();
  467. pChart21->DataBinding->ValueType = "Integer";
  468. pChart21->DisplayText = FrmLang->lblInc1->Caption;//"사고";
  469. pChart22 = TvChart2->CreateSeries();
  470. pChart22->DataBinding->ValueType = "Integer";
  471. pChart22->DisplayText = FrmLang->lblInc2->Caption;//"공사";
  472. pChart23 = TvChart2->CreateSeries();
  473. pChart23->DataBinding->ValueType = "Integer";
  474. pChart23->DisplayText = FrmLang->lblInc3->Caption;//"행사";
  475. pChart24 = TvChart2->CreateSeries();
  476. pChart24->DataBinding->ValueType = "Integer";
  477. pChart24->DisplayText = FrmLang->lblInc4->Caption;//"기상";
  478. pChart25 = TvChart2->CreateSeries();
  479. pChart25->DataBinding->ValueType = "Integer";
  480. pChart25->DisplayText = FrmLang->lblInc5->Caption;//"통제";
  481. pChart26 = TvChart2->CreateSeries();
  482. pChart26->DataBinding->ValueType = "Integer";
  483. pChart26->DisplayText = FrmLang->lblInc6->Caption;//"재난";
  484. pChart27 = TvChart2->CreateSeries();
  485. pChart27->DataBinding->ValueType = "Integer";
  486. pChart27->DisplayText = FrmLang->lblInc0->Caption;//"기타";
  487. FOR_STL(TItsStaIncident*, pInci, pMngrInci->FLists)
  488. {
  489. pChart11->Values[nRow] = pInci->FIncid[0][0];
  490. pChart12->Values[nRow] = pInci->FIncid[0][1];
  491. pChart13->Values[nRow] = pInci->FIncid[0][2];
  492. //pChart14->Values[nRow] = pInci->FIncid[0][3];
  493. TvChart1->Categories->Values[nRow] = pInci->FDate;
  494. pChart21->Values[nRow] = pInci->FIncid[1][0];
  495. pChart22->Values[nRow] = pInci->FIncid[2][0];
  496. pChart23->Values[nRow] = pInci->FIncid[3][0];
  497. pChart24->Values[nRow] = pInci->FIncid[4][0];
  498. pChart25->Values[nRow] = pInci->FIncid[5][0];
  499. pChart26->Values[nRow] = pInci->FIncid[6][0];
  500. pChart27->Values[nRow] = pInci->FIncid[7][0];
  501. TvChart2->Categories->Values[nRow] = pInci->FDate;
  502. nRow++;
  503. }
  504. }
  505. __finally
  506. {
  507. TvChart1->EndUpdate();
  508. TvChart2->EndUpdate();
  509. pMngrInci->FLists.RemoveAll();
  510. }
  511. }
  512. catch(...)
  513. {
  514. throw Exception(FrmLang->lblDbErr->Caption);//"[DspIncidentTypeChart]알수없는 오류가 발생하였습니다.");
  515. }
  516. }
  517. //---------------------------------------------------------------------------
  518. void __fastcall TIST00401::SelIncidentSect()
  519. {
  520. TSqlCursor sqlCrs;
  521. String sQry;
  522. TADOQuery *pADO = ADOQry;
  523. switch(FTermType)
  524. {
  525. case 0:
  526. sQry = "SELECT SUBSTR(STAT_DT, 1, 8) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  527. " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 8), 'YYYYMMDD'), 'YYYY-MM-DD') AS STAT_DTNM, \r\n"
  528. " LINK_ID AS LINK_ID, \r\n"
  529. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  530. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  531. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  532. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  533. " FROM TB_INCD_SECT_DD_STAT \r\n"
  534. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  535. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 8), LINK_ID) \r\n"
  536. " ORDER BY STAT_DT \r\n";
  537. break;
  538. case 1:
  539. sQry = "SELECT SUBSTR(STAT_DT, 1, 6) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  540. " TO_CHAR(TO_DATE(SUBSTR(STAT_DT, 1, 6), 'YYYYMM'), 'YYYY-MM') AS STAT_DTNM, \r\n"
  541. " LINK_ID AS LINK_ID, \r\n"
  542. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  543. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  544. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  545. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  546. " FROM TB_INCD_SECT_MN_STAT \r\n"
  547. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  548. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 6), LINK_ID) \r\n"
  549. " ORDER BY STAT_DT \r\n";
  550. break;
  551. case 2:
  552. sQry = "SELECT SUBSTR(STAT_DT, 1, 4) AS STAT_DT, COUNT(1) DATA_CNT, \r\n"
  553. " SUBSTR(STAT_DT, 1, 4) AS STAT_DTNM, \r\n"
  554. " LINK_ID AS LINK_ID, \r\n"
  555. " SUM(INCD_OCRR_NUM) INCD_OCRR_NUM, \r\n"
  556. " SUM(FTLT_PNUM) FTLT_PNUM, \r\n"
  557. " SUM(INJR_PNUM) INJR_PNUM, \r\n"
  558. " SUM(PRPR_DMGE_AMT) PRPR_DMGE_AMT \r\n"
  559. " FROM TB_INCD_SECT_MN_STAT \r\n"
  560. " WHERE STAT_DT BETWEEN :p01 AND :p02 \r\n"
  561. " GROUP BY ROLLUP(SUBSTR(STAT_DT, 1, 4), LINK_ID) \r\n"
  562. " ORDER BY STAT_DT \r\n";
  563. break;
  564. default: return;
  565. }
  566. sQry = "SELECT NVL(STAT_DT, 'X') AS STAT_DT, \r\n"
  567. " NVL(DATA_CNT, 0) AS DATA_CNT, \r\n"
  568. " NVL(STAT_DTNM, 'X') AS STAT_DTNM, \r\n"
  569. " NVL(LINK_ID, 0) AS LINK_ID, \r\n"
  570. " NVL(INCD_OCRR_NUM, 0) AS INCD_OCRR_NUM, \r\n"
  571. " NVL(FTLT_PNUM, 0) AS FTLT_PNUM, \r\n"
  572. " NVL(INJR_PNUM, 0) AS INJR_PNUM, \r\n"
  573. " NVL(PRPR_DMGE_AMT, 0) AS PRPR_DMGE_AMT \r\n"
  574. " FROM (" + sQry + ")";
  575. try
  576. {
  577. ITSDb_SQLText(pADO, sQry);
  578. ITSDb_SQLBind(pADO, "p01", FStTime);
  579. ITSDb_SQLBind(pADO, "p02", FEdTime);
  580. ITSDb_SQLOpen(pADO);
  581. DspIncidentSectList();
  582. }
  583. catch(EDatabaseError &E)
  584. {
  585. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  586. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  587. throw Exception(String(E.ClassName()) + E.Message);
  588. }
  589. catch(Exception &e)
  590. {
  591. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  592. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  593. throw Exception(String(e.ClassName()) + e.Message);
  594. }
  595. }
  596. //---------------------------------------------------------------------------
  597. void __fastcall TIST00401::DspIncidentSectList()
  598. {
  599. TADOQuery *pADO = ADOQry;
  600. try
  601. {
  602. CMM_ClearGridTableView(TvList);
  603. int nRow = 0;
  604. int nDataCnt = 0;
  605. try
  606. {
  607. TvList->BeginUpdate();
  608. nDataCnt = pADO->RecordCount;
  609. m_pGDC->RecordCount = nDataCnt;
  610. String sRowType = "";
  611. int nIncd, nFtlt, nInjr, nPrpr;
  612. TItsNode *pNode;
  613. TItsLink *pLink;
  614. String sFNode, sTNode;
  615. for( ; !pADO->Eof; pADO->Next(), nRow++)
  616. {
  617. sFNode = sTNode = "";
  618. String sDate = pADO->FieldByName("STAT_DTNM")->AsString; //통계시각
  619. String sLink = pADO->FieldByName("LINK_ID")->AsString; //구간ID
  620. nIncd = pADO->FieldByName("INCD_OCRR_NUM")->AsInteger; //발생건수
  621. nFtlt = pADO->FieldByName("FTLT_PNUM")->AsInteger; //사망자수
  622. nInjr = pADO->FieldByName("INJR_PNUM")->AsInteger; //부상자수
  623. nPrpr = pADO->FieldByName("PRPR_DMGE_AMT")->AsInteger; //피해금액
  624. sRowType = "0";
  625. if (sDate == "X")
  626. {
  627. sRowType = "2";
  628. sDate = FrmLang->lblChartTotal->Caption;//"전체";
  629. sLink = "-";
  630. sFNode = sTNode = "-";
  631. }
  632. else
  633. {
  634. if (sLink == "0")
  635. {
  636. sRowType = "1";
  637. sLink = FrmLang->lblChartSoge->Caption;//"소계";
  638. sFNode = sTNode = "-";
  639. }
  640. else
  641. {
  642. sFNode = sTNode = "";
  643. pLink = ItsLinkManager->FLists.Find(sLink);
  644. if (pLink)
  645. {
  646. sFNode = "[" + pLink->F_NODE_ID + "] ";
  647. pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
  648. if (pNode) sFNode = sFNode + pNode->NODE_NAME;
  649. sTNode = "[" + pLink->T_NODE_ID + "] ";
  650. pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
  651. if (pNode) sTNode = sTNode + pNode->NODE_NAME;
  652. }
  653. TItsStaIncident *pInci = pMngrInci->FLists.Find(sLink);
  654. if (!pInci)
  655. {
  656. pInci = new TItsStaIncident();
  657. pMngrInci->FLists.Push(sLink, pInci);
  658. pInci->FDate = sLink;
  659. }
  660. pInci->FIncid[0][0] += nIncd;
  661. pInci->FIncid[0][1] += nFtlt;
  662. pInci->FIncid[0][2] += nInjr;
  663. pInci->FIncid[0][3] += nPrpr;
  664. }
  665. }
  666. m_pGDC->Values[nRow][Column01->Index] = sDate;
  667. m_pGDC->Values[nRow][Column02->Index] = sLink;
  668. m_pGDC->Values[nRow][Column03->Index] = sFNode;
  669. m_pGDC->Values[nRow][Column11->Index] = sTNode;
  670. m_pGDC->Values[nRow][Column06->Index] = nIncd;
  671. m_pGDC->Values[nRow][Column07->Index] = nFtlt;
  672. m_pGDC->Values[nRow][Column08->Index] = nInjr;
  673. m_pGDC->Values[nRow][Column09->Index] = nPrpr;
  674. m_pGDC->Values[nRow][Column10->Index] = sRowType;
  675. }
  676. }
  677. __finally
  678. {
  679. if (pADO)
  680. {
  681. pADO->Close();
  682. }
  683. TvList->EndUpdate();
  684. //CxList->SetFocus();
  685. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  686. }
  687. }
  688. catch(EDatabaseError &E)
  689. {
  690. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  691. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  692. throw Exception(String(E.ClassName()) + E.Message);
  693. }
  694. catch(Exception &e)
  695. {
  696. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  697. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  698. throw Exception(String(e.ClassName()) + e.Message);
  699. }
  700. DspIncidentSectChart();
  701. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  702. Application->MessageBox(sEnd.c_str(),
  703. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  704. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  705. }
  706. //---------------------------------------------------------------------------
  707. void __fastcall TIST00401::DspIncidentSectChart()
  708. {
  709. try
  710. {
  711. TcxGridChartSeries *pChart11 = NULL;
  712. TcxGridChartSeries *pChart12 = NULL;
  713. TcxGridChartSeries *pChart13 = NULL;
  714. TcxGridChartSeries *pChart14 = NULL;
  715. TvChart1->ClearSeries();
  716. int nRow = 0;
  717. int nDataCnt = 0;
  718. try
  719. {
  720. TvChart1->BeginUpdate();
  721. nDataCnt = pMngrInci->FLists.Size();
  722. TvChart1->DataController->RecordCount = nDataCnt;
  723. pChart11 = TvChart1->CreateSeries();
  724. pChart11->DataBinding->ValueType = "Integer";
  725. pChart11->DisplayText = Column06->Caption;//"돌발발생건수";
  726. pChart12 = TvChart1->CreateSeries();
  727. pChart12->DataBinding->ValueType = "Integer";
  728. pChart12->DisplayText = Column07->Caption;//"사망자수";
  729. pChart13 = TvChart1->CreateSeries();
  730. pChart13->DataBinding->ValueType = "Integer";
  731. pChart13->DisplayText = Column08->Caption;//"부상자수";
  732. #if 0
  733. pChart14 = TvChart1->CreateSeries();
  734. pChart14->DataBinding->ValueType = "Integer";
  735. pChart14->DisplayText = Column09->Caption;//"재산피해금액";
  736. #endif
  737. FOR_STL(TItsStaIncident*, pInci, pMngrInci->FLists)
  738. {
  739. pChart11->Values[nRow] = pInci->FIncid[0][0];
  740. pChart12->Values[nRow] = pInci->FIncid[0][1];
  741. pChart13->Values[nRow] = pInci->FIncid[0][2];
  742. //pChart14->Values[nRow] = pInci->FIncid[0][3];
  743. TvChart1->Categories->Values[nRow] = pInci->FDate;
  744. nRow++;
  745. }
  746. }
  747. __finally
  748. {
  749. TvChart1->EndUpdate();
  750. pMngrInci->FLists.RemoveAll();
  751. }
  752. }
  753. catch(...)
  754. {
  755. throw Exception(FrmLang->lblDbErr->Caption);//"[DspIncidentTypeChart]알수없는 오류가 발생하였습니다.");
  756. }
  757. }
  758. //---------------------------------------------------------------------------
  759. void __fastcall TIST00401::OnMessage(TMessage &Msg)
  760. {
  761. switch (Msg.Msg)
  762. {
  763. case WM_PARAM_DATABASE:
  764. if (WP_DB_SELECT_OK == Msg.WParam)
  765. {
  766. //ShowMessage("Select Ok");
  767. }
  768. break;
  769. }
  770. }
  771. //---------------------------------------------------------------------------
  772. void __fastcall TIST00401::BtnExlSaveClick(TObject *Sender)
  773. {
  774. TcxGrid *pGrid = CxList;
  775. TcxGridTableView *pView = TvList;
  776. String sTitle= Caption;//"돌발상황통계";
  777. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  778. }
  779. //---------------------------------------------------------------------------
  780. void __fastcall TIST00401::FormClose(TObject *Sender, TCloseAction &Action)
  781. {
  782. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  783. CommClose();
  784. //IST00401 = NULL;
  785. }
  786. //---------------------------------------------------------------------------
  787. void __fastcall TIST00401::FormDestroy(TObject *Sender)
  788. {
  789. if (pMngrInci)
  790. {
  791. delete pMngrInci;
  792. pMngrInci = NULL;
  793. }
  794. CommClose();
  795. }
  796. //---------------------------------------------------------------------------
  797. void __fastcall TIST00401::CommClose()
  798. {
  799. if (pMngrInci)
  800. {
  801. delete pMngrInci;
  802. pMngrInci = NULL;
  803. }
  804. CMM_SaveForm(g_sFormsDir, this);
  805. //IST00401 = NULL;
  806. }
  807. //---------------------------------------------------------------------------
  808. void __fastcall TIST00401::cxTrackBarMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
  809. {
  810. try {
  811. TcxTrackBar *pTrack = (TcxTrackBar*)Sender;
  812. TcxLabel *pLabel = LblPage1;
  813. TcxGridChartView *pChart = TvChart1;
  814. if (pTrack->Tag == 2)
  815. {
  816. pLabel = LblPage2;
  817. pChart = TvChart2;
  818. }
  819. if (pTrack->Position == pTrack->Properties->Max)
  820. {
  821. pChart->OptionsView->CategoriesPerPage = 0;
  822. pLabel->Caption = lblAll->Caption;//"All ";
  823. }
  824. else
  825. {
  826. pChart->OptionsView->CategoriesPerPage = pTrack->Position;
  827. pLabel->Caption = String(pTrack->Position) + " ";
  828. }
  829. } catch(...) {}
  830. }
  831. //---------------------------------------------------------------------------
  832. void __fastcall TIST00401::cxTrackBarPropertiesChange(TObject *Sender)
  833. {
  834. try {
  835. TcxTrackBar *pTrack = (TcxTrackBar*)Sender;
  836. TcxLabel *pLabel = LblPage1;
  837. if (pTrack->Tag == 2)
  838. {
  839. pLabel = LblPage2;
  840. }
  841. if (pTrack->Position == pTrack->Properties->Max)
  842. {
  843. pLabel->Caption = lblAll->Caption;//"전체 ";
  844. }
  845. else
  846. {
  847. pLabel->Caption = String(pTrack->Position) + " ";
  848. }
  849. } catch(...) {}
  850. }
  851. //---------------------------------------------------------------------------
  852. void __fastcall TIST00401::BtnGraphSaveClick(TObject *Sender)
  853. {
  854. String sTitle;
  855. TcxButton *pBtn = (TcxButton*)Sender;
  856. TcxGridChartView *pChart = TvChart1;
  857. if (pBtn->Tag == 2)
  858. {
  859. pChart = TvChart2;
  860. }
  861. TSaveDialog *SaveDialog1 = NULL;
  862. String sNewFile, sDate;
  863. sTitle = cxPageControl1->Properties->ActivePage->Caption;
  864. sDate = Now().FormatString("YYYYMMDDhhnn");
  865. sNewFile = FTitle + "_" + sDate;
  866. int nFilterIndex = 0;
  867. try
  868. {
  869. SaveDialog1 = new TSaveDialog(Application);
  870. SaveDialog1->Title = sTitle + lblImgSave->Caption;//" 차트 이미지 저장";
  871. //SaveDialog1->InitialDir = ExtractFilePath(Application->ExeName);
  872. SaveDialog1->Filter = "BMP (*.bmp)|*.bmp|"
  873. "JPG (*.jpg)|*.jpg|"
  874. //"PNG (*.png)|*.png|"
  875. "WMF (*.wmf)|*.wmf|"
  876. "EMF (*.emf)|*.emf";
  877. SaveDialog1->FileName = sNewFile;
  878. if (SaveDialog1->Execute() == false)
  879. {
  880. return ;
  881. }
  882. sNewFile = SaveDialog1->FileName;
  883. if (sNewFile == "")
  884. {
  885. return ;
  886. }
  887. nFilterIndex = SaveDialog1->FilterIndex;
  888. }
  889. __finally
  890. {
  891. if (SaveDialog1) delete SaveDialog1;
  892. ChDir(ExtractFilePath(Application->ExeName));
  893. }
  894. TWaitCursor waitCsr;
  895. #include <jpeg.hpp>
  896. TGraphic *pGraphic = NULL;
  897. TGraphic *pTmpImage = NULL;
  898. try
  899. {
  900. Application->ProcessMessages();
  901. try
  902. {
  903. bool bMetafile = false;
  904. switch (nFilterIndex)
  905. {
  906. case 1: sNewFile = ChangeFileExt(sNewFile, ".bmp"); bMetafile = false; break;
  907. case 2: sNewFile = ChangeFileExt(sNewFile, ".jpg"); bMetafile = false; break;
  908. //case 3: sNewFile = ChangeFileExt(sNewFile, ".png"); bMetafile = false; break;
  909. case 3: sNewFile = ChangeFileExt(sNewFile, ".wmf"); bMetafile = true; break;
  910. case 4: sNewFile = ChangeFileExt(sNewFile, ".emf"); bMetafile = true; break;
  911. default: sNewFile = ChangeFileExt(sNewFile, ".bmp"); bMetafile = false; break;
  912. }
  913. // (TdxPNGImage)
  914. if (nFilterIndex == 3 || nFilterIndex == 4)
  915. {
  916. pGraphic = pChart->CreateImage(__classid(Graphics::TMetafile));
  917. ((Graphics::TMetafile*)pGraphic)->Enhanced = nFilterIndex == 4 ? true : false;
  918. }
  919. else
  920. {
  921. pGraphic = pChart->CreateImage(__classid(Graphics::TBitmap));
  922. }
  923. //TPNGImage *pPng = new TPNGImage();
  924. switch (nFilterIndex)
  925. {
  926. case 2: pTmpImage = new TJPEGImage(); break;
  927. //case 3: pTmpImage = new TdxPNGImage(); break;
  928. }
  929. if (pTmpImage)
  930. {
  931. pTmpImage->Assign(pGraphic);
  932. pTmpImage->SaveToFile(sNewFile);
  933. }
  934. else
  935. {
  936. pGraphic->SaveToFile(sNewFile);
  937. }
  938. }
  939. catch(Exception & E)
  940. {
  941. String strMsg = lblSaveErr->Caption + "\r\n";//"파일로 저장하는 중에 에러가 발생했습니다.\r\n";
  942. strMsg += "[" + E.Message + "]\r\n";
  943. ShowMessage(strMsg);
  944. return ;
  945. }
  946. }
  947. __finally
  948. {
  949. if (pGraphic)
  950. {
  951. delete pGraphic;
  952. }
  953. if (pTmpImage)
  954. {
  955. delete pTmpImage;
  956. }
  957. }
  958. String sMsg = "";
  959. //sMsg = "[차트 이미지를\r\n" + sNewFile + "\r\n 로 생성 하였습니다.";
  960. sMsg = lblSaveOk->Caption + "\r\n[" + sNewFile + "]";
  961. MessageDlg(sMsg, mtInformation, TMsgDlgButtons() << mbOK, 0);
  962. }
  963. //---------------------------------------------------------------------------
  964. void __fastcall TIST00401::ChkDisplayValPropertiesChange(TObject *Sender)
  965. {
  966. TcxCheckBox *pChkBox = (TcxCheckBox*)Sender;
  967. if (pChkBox->Tag == 1)
  968. ChartValueDisplay(TvChart1, pChkBox->Checked);
  969. else
  970. ChartValueDisplay(TvChart2, pChkBox->Checked);
  971. }
  972. //---------------------------------------------------------------------------
  973. void __fastcall TIST00401::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  974. bool &ADone)
  975. {
  976. if (AViewInfo)
  977. {
  978. String sType = AViewInfo->GridRecord->DisplayTexts[Column10->Index];
  979. if (sType == "1")
  980. ACanvas->Brush->Color = clOlive; //소계
  981. else if (sType == "2")
  982. ACanvas->Brush->Color = clLime; //전체
  983. }
  984. }
  985. //---------------------------------------------------------------------------