IDB0080MF.cpp 35 KB

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