IDB0070MF.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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 "ITSLangTransF.h"
  9. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "IDB0070MF.h"
  12. #include "ITSSELDAYF.h"
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. #pragma link "cxButtons"
  16. #pragma link "cxCalc"
  17. #pragma link "cxCheckBox"
  18. #pragma link "cxClasses"
  19. #pragma link "cxContainer"
  20. #pragma link "cxControls"
  21. #pragma link "cxCustomData"
  22. #pragma link "cxData"
  23. #pragma link "cxDataStorage"
  24. #pragma link "cxDropDownEdit"
  25. #pragma link "cxEdit"
  26. #pragma link "cxFilter"
  27. #pragma link "cxGraphics"
  28. #pragma link "cxGrid"
  29. #pragma link "cxGridCustomTableView"
  30. #pragma link "cxGridCustomView"
  31. #pragma link "cxGridLevel"
  32. #pragma link "cxGridTableView"
  33. #pragma link "cxLabel"
  34. #pragma link "cxLookAndFeelPainters"
  35. #pragma link "cxLookAndFeels"
  36. #pragma link "cxStyles"
  37. #pragma link "cxTextEdit"
  38. #pragma link "dxSkinBlack"
  39. #pragma link "dxSkinBlue"
  40. #pragma link "dxSkinsCore"
  41. #pragma link "dxSkinscxPCPainter"
  42. #pragma link "dxSkinMcSkin"
  43. #pragma resource "*.dfm"
  44. TIDB0070M *IDB0070M = NULL;
  45. //---------------------------------------------------------------------------
  46. __fastcall TIDB0070M::TIDB0070M(TComponent* Owner)
  47. : TForm(Owner)
  48. {
  49. LangTrans->Translate(this, ITSDb_GetConnection());
  50. ITSSkin_Load(this);
  51. CMM_LoadForm(g_sFormsDir, this);
  52. FTitle = Caption;//"휴일정보관리";
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TIDB0070M::CommClose()
  56. {
  57. try
  58. {
  59. if (ItsHolidayManager)
  60. {
  61. delete ItsHolidayManager;
  62. ItsHolidayManager = NULL;
  63. }
  64. CMM_SaveForm(g_sFormsDir, this);
  65. }
  66. catch(...)
  67. {
  68. }
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TIDB0070M::FormShow(TObject *Sender)
  72. {
  73. Refresh();
  74. FormInit();
  75. TmrShow->Enabled = true;
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TIDB0070M::FormInit()
  79. {
  80. m_pGDC = TvList->DataController;
  81. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<현재 등록된 휴일 정보가 없습니다>";
  82. if (!ItsHolidayManager)
  83. {
  84. ItsHolidayManager = new TItsHolidayManager();
  85. }
  86. FCodeLHT = ItsCodeManager->FLists.Find("LHT");
  87. try {
  88. TcxComboBoxProperties *pcxColumn02 = (TcxComboBoxProperties *)Column02->Properties;
  89. pcxColumn02->Items->Clear();
  90. if (FCodeLHT)
  91. {
  92. FOR_STL(TItsSubCode*, pSubCode, FCodeLHT->FSubLists)
  93. {
  94. pcxColumn02->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  95. if (FInitCombo == "") FInitCombo = pSubCode->CMMN_CD;
  96. }
  97. }
  98. else
  99. {
  100. //pcxColumn02->Items->Add("[LHT0] 공휴일");
  101. pcxColumn02->Items->Add("[LHT0] Holiday");
  102. }
  103. if (FInitCombo == "") FInitCombo = "LHT0";
  104. } catch(...) {}
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TIDB0070M::TmrShowTimer(TObject *Sender)
  108. {
  109. TmrShow->Enabled = false;
  110. BtnSearchClick((TObject*)BtnSearch);
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TIDB0070M::BtnSearchClick(TObject *Sender)
  114. {
  115. Application->ProcessMessages();
  116. TSqlCursor sqlCrs((TControl*)BtnSearch);
  117. RefreshData();
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TIDB0070M::RefreshData()
  121. {
  122. ItsHolidayManager->LoadFromDb();
  123. SelListData();
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TIDB0070M::SelListData()
  127. {
  128. FUpdate = false;
  129. CMM_ClearGridTableView(TvList);
  130. try
  131. {
  132. TvList->BeginUpdate();
  133. FOR_STL(TItsHoliday*, pObj, ItsHolidayManager->FLists)
  134. {
  135. pObj->EditMode = DB_INIT; // 미리초기화해준다.(삭제된것)
  136. pObj->Completed = true;
  137. if (pObj->DEL_YN == "Y") continue;
  138. AddObjectItem(pObj, "-");
  139. }
  140. }
  141. __finally
  142. {
  143. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  144. TvList->EndUpdate();
  145. TvList->DataController->GotoFirst();
  146. TvList->DataController->FocusedRecordIndex = 0;
  147. //CxList->SetFocus();
  148. }
  149. }
  150. //---------------------------------------------------------------------------
  151. void __fastcall TIDB0070M::BtnCloseClick(TObject *Sender)
  152. {
  153. Close();
  154. }
  155. //---------------------------------------------------------------------------
  156. void __fastcall TIDB0070M::BtnExlSaveClick(TObject *Sender)
  157. {
  158. TcxGrid *pGrid = CxList;
  159. TcxGridTableView *pView = TvList;
  160. String sTitle= Caption;//"휴일정보";
  161. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TIDB0070M::BtnInsertClick(TObject *Sender)
  165. {
  166. int nMsgType = MB_OK|MB_ICONERROR|MB_APPLMODAL;
  167. try
  168. {
  169. ITSSELDAY = new TITSSELDAY(this);
  170. ITSSELDAY->ShowModal();
  171. if (ITSSELDAY->Selected == false)
  172. {
  173. return;
  174. }
  175. String sDay = ITSSELDAY->cxDateEdit1->Date.FormatString("YYYYMMDD");
  176. TItsHoliday *pDb = (TItsHoliday *)ItsHolidayManager->FLists.Find(sDay);
  177. if (pDb)
  178. {
  179. String sErr = FrmLang->lbIdErr->Caption + "[" + sDay + "]";
  180. Application->MessageBox(sErr.c_str(),//("[" + sDay + "]는 사용할 수 없는 휴일 입니다.").c_str(),
  181. FTitle.c_str(), nMsgType);
  182. return;
  183. }
  184. try
  185. {
  186. TvList->BeginUpdate();
  187. TItsHoliday *pObj = new TItsHoliday();
  188. if (!pObj)
  189. {
  190. Application->MessageBox(FrmLang->lblMemErr->Caption.c_str(),//L"신규 휴일 정보를 생성할 수 없습니다.[메모리오류]",
  191. FTitle.c_str(), nMsgType);
  192. return;
  193. }
  194. pObj->YMD = sDay;
  195. pObj->DAY_TYPE_CD = FInitCombo;
  196. pObj->LEGL_HLDY_NM = "";
  197. pObj->RMRK = "";
  198. pObj->DEL_YN = "N";
  199. pObj->Completed = false;
  200. pObj->EditMode = DB_NEW;
  201. ItsHolidayManager->FLists.Push(pObj->YMD, pObj);
  202. AddObjectItem(pObj, FrmLang->lblNew->Caption);//"신규");
  203. }
  204. __finally
  205. {
  206. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  207. TvList->EndUpdate();
  208. TvList->DataController->GotoFirst();
  209. TvList->DataController->FocusedRecordIndex = 0;
  210. }
  211. }
  212. __finally
  213. {
  214. if (ITSSELDAY) delete ITSSELDAY;
  215. ITSSELDAY = NULL;
  216. }
  217. }
  218. //---------------------------------------------------------------------------
  219. void __fastcall TIDB0070M::BtnDeleteClick(TObject *Sender)
  220. {
  221. int nIdx = m_pGDC->FocusedRecordIndex;
  222. if (nIdx < 0) return;
  223. int nMemPtr = m_pGDC->Values[nIdx][Column99->Index];
  224. TItsHoliday *pObj = (TItsHoliday*)nMemPtr;
  225. pObj->EditMode = DB_DELETE;
  226. m_pGDC->Values[nIdx][Column00->Index] = FrmLang->lblDelete->Caption;//"삭제";
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TIDB0070M::FormClose(TObject *Sender, TCloseAction &Action)
  230. {
  231. CommClose();
  232. IDB0070M = NULL;
  233. Action = caFree;
  234. }
  235. //---------------------------------------------------------------------------
  236. void __fastcall TIDB0070M::BtnEditClick(TObject *Sender)
  237. {
  238. TListFocus tvFocus(TvList);
  239. if (BtnEdit->Caption == FrmLang->lblCancel->Caption)//"취소")
  240. {
  241. CxList->SetFocus();
  242. Application->ProcessMessages();
  243. SaveData();
  244. }
  245. FrmLang->ITSSkin_ButtonClick(BtnSearch, BtnEdit, BtnInsert, BtnDelete, BtnApply);
  246. ChangeEditMode(BtnEdit->Down);
  247. RefreshData();
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TIDB0070M::ChangeEditMode(bool AEdit)
  251. {
  252. bool bEditing = AEdit;
  253. try
  254. {
  255. TvList->BeginUpdate();
  256. Column00->Visible = bEditing;
  257. Column02->Options->Editing = bEditing;
  258. Column03->Options->Editing = bEditing;
  259. Column04->Options->Editing = bEditing;
  260. }
  261. __finally
  262. {
  263. TvList->EndUpdate();
  264. if (bEditing)
  265. {
  266. BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
  267. BtnEdit->Hint = FrmLang->lblCancel->Hint;//데이터 편집 취소";
  268. }
  269. else
  270. {
  271. BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
  272. BtnEdit->Hint = FrmLang->lblEdit->Hint;//데이터 편집";
  273. }
  274. }
  275. }
  276. //---------------------------------------------------------------------------
  277. void __fastcall TIDB0070M::TvListColumnPropertiesValidate(TObject *Sender, Variant &DisplayValue, TCaption &ErrorText, bool &Error)
  278. {
  279. if (TvList->Controller->FocusedRow->IsFilterRow) return;
  280. int nRow = m_pGDC->FocusedRecordIndex;
  281. if (nRow < 0) return;
  282. int nMemPtr = TvList->DataController->Values[nRow][Column99->Index];
  283. TItsHoliday *pObj = (TItsHoliday*)nMemPtr;
  284. if (pObj->Completed == false)
  285. {
  286. //신규이거나 삭제인 경우 편집 내용에 따른 변화가 필요없다.
  287. return;
  288. }
  289. String sType = VarToStr(m_pGDC->Values[nRow][Column02->Index]);
  290. String sName = VarToStr(m_pGDC->Values[nRow][Column03->Index]);
  291. String sRmrk = VarToStr(m_pGDC->Values[nRow][Column04->Index]);
  292. TcxGridColumn *pColumn = TvList->Controller->FocusedColumn;
  293. if (pColumn == Column02) sType = DisplayValue;
  294. else if (pColumn == Column03) sName = DisplayValue;
  295. else if (pColumn == Column04) sRmrk = DisplayValue;
  296. sType = ITSUtil_GetCode(sType);
  297. if (pObj->DAY_TYPE_CD != sType || //요일 유형 코드
  298. pObj->LEGL_HLDY_NM != sName || //공휴일 명
  299. pObj->RMRK != sRmrk ) //비고
  300. {
  301. m_pGDC->Values[nRow][Column00->Index] = FrmLang->lblModify->Caption;//"수정";
  302. pObj->EditMode = DB_UPDATE;
  303. }
  304. else
  305. {
  306. m_pGDC->Values[nRow][Column00->Index] = "-";
  307. pObj->EditMode = DB_INIT;
  308. }
  309. }
  310. //---------------------------------------------------------------------------
  311. void __fastcall TIDB0070M::BtnBestFitClick(TObject *Sender)
  312. {
  313. try
  314. {
  315. TvList->BeginUpdate();
  316. TvList->ApplyBestFit(NULL, false, false);
  317. }
  318. __finally
  319. {
  320. TvList->EndUpdate();
  321. }
  322. }
  323. //---------------------------------------------------------------------------
  324. void __fastcall TIDB0070M::ChkAutoWidthPropertiesChange(TObject *Sender)
  325. {
  326. try
  327. {
  328. TvList->BeginUpdate();
  329. TvList->OptionsView->ColumnAutoWidth = ChkAutoWidth->Checked;
  330. BtnBestFit->Visible = !ChkAutoWidth->Checked;
  331. }
  332. __finally
  333. {
  334. TvList->EndUpdate();
  335. }
  336. }
  337. //---------------------------------------------------------------------------
  338. void __fastcall TIDB0070M::MnuDeleteCancelClick(TObject *Sender)
  339. {
  340. //
  341. }
  342. //---------------------------------------------------------------------------
  343. void __fastcall TIDB0070M::BtnApplyClick(TObject *Sender)
  344. {
  345. FUpdate = true;
  346. BtnEdit->Down = false;
  347. BtnEdit->Click();
  348. }
  349. //---------------------------------------------------------------------------
  350. bool __fastcall TIDB0070M::AddObjectItem(TItsHoliday *pObj, String AMode)
  351. {
  352. TItsSubCode *pSubCode;
  353. int nRow;
  354. try
  355. {
  356. nRow = m_pGDC->AppendRecord();
  357. pObj->GridIndex = nRow;
  358. m_pGDC->Values[nRow][Column00->Index] = AMode;
  359. m_pGDC->Values[nRow][Column01->Index] = pObj->YMD;
  360. String sLHTName = "[" + pObj->DAY_TYPE_CD + "] ";
  361. if (FCodeLHT)
  362. {
  363. pSubCode = FCodeLHT->FSubLists.Find(pObj->DAY_TYPE_CD);
  364. if (pSubCode) sLHTName = sLHTName + pSubCode->CMMN_CD_KOR_NM;
  365. }
  366. m_pGDC->Values[nRow][Column02->Index] = sLHTName;
  367. m_pGDC->Values[nRow][Column03->Index] = pObj->LEGL_HLDY_NM;
  368. m_pGDC->Values[nRow][Column04->Index] = pObj->RMRK;
  369. m_pGDC->Values[nRow][Column99->Index] = (int)pObj;
  370. return true;
  371. }
  372. catch(...)
  373. {
  374. }
  375. return false;
  376. }
  377. //---------------------------------------------------------------------------
  378. bool __fastcall TIDB0070M::IsUpdate()
  379. {
  380. FOR_STL(TItsHoliday*, pObj, ItsHolidayManager->FLists)
  381. {
  382. if (pObj->Completed && pObj->EditMode != DB_INIT)
  383. return true;
  384. if (!pObj->Completed && pObj->EditMode == DB_NEW)
  385. return true;
  386. }
  387. return false;
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TIDB0070M::SaveData()
  391. {
  392. bool bSave = false;
  393. if (!IsUpdate()) return;
  394. if (!FUpdate)
  395. {
  396. if (Application->MessageBox(FrmLang->lblEidtConfirm->Caption.c_str(),//L"변경된 정보가 있습니다.\r\n변경된 정보를 저장 하시겠습니까?",
  397. FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  398. }
  399. TADOQuery *pADOI = NULL;
  400. TADOQuery *pADOU = NULL;
  401. TADOQuery *pADOD = NULL;
  402. String sQryI;
  403. String sQryU;
  404. String sQryD;
  405. int nEditMode;
  406. try
  407. {
  408. sQryI = "INSERT INTO TB_LEGL_HLDY_INFR ( \r\n"
  409. " YMD , \r\n"
  410. " DAY_TYPE_CD , \r\n"
  411. " LEGL_HLDY_NM, \r\n"
  412. " RMRK ) \r\n"
  413. " VALUES ( \r\n"
  414. " :p01, \r\n"
  415. " :p02, \r\n"
  416. " :p03, \r\n"
  417. " :p04 ) \r\n";
  418. sQryU = "UPDATE TB_LEGL_HLDY_INFR \r\n"
  419. " SET DAY_TYPE_CD = :p02, \r\n"
  420. " LEGL_HLDY_NM = :p03, \r\n"
  421. " RMRK = :p04 \r\n"
  422. " WHERE YMD = :p01 \r\n";
  423. sQryD = "DELETE TB_LEGL_HLDY_INFR \r\n"
  424. " WHERE YMD = :p01 \r\n";
  425. int nRow;
  426. TvList->BeginUpdate();
  427. try
  428. {
  429. pADOI = new TADOQuery(NULL);
  430. pADOI->Close();
  431. pADOI->Connection = ITSDb_GetConnection();
  432. pADOU = new TADOQuery(NULL);
  433. pADOU->Close();
  434. pADOU->Connection = ITSDb_GetConnection();
  435. pADOD = new TADOQuery(NULL);
  436. pADOD->Close();
  437. pADOD->Connection = ITSDb_GetConnection();
  438. ITSDb_SQLText(pADOI, sQryI);
  439. ITSDb_SQLText(pADOU, sQryU);
  440. ITSDb_SQLText(pADOD, sQryD);
  441. ITSDb_GetConnection()->BeginTrans();
  442. FOR_STL(TItsHoliday*, pObj, ItsHolidayManager->FLists)
  443. {
  444. if (pObj->GridIndex < 0) continue;
  445. if (pObj->Completed && pObj->EditMode == DB_INIT)
  446. continue;
  447. if (!pObj->Completed && pObj->EditMode != DB_NEW)
  448. continue;
  449. nRow = pObj->GridIndex;
  450. //String sDay = VarToStr(m_pGDC->Values[nRow][Column01->Index]);
  451. String sType = VarToStr(m_pGDC->Values[nRow][Column02->Index]);
  452. String sName = VarToStr(m_pGDC->Values[nRow][Column03->Index]);
  453. String sRmrk = VarToStr(m_pGDC->Values[nRow][Column04->Index]);
  454. sType = ITSUtil_GetCode(sType);
  455. //pObj->YMD = sDay;
  456. pObj->DAY_TYPE_CD = sType;
  457. pObj->LEGL_HLDY_NM = sName;
  458. pObj->RMRK = sRmrk;
  459. nEditMode = pObj->EditMode;
  460. if (pObj->Completed)
  461. {
  462. if (pObj->EditMode == DB_DELETE)
  463. {
  464. //delete
  465. ITSDb_SQLBind(pADOD, "p01", pObj->YMD);
  466. ITSDb_SQLExec(pADOD);
  467. pObj->DEL_YN = "Y";
  468. }
  469. else
  470. if (pObj->EditMode == DB_UPDATE)
  471. {
  472. //update
  473. ITSDb_SQLBind(pADOU, "p01", pObj->YMD);
  474. ITSDb_SQLBind(pADOU, "p02", pObj->DAY_TYPE_CD);
  475. ITSDb_SQLBind(pADOU, "p03", pObj->LEGL_HLDY_NM);
  476. ITSDb_SQLBind(pADOU, "p04", pObj->RMRK);
  477. ITSDb_SQLExec(pADOU);
  478. pObj->DEL_YN = "N";
  479. }
  480. }
  481. else
  482. {
  483. if (pObj->EditMode == DB_NEW)
  484. {
  485. //insert
  486. ITSDb_SQLBind(pADOI, "p01", pObj->YMD);
  487. ITSDb_SQLBind(pADOI, "p02", pObj->DAY_TYPE_CD);
  488. ITSDb_SQLBind(pADOI, "p03", pObj->LEGL_HLDY_NM);
  489. ITSDb_SQLBind(pADOI, "p04", pObj->RMRK);
  490. ITSDb_SQLExec(pADOI);
  491. pObj->DEL_YN = "N";
  492. }
  493. }
  494. pObj->Completed = true;
  495. }
  496. bSave = true;
  497. ITSDb_GetConnection()->CommitTrans();
  498. }
  499. catch(EDatabaseError &E)
  500. {
  501. ITSDb_GetConnection()->RollbackTrans();
  502. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  503. if (nEditMode == DB_DELETE)
  504. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQryD);
  505. else
  506. if (nEditMode == DB_UPDATE)
  507. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQryU);
  508. else
  509. if (nEditMode == DB_NEW)
  510. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQryI);
  511. throw Exception(String(E.ClassName()) + E.Message);
  512. }
  513. catch(Exception &e)
  514. {
  515. ITSDb_GetConnection()->RollbackTrans();
  516. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  517. if (nEditMode == DB_DELETE)
  518. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQryD);
  519. else
  520. if (nEditMode == DB_UPDATE)
  521. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQryU);
  522. else
  523. if (nEditMode == DB_NEW)
  524. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQryI);
  525. throw Exception(String(e.ClassName()) + e.Message);
  526. }
  527. }
  528. __finally
  529. {
  530. if (pADOI)
  531. {
  532. pADOI->Close();
  533. delete pADOI;
  534. }
  535. if (pADOU)
  536. {
  537. pADOU->Close();
  538. delete pADOU;
  539. }
  540. if (pADOD)
  541. {
  542. pADOD->Close();
  543. delete pADOD;
  544. }
  545. TvList->EndUpdate();
  546. }
  547. if (bSave)
  548. {
  549. Application->ProcessMessages();
  550. Application->MessageBox(FrmLang->lblDbSave->Caption.c_str(),//L"휴일정보를 저장 하였습니다.",
  551. FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  552. POST_MSG(Application->MainForm->Handle, WM_DATABASE_REFRESH, WP_MSG_04, 0);
  553. }
  554. }
  555. //---------------------------------------------------------------------------
  556. void __fastcall TIDB0070M::FormCloseQuery(TObject *Sender, bool &CanClose)
  557. {
  558. SaveData();
  559. }
  560. //---------------------------------------------------------------------------
  561. void __fastcall TIDB0070M::TvListKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
  562. {
  563. if (Key == VK_DELETE)
  564. {
  565. if (BtnDelete->Enabled) BtnDeleteClick(Sender);
  566. }
  567. }
  568. //---------------------------------------------------------------------------
  569. void __fastcall TIDB0070M::TvListDataControllerFilterChanged(TObject *Sender)
  570. {
  571. CMM_SetFilterLike(TvList);
  572. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  573. }
  574. //---------------------------------------------------------------------------
  575. void __fastcall TIDB0070M::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  576. bool &ADone)
  577. {
  578. if (AViewInfo)
  579. {
  580. String sType = AViewInfo->GridRecord->DisplayTexts[Column00->Index];
  581. if (sType == FrmLang->lblModify->Caption)//"수정")
  582. {
  583. ACanvas->Brush->Color = clOlive;
  584. }
  585. else if (sType == FrmLang->lblDelete->Caption)//"삭제")
  586. {
  587. ACanvas->Brush->Color = clRed;
  588. }
  589. else if (sType == FrmLang->lblNew->Caption)//"신규")
  590. {
  591. ACanvas->Brush->Color = clLime;
  592. if (AViewInfo->Focused) ACanvas->Font->Color = clBlack;
  593. }
  594. }
  595. }
  596. //---------------------------------------------------------------------------