IDB0080MF.cpp 35 KB

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