IFM0050MF.cpp 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "IFM0050MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "FRAME_FailHndlF"
  12. #pragma link "cxButtons"
  13. #pragma link "cxCalc"
  14. #pragma link "cxCheckBox"
  15. #pragma link "cxClasses"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxCustomData"
  19. #pragma link "cxData"
  20. #pragma link "cxDataStorage"
  21. #pragma link "cxDropDownEdit"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxGroupBox"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxMaskEdit"
  34. #pragma link "cxPC"
  35. #pragma link "cxPCdxBarPopupMenu"
  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 resource "*.dfm"
  43. TIFM0050M *IFM0050M = NULL;
  44. //---------------------------------------------------------------------------
  45. __fastcall TIFM0050M::TIFM0050M(TComponent* Owner)
  46. : TForm(Owner)
  47. {
  48. ITSSkin_Load(this);
  49. CMM_LoadForm(g_sFormsDir, this);
  50. m_enJob1 = enJobNone;
  51. m_enJob2 = enJobNone;
  52. }
  53. //---------------------------------------------------------------------------
  54. /*
  55. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  56. * Form과 DataModule class를 delete시킨다.
  57. * arguments
  58. *
  59. * return
  60. * void
  61. */
  62. void __fastcall TIFM0050M::CommClose()
  63. {
  64. try
  65. {
  66. CMM_SaveForm(g_sFormsDir, this);
  67. }
  68. catch(...)
  69. {
  70. }
  71. }
  72. //---------------------------------------------------------------------------
  73. /*
  74. * Form을 보여줄때 호출되는 event 메서드이다.
  75. * arguments
  76. * Sender : event handler 객체
  77. * return
  78. * void
  79. */
  80. void __fastcall TIFM0050M::FormShow(TObject *Sender)
  81. {
  82. Refresh();
  83. FormInit();
  84. TmrShow->Enabled = true;
  85. }
  86. //---------------------------------------------------------------------------
  87. /*
  88. * form 초기화
  89. *
  90. * arguments
  91. *
  92. * return
  93. * void
  94. */
  95. void __fastcall TIFM0050M::FormInit()
  96. {
  97. m_pGDC1 = TvList1->DataController;
  98. m_pGDC2 = TvList2->DataController;
  99. TvList1->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<장애 장비 유형 정보가 없습니다>";
  100. TvList2->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<세부코드 정보가 없습니다>";
  101. EdId1->Enabled = false;
  102. EdId2->Enabled = false;
  103. FormClear1();
  104. FormClear2();
  105. ChangeButtonType1(1);
  106. ChangeButtonType2(1);
  107. }
  108. //---------------------------------------------------------------------------
  109. /*
  110. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  111. * arguments
  112. * Sender : event handler 객체
  113. * return
  114. * void
  115. */
  116. void __fastcall TIFM0050M::TmrShowTimer(TObject *Sender)
  117. {
  118. TmrShow->Enabled = false;
  119. BtnSearchClick((TObject*)BtnSearch);
  120. }
  121. //---------------------------------------------------------------------------
  122. /*
  123. * Search 버튼 클릭 이벤트 핸들러
  124. * arguments
  125. * Sender : event handler 객체
  126. * return
  127. * void
  128. */
  129. void __fastcall TIFM0050M::BtnSearchClick(TObject *Sender)
  130. {
  131. Application->ProcessMessages();
  132. TSqlCursor sqlCrs((TControl*)BtnSearch);
  133. FormClear1();
  134. FormClear2();
  135. RefreshData();
  136. CxList1->SetFocus();
  137. ChangeButtonType1(1);
  138. ChangeButtonType2(1);
  139. }
  140. //---------------------------------------------------------------------------
  141. /*
  142. * Refresh Data Event Function
  143. * arguments
  144. *
  145. * return
  146. * void
  147. */
  148. void __fastcall TIFM0050M::RefreshData()
  149. {
  150. SelListData1();
  151. }
  152. //---------------------------------------------------------------------------
  153. /*
  154. * form 입력 필드 Clear
  155. * arguments
  156. * return
  157. * void
  158. */
  159. void __fastcall TIFM0050M::FormClear1()
  160. {
  161. m_enJob1 = enJobNone;
  162. EdId1->Clear();
  163. EdMsgCd->Clear();
  164. EdKName1->Clear();
  165. EdEName1->Clear();
  166. EdRemark1->Clear();
  167. EdSysCd->Clear();
  168. CbUseYn1->ItemIndex = 0;
  169. EdCmmnClsfCd->Clear();
  170. EdCmmnClsfCdNm->Clear();
  171. FCode = NULL;
  172. }
  173. //---------------------------------------------------------------------------
  174. void __fastcall TIFM0050M::FormClear2()
  175. {
  176. m_enJob2 = enJobNone;
  177. EdId2->Clear();
  178. EdCdAbbr->Clear();
  179. EdKName2->Clear();
  180. EdEName2->Clear();
  181. EdRemark2->Clear();
  182. EdAtrb1->Clear();
  183. EdAtrb2->Clear();
  184. CbUseYn2->ItemIndex = 0;
  185. FSubCode = NULL;
  186. }
  187. //---------------------------------------------------------------------------
  188. /*
  189. * 작업유형에 따라 컴포넌트 활성/비활성
  190. * arguments
  191. *
  192. * return
  193. * void
  194. */
  195. void __fastcall TIFM0050M::ChangeButtonType1(int nBtnType)
  196. {
  197. if (nBtnType == 1)
  198. {
  199. BtnSave1->Visible = false;
  200. BtnCancel1->Visible = false;
  201. BtnInsert1->Visible = true;
  202. if (TvList1->ViewData->RecordCount > 0)
  203. {
  204. BtnEdit1->Visible = true;
  205. BtnDelete1->Visible = true;
  206. }
  207. else
  208. {
  209. BtnEdit1->Visible = false;
  210. BtnDelete1->Visible = false;
  211. }
  212. BtnSearch->Enabled = true;
  213. CxList1->Enabled = true;
  214. cxGroupBox1->Enabled = false;
  215. }
  216. else
  217. {
  218. BtnSave1->Visible = true;
  219. BtnCancel1->Visible = true;
  220. BtnInsert1->Visible = false;
  221. BtnEdit1->Visible = false;
  222. BtnDelete1->Visible = false;
  223. BtnSearch->Enabled = false;
  224. CxList1->Enabled = false;
  225. cxGroupBox1->Enabled = true;
  226. }
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TIFM0050M::ChangeButtonType2(int nBtnType)
  230. {
  231. if (nBtnType == 1)
  232. {
  233. BtnSave2->Visible = false;
  234. BtnCancel2->Visible = false;
  235. BtnInsert2->Visible = true;
  236. if (TvList2->ViewData->RecordCount > 0)
  237. {
  238. BtnEdit2->Visible = true;
  239. BtnDelete2->Visible = true;
  240. }
  241. else
  242. {
  243. BtnEdit2->Visible = false;
  244. BtnDelete2->Visible = false;
  245. }
  246. CxList2->Enabled = true;
  247. cxGroupBox2->Enabled = false;
  248. }
  249. else
  250. {
  251. BtnSave2->Visible = true;
  252. BtnCancel2->Visible = true;
  253. BtnInsert2->Visible = false;
  254. BtnEdit2->Visible = false;
  255. BtnDelete2->Visible = false;
  256. CxList2->Enabled = false;
  257. CxList2->Enabled = false;
  258. cxGroupBox2->Enabled = true;
  259. }
  260. }
  261. //---------------------------------------------------------------------------
  262. void __fastcall TIFM0050M::SelListData1()
  263. {
  264. CMM_ClearGridTableView(TvList1);
  265. CMM_ClearGridTableView(TvList2);
  266. int nRow = 0;
  267. try
  268. {
  269. TvList1->BeginUpdate();
  270. FOR_STL(TItsCode *, pCode, ItsCodeManager->FLists)
  271. {
  272. nRow = m_pGDC1->AppendRecord();
  273. m_pGDC1->Values[nRow][MColumn01->Index] = "-"; //편집모드
  274. m_pGDC1->Values[nRow][MColumn02->Index] = pCode->CMMN_CLSF_CD; //공통 분류 코드
  275. m_pGDC1->Values[nRow][MColumn03->Index] = pCode->MSG_TYPE_CD; //메시지 유형 코드
  276. m_pGDC1->Values[nRow][MColumn04->Index] = pCode->CMMN_CLSF_KOR_NM; //공통 분류 한글 명
  277. m_pGDC1->Values[nRow][MColumn05->Index] = pCode->CMMN_CLSF_ENGL_NM; //공통 분류 영문 명
  278. m_pGDC1->Values[nRow][MColumn06->Index] = pCode->USE_SYST_CD; //사용 시스템 코드
  279. m_pGDC1->Values[nRow][MColumn07->Index] = pCode->RMRK; //비고
  280. m_pGDC1->Values[nRow][MColumn08->Index] = pCode->USE_YN; //사용 여부
  281. m_pGDC1->Values[nRow][MColumn09->Index] = pCode->FRST_REGR_NMBR; //최초 등록자 번호
  282. m_pGDC1->Values[nRow][MColumn10->Index] = pCode->FRST_RGST_DT; //최초 등록 일시
  283. m_pGDC1->Values[nRow][MColumn11->Index] = pCode->LAST_CRPR_NMBR; //최종 수정자 번호
  284. m_pGDC1->Values[nRow][MColumn12->Index] = pCode->LAST_CRCT_DT; //최종 수정 일시
  285. m_pGDC1->Values[nRow][MColumn98->Index] = (int)pCode;
  286. }
  287. }
  288. __finally
  289. {
  290. TvList1->EndUpdate();
  291. TvList1->DataController->GotoFirst();
  292. TvList1->DataController->FocusedRecordIndex = 0;
  293. }
  294. }
  295. //---------------------------------------------------------------------------
  296. void __fastcall TIFM0050M::SelListData2()
  297. {
  298. CMM_ClearGridTableView(TvList2);
  299. if (TvList1->ViewData->RecordCount <= 0) return;
  300. int nIndex = m_pGDC1->FocusedRecordIndex;
  301. if (nIndex < 0) return;
  302. int nMemPtr = m_pGDC1->Values[nIndex][MColumn98->Index];
  303. if (nMemPtr == 0) return;
  304. TItsCode *pCode = (TItsCode *)nMemPtr;
  305. int nRow = 0;
  306. try
  307. {
  308. TvList2->BeginUpdate();
  309. FOR_STL(TItsSubCode *, pSubCode, pCode->FSubLists)
  310. {
  311. nRow = m_pGDC2->AppendRecord();
  312. m_pGDC2->Values[nRow][SColumn01->Index] = "-"; //편집모드
  313. m_pGDC2->Values[nRow][SColumn02->Index] = pSubCode->CMMN_CD;
  314. m_pGDC2->Values[nRow][SColumn03->Index] = pSubCode->CMMN_CD_KOR_NM;
  315. m_pGDC2->Values[nRow][SColumn04->Index] = pSubCode->CMMN_CD_ENGL_NM;
  316. m_pGDC2->Values[nRow][SColumn05->Index] = pSubCode->CMMN_CD_ABBR;
  317. m_pGDC2->Values[nRow][SColumn06->Index] = pSubCode->RMRK;
  318. m_pGDC2->Values[nRow][SColumn07->Index] = pSubCode->ATRB1;
  319. m_pGDC2->Values[nRow][SColumn08->Index] = pSubCode->ATRB2;
  320. m_pGDC2->Values[nRow][SColumn09->Index] = pSubCode->USE_YN;
  321. m_pGDC2->Values[nRow][SColumn10->Index] = pSubCode->FRST_REGR_NMBR;
  322. m_pGDC2->Values[nRow][SColumn11->Index] = pSubCode->FRST_RGST_DT;
  323. m_pGDC2->Values[nRow][SColumn12->Index] = pSubCode->LAST_CRPR_NMBR;
  324. m_pGDC2->Values[nRow][SColumn13->Index] = pSubCode->LAST_CRCT_DT;
  325. m_pGDC2->Values[nRow][SColumn98->Index] = (int)pSubCode;
  326. }
  327. }
  328. __finally
  329. {
  330. TvList2->EndUpdate();
  331. TvList2->DataController->GotoFirst();
  332. TvList2->DataController->FocusedRecordIndex = 0;
  333. }
  334. }
  335. //---------------------------------------------------------------------------
  336. /*
  337. * Close 버튼 클릭 이벤트 핸들러
  338. * arguments
  339. * Sender : event handler 객체
  340. * return
  341. * void
  342. */
  343. void __fastcall TIFM0050M::BtnCloseClick(TObject *Sender)
  344. {
  345. Close();
  346. }
  347. //---------------------------------------------------------------------------
  348. /*
  349. * 저장 버튼 클릭 이벤트 핸들러
  350. * arguments
  351. * Sender : event handler 객체
  352. * return
  353. * void
  354. */
  355. void __fastcall TIFM0050M::BtnSaveClick(TObject *Sender)
  356. {
  357. bool bMemDel = true;
  358. String sMsgTitle, sMsgString;
  359. TcxButton *pBtn = (TcxButton*)Sender;
  360. if (pBtn->Tag == 0)
  361. {
  362. TItsCode *pCode = new TItsCode();
  363. try
  364. {
  365. pCode->CMMN_CLSF_CD = EdId1->Text.Trim();
  366. pCode->MSG_TYPE_CD = EdMsgCd->Text.Trim();
  367. pCode->CMMN_CLSF_KOR_NM = EdKName1->Text.Trim();
  368. pCode->CMMN_CLSF_ENGL_NM = EdEName1->Text.Trim();
  369. pCode->USE_SYST_CD = EdSysCd->Text.Trim();
  370. pCode->RMRK = EdRemark1->Text.Trim();
  371. pCode->USE_YN = (CbUseYn1->ItemIndex == 0) ? "Y" : "N";
  372. //pCode->FRST_REGR_NMBR = pCode->FFRST_REGR_NMBR;
  373. //pCode->FRST_RGST_DT = pCode->FFRST_RGST_DT;
  374. //pCode->LAST_CRPR_NMBR = pCode->FLAST_CRPR_NMBR;
  375. //pCode->LAST_CRCT_DT = pCode->FLAST_CRCT_DT;
  376. if (m_enJob1 == enJobSave) sMsgTitle = "대표코드 정보 등록";
  377. sMsgTitle = "대표코드 정보 수정";
  378. if (MergeCmmnClsfCd(pCode))
  379. {
  380. if (m_enJob1 == enJobSave)
  381. {
  382. ItsCodeManager->FLists.Push(pCode->CMMN_CLSF_CD, pCode);
  383. pCode->Completed = true;
  384. bMemDel = false;
  385. }
  386. else
  387. {
  388. //FCode->CMMN_CLSF_CD = EdId1->Text.Trim();
  389. FCode->MSG_TYPE_CD = EdMsgCd->Text.Trim();
  390. FCode->CMMN_CLSF_KOR_NM = EdKName1->Text.Trim();
  391. FCode->CMMN_CLSF_ENGL_NM = EdEName1->Text.Trim();
  392. FCode->USE_SYST_CD = EdSysCd->Text.Trim();
  393. FCode->RMRK = EdRemark1->Text.Trim();
  394. FCode->USE_YN = (CbUseYn1->ItemIndex == 0) ? "Y" : "N";
  395. }
  396. RefreshData();
  397. CMM_SetGridFocusRow(CxList1, TvList1, pCode->CMMN_CLSF_CD, MColumn02->Index);
  398. DisplayListData1();
  399. ChangeButtonType1(1);
  400. Application->MessageBox(String(sMsgTitle + " 하였습니다.").c_str(), sMsgTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  401. }
  402. }
  403. __finally
  404. {
  405. if (bMemDel)
  406. {
  407. if (pCode) delete pCode;
  408. }
  409. }
  410. }
  411. else
  412. if (pBtn->Tag == 1)
  413. {
  414. TItsSubCode *pSubCode = new TItsSubCode();
  415. try
  416. {
  417. pSubCode->CMMN_CD = EdId2->Text.Trim();
  418. pSubCode->CMMN_CLSF_CD = FCode->CMMN_CLSF_CD;
  419. pSubCode->CMMN_CD_KOR_NM = EdKName2->Text.Trim();
  420. pSubCode->CMMN_CD_ENGL_NM = EdEName2->Text.Trim();
  421. pSubCode->CMMN_CD_ABBR = EdCdAbbr->Text.Trim();
  422. pSubCode->RMRK = EdRemark2->Text.Trim();
  423. pSubCode->ATRB1 = EdAtrb1->Text.Trim();
  424. pSubCode->ATRB2 = EdAtrb2->Text.Trim();
  425. pSubCode->USE_YN = (CbUseYn2->ItemIndex == 0) ? "Y" : "N";
  426. //pSubCode->FRST_REGR_NMBR = pSubCode->FFRST_REGR_NMBR;
  427. //pSubCode->FRST_RGST_DT = pSubCode->FFRST_RGST_DT;
  428. //pSubCode->LAST_CRPR_NMBR = pSubCode->FLAST_CRPR_NMBR;
  429. //pSubCode->LAST_CRCT_DT = pSubCode->FLAST_CRCT_DT;
  430. if (m_enJob2 == enJobSave) sMsgTitle = "세부코드 정보 등록";
  431. else sMsgTitle = "세부코드 정보 수정";
  432. if (MergeCmmnCd(pSubCode))
  433. {
  434. if (m_enJob2 == enJobSave)
  435. {
  436. FCode->FSubLists.Push(pSubCode->CMMN_CD, pSubCode);
  437. pSubCode->Completed = true;
  438. bMemDel = false;
  439. }
  440. else
  441. {
  442. //FSubCode->CMMN_CD = EdId2->Text.Trim();
  443. //FSubCode->CMMN_CLSF_CD = FCode->CMMN_CLSF_CD;
  444. FSubCode->CMMN_CD_KOR_NM = EdKName2->Text.Trim();
  445. FSubCode->CMMN_CD_ENGL_NM = EdEName2->Text.Trim();
  446. FSubCode->CMMN_CD_ABBR = EdCdAbbr->Text.Trim();
  447. FSubCode->RMRK = EdRemark2->Text.Trim();
  448. FSubCode->ATRB1 = EdAtrb1->Text.Trim();
  449. FSubCode->ATRB2 = EdAtrb2->Text.Trim();
  450. FSubCode->USE_YN = (CbUseYn2->ItemIndex == 0) ? "Y" : "N";
  451. }
  452. SelListData2();
  453. CMM_SetGridFocusRow(CxList2, TvList2, pSubCode->CMMN_CD, SColumn02->Index);
  454. DisplayListData2();
  455. ChangeButtonType2(1);
  456. Application->MessageBox(String(sMsgTitle + " 하였습니다.").c_str(), sMsgTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  457. }
  458. }
  459. __finally
  460. {
  461. if (bMemDel)
  462. {
  463. if (pSubCode) delete pSubCode;
  464. }
  465. }
  466. }
  467. }
  468. //---------------------------------------------------------------------------
  469. bool __fastcall TIFM0050M::MergeCmmnClsfCd(TItsCode *pCode)
  470. {
  471. bool bResult = false;
  472. String sQry;
  473. TADOQuery *pADO = NULL;
  474. sQry = "MERGE INTO TB_CMMN_CLSF_CD L \r\n"
  475. "USING (SELECT :p01 AS CMMN_CLSF_CD, \r\n"
  476. " :p02 AS MSG_TYPE_CD, \r\n"
  477. " :p03 AS CMMN_CLSF_KOR_NM, \r\n"
  478. " :p04 AS CMMN_CLSF_ENGL_NM, \r\n"
  479. " :p05 AS USE_SYST_CD, \r\n"
  480. " :p06 AS RMRK, \r\n"
  481. " :p07 AS USE_YN \r\n"
  482. " FROM DUAL \r\n"
  483. " ) M \r\n"
  484. "ON (L.CMMN_CLSF_CD = M.CMMN_CLSF_CD) \r\n"
  485. "WHEN MATCHED THEN \r\n"
  486. " UPDATE SET L.MSG_TYPE_CD = M.MSG_TYPE_CD, \r\n"
  487. " L.CMMN_CLSF_KOR_NM = M.CMMN_CLSF_KOR_NM, \r\n"
  488. " L.CMMN_CLSF_ENGL_NM = M.CMMN_CLSF_ENGL_NM, \r\n"
  489. " L.USE_SYST_CD = M.USE_SYST_CD, \r\n"
  490. " L.RMRK = M.RMRK, \r\n"
  491. " L.USE_YN = M.USE_YN \r\n"
  492. "WHEN NOT MATCHED THEN \r\n"
  493. " INSERT (L.CMMN_CLSF_CD, \r\n"
  494. " L.MSG_TYPE_CD, \r\n"
  495. " L.CMMN_CLSF_KOR_NM, \r\n"
  496. " L.CMMN_CLSF_ENGL_NM, \r\n"
  497. " L.USE_SYST_CD, \r\n"
  498. " L.RMRK, \r\n"
  499. " L.USE_YN) \r\n"
  500. " VALUES (M.CMMN_CLSF_CD, \r\n"
  501. " M.MSG_TYPE_CD, \r\n"
  502. " M.CMMN_CLSF_KOR_NM, \r\n"
  503. " M.CMMN_CLSF_ENGL_NM, \r\n"
  504. " M.USE_SYST_CD, \r\n"
  505. " M.RMRK, \r\n"
  506. " M.USE_YN) \r\n";
  507. try
  508. {
  509. try
  510. {
  511. pADO = new TADOQuery(NULL);
  512. pADO->Close();
  513. pADO->Connection = ITSDb_GetConnection();
  514. ITSDb_SQLText(pADO, sQry);
  515. ITSDb_SQLBind(pADO, "p01", pCode->CMMN_CLSF_CD);
  516. ITSDb_SQLBind(pADO, "p02", pCode->MSG_TYPE_CD);
  517. ITSDb_SQLBind(pADO, "p03", pCode->CMMN_CLSF_KOR_NM);
  518. ITSDb_SQLBind(pADO, "p04", pCode->CMMN_CLSF_ENGL_NM);
  519. ITSDb_SQLBind(pADO, "p05", pCode->USE_SYST_CD);
  520. ITSDb_SQLBind(pADO, "p06", pCode->RMRK);
  521. ITSDb_SQLBind(pADO, "p07", pCode->USE_YN);
  522. ITSDb_GetConnection()->BeginTrans();
  523. ITSDb_SQLExec(pADO);
  524. ITSDb_GetConnection()->CommitTrans();
  525. bResult = true;
  526. }
  527. catch(EDatabaseError &E)
  528. {
  529. ITSDb_GetConnection()->RollbackTrans();
  530. ShowMessage(String(E.ClassName()) + E.Message);
  531. }
  532. catch(Exception &exception)
  533. {
  534. ITSDb_GetConnection()->RollbackTrans();
  535. ShowMessage(String(exception.ClassName()) + exception.Message);
  536. }
  537. catch(...)
  538. {
  539. ITSDb_GetConnection()->RollbackTrans();
  540. ShowMessage(FrmLang->lblDbErr->Caption);//"데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
  541. }
  542. }
  543. __finally
  544. {
  545. if (pADO)
  546. {
  547. pADO->Close();
  548. delete pADO;
  549. }
  550. }
  551. return bResult;
  552. }
  553. //---------------------------------------------------------------------------
  554. bool __fastcall TIFM0050M::MergeCmmnCd(TItsSubCode *pSubCode)
  555. {
  556. bool bResult = false;
  557. String sQry;
  558. TADOQuery *pADO = NULL;
  559. sQry = "MERGE INTO TB_CMMN_CD L \r\n"
  560. "USING (SELECT :p01 AS CMMN_CD, \r\n"
  561. " :p02 AS CMMN_CLSF_CD, \r\n"
  562. " :p03 AS CMMN_CD_KOR_NM, \r\n"
  563. " :p04 AS CMMN_CD_ENGL_NM, \r\n"
  564. " :p05 AS CMMN_CD_ABBR, \r\n"
  565. " :p06 AS RMRK, \r\n"
  566. " :p07 AS ATRB1, \r\n"
  567. " :p08 AS ATRB2, \r\n"
  568. " :p09 AS USE_YN \r\n"
  569. " FROM DUAL \r\n"
  570. " ) M \r\n"
  571. "ON ( L.CMMN_CD = M.CMMN_CD \r\n"
  572. " AND L.CMMN_CLSF_CD = M.CMMN_CLSF_CD) \r\n"
  573. "WHEN MATCHED THEN \r\n"
  574. " UPDATE SET L.CMMN_CD_KOR_NM = M.CMMN_CD_KOR_NM, \r\n"
  575. " L.CMMN_CD_ENGL_NM = M.CMMN_CD_ENGL_NM, \r\n"
  576. " L.CMMN_CD_ABBR = M.CMMN_CD_ABBR, \r\n"
  577. " L.RMRK = M.RMRK, \r\n"
  578. " L.ATRB1 = M.ATRB1, \r\n"
  579. " L.ATRB2 = M.ATRB2, \r\n"
  580. " L.USE_YN = M.USE_YN \r\n"
  581. "WHEN NOT MATCHED THEN \r\n"
  582. " INSERT (L.CMMN_CD, \r\n"
  583. " L.CMMN_CLSF_CD, \r\n"
  584. " L.CMMN_CD_KOR_NM, \r\n"
  585. " L.CMMN_CD_ENGL_NM, \r\n"
  586. " L.CMMN_CD_ABBR, \r\n"
  587. " L.RMRK, \r\n"
  588. " L.ATRB1, \r\n"
  589. " L.ATRB2, \r\n"
  590. " L.USE_YN) \r\n"
  591. " VALUES (M.CMMN_CD, \r\n"
  592. " M.CMMN_CLSF_CD, \r\n"
  593. " M.CMMN_CD_KOR_NM, \r\n"
  594. " M.CMMN_CD_ENGL_NM, \r\n"
  595. " M.CMMN_CD_ABBR, \r\n"
  596. " M.RMRK, \r\n"
  597. " M.ATRB1, \r\n"
  598. " M.ATRB2, \r\n"
  599. " M.USE_YN) \r\n";
  600. try
  601. {
  602. try
  603. {
  604. pADO = new TADOQuery(NULL);
  605. pADO->Close();
  606. pADO->Connection = ITSDb_GetConnection();
  607. ITSDb_SQLText(pADO, sQry);
  608. ITSDb_SQLBind(pADO, "p01", pSubCode->CMMN_CD);
  609. ITSDb_SQLBind(pADO, "p02", pSubCode->CMMN_CLSF_CD);
  610. ITSDb_SQLBind(pADO, "p03", pSubCode->CMMN_CD_KOR_NM);
  611. ITSDb_SQLBind(pADO, "p04", pSubCode->CMMN_CD_ENGL_NM);
  612. ITSDb_SQLBind(pADO, "p05", pSubCode->CMMN_CD_ABBR);
  613. ITSDb_SQLBind(pADO, "p06", pSubCode->RMRK);
  614. ITSDb_SQLBind(pADO, "p07", pSubCode->ATRB1);
  615. ITSDb_SQLBind(pADO, "p08", pSubCode->ATRB2);
  616. ITSDb_SQLBind(pADO, "p09", pSubCode->USE_YN);
  617. ITSDb_GetConnection()->BeginTrans();
  618. ITSDb_SQLExec(pADO);
  619. ITSDb_GetConnection()->CommitTrans();
  620. bResult = true;
  621. }
  622. catch(EDatabaseError &E)
  623. {
  624. ITSDb_GetConnection()->RollbackTrans();
  625. ShowMessage(String(E.ClassName()) + E.Message);
  626. }
  627. catch(Exception &exception)
  628. {
  629. ITSDb_GetConnection()->RollbackTrans();
  630. ShowMessage(String(exception.ClassName()) + exception.Message);
  631. }
  632. catch(...)
  633. {
  634. ITSDb_GetConnection()->RollbackTrans();
  635. ShowMessage(FrmLang->lblDbErr->Caption);//"데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
  636. }
  637. }
  638. __finally
  639. {
  640. if (pADO)
  641. {
  642. pADO->Close();
  643. delete pADO;
  644. }
  645. }
  646. return bResult;
  647. }
  648. //---------------------------------------------------------------------------
  649. /*
  650. * 취소 버튼 클릭 이벤트 핸들러
  651. * arguments
  652. * Sender : event handler 객체
  653. * return
  654. * void
  655. */
  656. void __fastcall TIFM0050M::BtnCancelClick(TObject *Sender)
  657. {
  658. TcxButton *pBtn = (TcxButton*)Sender;
  659. if (pBtn->Tag == 0)
  660. {
  661. ChangeButtonType1(1);
  662. m_enJob1 = enJobNone;
  663. DisplayListData1();
  664. }
  665. else
  666. if (pBtn->Tag == 1)
  667. {
  668. ChangeButtonType2(1);
  669. m_enJob2 = enJobNone;
  670. DisplayListData2();
  671. }
  672. }
  673. //---------------------------------------------------------------------------
  674. /*
  675. * 등록 버튼 클릭 이벤트 핸들러
  676. * arguments
  677. * Sender : event handler 객체
  678. * return
  679. * void
  680. */
  681. void __fastcall TIFM0050M::BtnInsertClick(TObject *Sender)
  682. {
  683. String sErrMsg = "";
  684. String sId = "";
  685. TcxButton *pBtn = (TcxButton*)Sender;
  686. if (pBtn->Tag == 0)
  687. {
  688. sId = InputBox("대표코드", "새로운 대표코드를 입력하세요.\r\n입력후에는 수정이 불가능합니다.", "최대5자리");
  689. sId.Trim();
  690. if (sId.IsEmpty() || AnsiString(sId).Length() > 5 || sId == "최대5자리")
  691. {
  692. Application->MessageBox(L"5자리를 초과하였거나 값이 없습니다.", L"대표코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  693. return;
  694. }
  695. TItsCode *pCode = ItsCodeManager->FLists.Find(sId);
  696. if (pCode)
  697. {
  698. sErrMsg = "[" + sId + "] 코드는 이미 사용 중인 코드입니다.\r\n다른 코드를 입력하세요.";
  699. Application->MessageBox(sErrMsg.c_str(), L"대표코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  700. return;
  701. }
  702. ChangeButtonType1(2);
  703. FormClear1();
  704. FormClear2();
  705. EdId1->Text = sId;
  706. m_enJob1 = enJobSave;
  707. }
  708. else
  709. if (pBtn->Tag == 1)
  710. {
  711. if (m_pGDC1->FocusedRecordIndex < 0)
  712. {
  713. Application->MessageBox(L"대표코드를 선택후 사용해주십시오.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  714. return;
  715. }
  716. if (!FCode)
  717. {
  718. Application->MessageBox(L"대표코드를 선택후 사용해주십시오.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  719. return;
  720. }
  721. sId = InputBox("세부코드", "새로운 세부코드를 입력하세요.\r\n입력후에는 수정이 불가능합니다.", "최대7자리");
  722. sId.Trim();
  723. if (sId.IsEmpty() || AnsiString(sId).Length() > 5 || sId == "최대7자리")
  724. {
  725. Application->MessageBox(L"7자리를 초과하였거나 값이 없습니다.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  726. return;
  727. }
  728. TItsSubCode *pSubCode = FCode->FSubLists.Find(sId);
  729. if (pSubCode)
  730. {
  731. sErrMsg = "[" + sId + "] 코드는 이미 사용 중인 코드입니다.\r\n다른 코드를 입력하세요.";
  732. Application->MessageBox(sErrMsg.c_str(), L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  733. return;
  734. }
  735. ChangeButtonType2(2);
  736. FormClear2();
  737. EdId2->Text = sId;
  738. m_enJob2 = enJobSave;
  739. }
  740. }
  741. //---------------------------------------------------------------------------
  742. /*
  743. * 수정 버튼 클릭 이벤트 핸들러
  744. * arguments
  745. * Sender : event handler 객체
  746. * return
  747. * void
  748. */
  749. void __fastcall TIFM0050M::BtnEditClick(TObject *Sender)
  750. {
  751. TcxButton *pBtn = (TcxButton*)Sender;
  752. if (pBtn->Tag == 0)
  753. {
  754. ChangeButtonType1(2);
  755. m_enJob1 = enJobEdit;
  756. }
  757. else
  758. if (pBtn->Tag == 1)
  759. {
  760. ChangeButtonType2(2);
  761. m_enJob2 = enJobEdit;
  762. }
  763. }
  764. //---------------------------------------------------------------------------
  765. /*
  766. * 삭제 버튼 클릭 이벤트 핸들러
  767. * arguments
  768. * Sender : event handler 객체
  769. * return
  770. * void
  771. */
  772. void __fastcall TIFM0050M::BtnDeleteClick(TObject *Sender)
  773. {
  774. TcxButton *pBtn = (TcxButton*)Sender;
  775. if (pBtn->Tag == 0)
  776. {
  777. DeleteData1();
  778. }
  779. else
  780. if (pBtn->Tag == 1)
  781. {
  782. DeleteData2();
  783. }
  784. }
  785. //---------------------------------------------------------------------------
  786. void __fastcall TIFM0050M::DeleteData1()
  787. {
  788. TADOQuery *pADO = NULL;
  789. String sQry;
  790. String sMsgString;
  791. if (TvList1->ViewData->RecordCount <= 0) return;
  792. if (TvList1->DataController->FocusedRecordIndex < 0) return;
  793. if (!FCode)
  794. {
  795. return;
  796. }
  797. sMsgString = "대표코드 정보를 삭제 하시겠습니까?\r\n세부코드 정보도 함께 삭제 됩니다." ;
  798. if (Application->MessageBox(sMsgString.c_str(), L"코드 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  799. String sCode = FCode->CMMN_CLSF_CD;
  800. try
  801. {
  802. try
  803. {
  804. pADO = new TADOQuery(NULL);
  805. pADO->Close();
  806. pADO->Connection = ITSDb_GetConnection();
  807. ITSDb_GetConnection()->BeginTrans();
  808. // 세부코드 삭제
  809. sQry = "DELETE FROM TB_CMMN_CD \r\n"
  810. " WHERE CMMN_CLSF_CD = :p01 \r\n";
  811. ITSDb_SQLText(pADO, sQry);
  812. ITSDb_SQLBind(pADO, "p01", sCode);
  813. ITSDb_SQLExec(pADO);
  814. // 대분류 코드 삭제
  815. sQry = "DELETE FROM TB_CMMN_CLSF_CD \r\n"
  816. " WHERE CMMN_CLSF_CD = :p01 \r\n";
  817. ITSDb_SQLText(pADO, sQry);
  818. ITSDb_SQLBind(pADO, "p01", sCode);
  819. ITSDb_SQLExec(pADO);
  820. ITSDb_GetConnection()->CommitTrans();
  821. ItsCodeManager->FLists.Remove(sCode);
  822. Application->MessageBox(L"대표코드와 세부코드 정보를 삭제하였습니다.", L"코드 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  823. }
  824. catch(EDatabaseError &E)
  825. {
  826. ITSDb_GetConnection()->RollbackTrans();
  827. ShowMessage(String(E.ClassName()) + E.Message);
  828. }
  829. catch(Exception &exception)
  830. {
  831. ITSDb_GetConnection()->RollbackTrans();
  832. ShowMessage(String(exception.ClassName()) + exception.Message);
  833. }
  834. catch(...)
  835. {
  836. ITSDb_GetConnection()->RollbackTrans();
  837. ShowMessage(FrmLang->lblDbDelErr->Caption);//"데이터 삭제 중에 알수없는 DB 오류가 발생하였습니다.");
  838. }
  839. }
  840. __finally
  841. {
  842. if (pADO)
  843. {
  844. pADO->Close();
  845. delete pADO;
  846. }
  847. }
  848. BtnSearchClick(NULL);
  849. }
  850. //---------------------------------------------------------------------------
  851. void __fastcall TIFM0050M::DeleteData2()
  852. {
  853. TADOQuery *pADO = NULL;
  854. String sQry;
  855. String sMsgString;
  856. if (TvList2->ViewData->RecordCount <= 0) return;
  857. if (TvList2->DataController->FocusedRecordIndex < 0) return;
  858. if (!FCode || !FSubCode)
  859. {
  860. return;
  861. }
  862. sMsgString = "세부코드 정보를 삭제 하시겠습니까?" ;
  863. if (Application->MessageBox(sMsgString.c_str(), L"세부코드 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  864. String sSubCode = FSubCode->CMMN_CD;
  865. String sCode = FSubCode->CMMN_CLSF_CD;
  866. try
  867. {
  868. try
  869. {
  870. pADO = new TADOQuery(NULL);
  871. pADO->Close();
  872. pADO->Connection = ITSDb_GetConnection();
  873. // 세부코드 삭제
  874. sQry = "DELETE FROM TB_CMMN_CD \r\n"
  875. " WHERE CMMN_CD = :p01 \r\n"
  876. " AND CMMN_CLSF_CD = :p02 \r\n";
  877. ITSDb_SQLText(pADO, sQry);
  878. ITSDb_SQLBind(pADO, "p01", sSubCode);
  879. ITSDb_SQLBind(pADO, "p02", sCode);
  880. ITSDb_SQLExec(pADO);
  881. ITSDb_GetConnection()->CommitTrans();
  882. ITSDb_GetConnection()->BeginTrans();
  883. FCode->FSubLists.Remove(sSubCode);
  884. Application->MessageBox(L"세부코드 정보를 삭제하였습니다.", L"세부코드 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  885. }
  886. catch(EDatabaseError &E)
  887. {
  888. ITSDb_GetConnection()->RollbackTrans();
  889. ShowMessage(String(E.ClassName()) + E.Message);
  890. }
  891. catch(Exception &exception)
  892. {
  893. ITSDb_GetConnection()->RollbackTrans();
  894. ShowMessage(String(exception.ClassName()) + exception.Message);
  895. }
  896. }
  897. __finally
  898. {
  899. if (pADO)
  900. {
  901. pADO->Close();
  902. delete pADO;
  903. }
  904. }
  905. SelListData2();
  906. DisplayListData2();
  907. ChangeButtonType2(1);
  908. }
  909. //---------------------------------------------------------------------------
  910. void __fastcall TIFM0050M::TvList1FocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
  911. TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
  912. {
  913. DisplayListData1();
  914. SelListData2();
  915. ChangeButtonType2(1);
  916. }
  917. //---------------------------------------------------------------------------
  918. void __fastcall TIFM0050M::TvList2FocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
  919. TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
  920. {
  921. DisplayListData2();
  922. }
  923. //---------------------------------------------------------------------------
  924. void __fastcall TIFM0050M::DisplayListData1()
  925. {
  926. int ii;
  927. FormClear1();
  928. if (TvList1->ViewData->RecordCount <= 0) return;
  929. int nIndex = m_pGDC1->FocusedRecordIndex;
  930. if (nIndex < 0) return;
  931. int nMemPtr = m_pGDC1->Values[nIndex][MColumn98->Index];
  932. if (nMemPtr == 0) return;
  933. FCode = (TItsCode *)nMemPtr;
  934. try
  935. {
  936. EdId1->Text = FCode->CMMN_CLSF_CD;
  937. EdMsgCd->Text = FCode->MSG_TYPE_CD;
  938. EdKName1->Text = FCode->CMMN_CLSF_KOR_NM;
  939. EdEName1->Text = FCode->CMMN_CLSF_ENGL_NM;
  940. EdRemark1->Text = FCode->RMRK;
  941. EdSysCd->Text = FCode->USE_SYST_CD;
  942. CbUseYn1->ItemIndex = FCode->USE_YN == "Y" ? 0 : 1;
  943. EdCmmnClsfCd->Text = FCode->CMMN_CLSF_CD;
  944. EdCmmnClsfCdNm->Text= FCode->CMMN_CLSF_KOR_NM;
  945. }
  946. catch(Exception &e)
  947. {
  948. Application->MessageBox((e.Message + " - " +__FILE__+ " - " +__LINE__).c_str(), Caption.c_str(), MB_OK);
  949. }
  950. }
  951. //---------------------------------------------------------------------------
  952. void __fastcall TIFM0050M::DisplayListData2()
  953. {
  954. FormClear2();
  955. if (TvList2->ViewData->RecordCount <= 0) return;
  956. int nIndex = m_pGDC2->FocusedRecordIndex;
  957. if (nIndex < 0) return;
  958. int nMemPtr = m_pGDC2->Values[nIndex][SColumn98->Index];
  959. if (nMemPtr == 0) return;
  960. FSubCode = (TItsSubCode *)nMemPtr;
  961. try
  962. {
  963. EdId2->Text = FSubCode->CMMN_CD;
  964. EdCdAbbr->Text = FSubCode->CMMN_CD_ABBR;
  965. EdKName2->Text = FSubCode->CMMN_CD_KOR_NM;
  966. EdEName2->Text = FSubCode->CMMN_CD_ENGL_NM;
  967. EdRemark2->Text = FSubCode->RMRK;
  968. EdAtrb1->Text = FSubCode->ATRB1;
  969. EdAtrb2->Text = FSubCode->ATRB2;
  970. CbUseYn2->ItemIndex = FSubCode->USE_YN == "Y" ? 0 : 1;
  971. }
  972. catch(Exception &e)
  973. {
  974. Application->MessageBox((e.Message + " - " +__FILE__+ " - " +__LINE__).c_str(), Caption.c_str(), MB_OK);
  975. }
  976. }
  977. //---------------------------------------------------------------------------
  978. void __fastcall TIFM0050M::FormClose(TObject *Sender, TCloseAction &Action)
  979. {
  980. CommClose();
  981. IFM0050M = NULL;
  982. Action = caFree;
  983. }
  984. //---------------------------------------------------------------------------