123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #pragma hdrstop
- #include "IFM0050MF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "FRAME_FailHndlF"
- #pragma link "cxButtons"
- #pragma link "cxCalc"
- #pragma link "cxCheckBox"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxDropDownEdit"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxGroupBox"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxMaskEdit"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- TIFM0050M *IFM0050M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TIFM0050M::TIFM0050M(TComponent* Owner)
- : TForm(Owner)
- {
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- m_enJob1 = enJobNone;
- m_enJob2 = enJobNone;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::FormShow(TObject *Sender)
- {
- Refresh();
- FormInit();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::FormInit()
- {
- m_pGDC1 = TvList1->DataController;
- m_pGDC2 = TvList2->DataController;
- TvList1->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<장애 장비 유형 정보가 없습니다>";
- TvList2->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<세부코드 정보가 없습니다>";
- EdId1->Enabled = false;
- EdId2->Enabled = false;
- FormClear1();
- FormClear2();
- ChangeButtonType1(1);
- ChangeButtonType2(1);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- BtnSearchClick((TObject*)BtnSearch);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnSearchClick(TObject *Sender)
- {
- Application->ProcessMessages();
- TSqlCursor sqlCrs((TControl*)BtnSearch);
- FormClear1();
- FormClear2();
- RefreshData();
- CxList1->SetFocus();
- ChangeButtonType1(1);
- ChangeButtonType2(1);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::RefreshData()
- {
- SelListData1();
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::FormClear1()
- {
- m_enJob1 = enJobNone;
- EdId1->Clear();
- EdMsgCd->Clear();
- EdKName1->Clear();
- EdEName1->Clear();
- EdRemark1->Clear();
- EdSysCd->Clear();
- CbUseYn1->ItemIndex = 0;
- EdCmmnClsfCd->Clear();
- EdCmmnClsfCdNm->Clear();
-
- FCode = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::FormClear2()
- {
- m_enJob2 = enJobNone;
- EdId2->Clear();
- EdCdAbbr->Clear();
- EdKName2->Clear();
- EdEName2->Clear();
- EdRemark2->Clear();
- EdAtrb1->Clear();
- EdAtrb2->Clear();
- CbUseYn2->ItemIndex = 0;
-
- FSubCode = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::ChangeButtonType1(int nBtnType)
- {
- if (nBtnType == 1)
- {
- BtnSave1->Visible = false;
- BtnCancel1->Visible = false;
- BtnInsert1->Visible = true;
- if (TvList1->ViewData->RecordCount > 0)
- {
- BtnEdit1->Visible = true;
- BtnDelete1->Visible = true;
- }
- else
- {
- BtnEdit1->Visible = false;
- BtnDelete1->Visible = false;
- }
- BtnSearch->Enabled = true;
- CxList1->Enabled = true;
- cxGroupBox1->Enabled = false;
- }
- else
- {
- BtnSave1->Visible = true;
- BtnCancel1->Visible = true;
- BtnInsert1->Visible = false;
- BtnEdit1->Visible = false;
- BtnDelete1->Visible = false;
- BtnSearch->Enabled = false;
- CxList1->Enabled = false;
- cxGroupBox1->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::ChangeButtonType2(int nBtnType)
- {
- if (nBtnType == 1)
- {
- BtnSave2->Visible = false;
- BtnCancel2->Visible = false;
- BtnInsert2->Visible = true;
- if (TvList2->ViewData->RecordCount > 0)
- {
- BtnEdit2->Visible = true;
- BtnDelete2->Visible = true;
- }
- else
- {
- BtnEdit2->Visible = false;
- BtnDelete2->Visible = false;
- }
- CxList2->Enabled = true;
- cxGroupBox2->Enabled = false;
- }
- else
- {
- BtnSave2->Visible = true;
- BtnCancel2->Visible = true;
- BtnInsert2->Visible = false;
- BtnEdit2->Visible = false;
- BtnDelete2->Visible = false;
- CxList2->Enabled = false;
- CxList2->Enabled = false;
- cxGroupBox2->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::SelListData1()
- {
- CMM_ClearGridTableView(TvList1);
- CMM_ClearGridTableView(TvList2);
- int nRow = 0;
- try
- {
- TvList1->BeginUpdate();
- FOR_STL(TItsCode *, pCode, ItsCodeManager->FLists)
- {
- nRow = m_pGDC1->AppendRecord();
- m_pGDC1->Values[nRow][MColumn01->Index] = "-"; //편집모드
- m_pGDC1->Values[nRow][MColumn02->Index] = pCode->CMMN_CLSF_CD; //공통 분류 코드
- m_pGDC1->Values[nRow][MColumn03->Index] = pCode->MSG_TYPE_CD; //메시지 유형 코드
- m_pGDC1->Values[nRow][MColumn04->Index] = pCode->CMMN_CLSF_KOR_NM; //공통 분류 한글 명
- m_pGDC1->Values[nRow][MColumn05->Index] = pCode->CMMN_CLSF_ENGL_NM; //공통 분류 영문 명
- m_pGDC1->Values[nRow][MColumn06->Index] = pCode->USE_SYST_CD; //사용 시스템 코드
- m_pGDC1->Values[nRow][MColumn07->Index] = pCode->RMRK; //비고
- m_pGDC1->Values[nRow][MColumn08->Index] = pCode->USE_YN; //사용 여부
- m_pGDC1->Values[nRow][MColumn98->Index] = (int)pCode;
- }
- }
- __finally
- {
- TvList1->EndUpdate();
- TvList1->DataController->GotoFirst();
- TvList1->DataController->FocusedRecordIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::SelListData2()
- {
- CMM_ClearGridTableView(TvList2);
- if (TvList1->ViewData->RecordCount <= 0) return;
- int nIndex = m_pGDC1->FocusedRecordIndex;
- if (nIndex < 0) return;
- int nMemPtr = m_pGDC1->Values[nIndex][MColumn98->Index];
- if (nMemPtr == 0) return;
- TItsCode *pCode = (TItsCode *)nMemPtr;
- int nRow = 0;
- try
- {
- TvList2->BeginUpdate();
- FOR_STL(TItsSubCode *, pSubCode, pCode->FSubLists)
- {
- nRow = m_pGDC2->AppendRecord();
- m_pGDC2->Values[nRow][SColumn01->Index] = "-"; //편집모드
- m_pGDC2->Values[nRow][SColumn02->Index] = pSubCode->CMMN_CD;
- m_pGDC2->Values[nRow][SColumn03->Index] = pSubCode->CMMN_CD_KOR_NM;
- m_pGDC2->Values[nRow][SColumn04->Index] = pSubCode->CMMN_CD_ENGL_NM;
- m_pGDC2->Values[nRow][SColumn05->Index] = pSubCode->CMMN_CD_ABBR;
- m_pGDC2->Values[nRow][SColumn06->Index] = pSubCode->RMRK;
- m_pGDC2->Values[nRow][SColumn07->Index] = pSubCode->ATRB1;
- m_pGDC2->Values[nRow][SColumn08->Index] = pSubCode->ATRB2;
- m_pGDC2->Values[nRow][SColumn09->Index] = pSubCode->USE_YN;
- m_pGDC2->Values[nRow][SColumn98->Index] = (int)pSubCode;
- }
- }
- __finally
- {
- TvList2->EndUpdate();
- TvList2->DataController->GotoFirst();
- TvList2->DataController->FocusedRecordIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnSaveClick(TObject *Sender)
- {
- bool bMemDel = true;
- String sMsgTitle, sMsgString;
- TcxButton *pBtn = (TcxButton*)Sender;
- if (pBtn->Tag == 0)
- {
- TItsCode *pCode = new TItsCode();
- try
- {
- pCode->CMMN_CLSF_CD = EdId1->Text.Trim();
- pCode->MSG_TYPE_CD = EdMsgCd->Text.Trim();
- pCode->CMMN_CLSF_KOR_NM = EdKName1->Text.Trim();
- pCode->CMMN_CLSF_ENGL_NM = EdEName1->Text.Trim();
- pCode->USE_SYST_CD = EdSysCd->Text.Trim();
- pCode->RMRK = EdRemark1->Text.Trim();
- pCode->USE_YN = (CbUseYn1->ItemIndex == 0) ? "Y" : "N";
- if (m_enJob1 == enJobSave) sMsgTitle = "대표코드 정보 등록";
- sMsgTitle = "대표코드 정보 수정";
- if (MergeCmmnClsfCd(pCode))
- {
- if (m_enJob1 == enJobSave)
- {
- ItsCodeManager->FLists.Push(pCode->CMMN_CLSF_CD, pCode);
- pCode->Completed = true;
- bMemDel = false;
- }
- else
- {
- //FCode->CMMN_CLSF_CD = EdId1->Text.Trim();
- FCode->MSG_TYPE_CD = EdMsgCd->Text.Trim();
- FCode->CMMN_CLSF_KOR_NM = EdKName1->Text.Trim();
- FCode->CMMN_CLSF_ENGL_NM = EdEName1->Text.Trim();
- FCode->USE_SYST_CD = EdSysCd->Text.Trim();
- FCode->RMRK = EdRemark1->Text.Trim();
- FCode->USE_YN = (CbUseYn1->ItemIndex == 0) ? "Y" : "N";
- }
- RefreshData();
- CMM_SetGridFocusRow(CxList1, TvList1, pCode->CMMN_CLSF_CD, MColumn02->Index);
- DisplayListData1();
- ChangeButtonType1(1);
- Application->MessageBox(String(sMsgTitle + " 하였습니다.").c_str(), sMsgTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- }
- __finally
- {
- if (bMemDel)
- {
- if (pCode) delete pCode;
- }
- }
- }
- else
- if (pBtn->Tag == 1)
- {
- TItsSubCode *pSubCode = new TItsSubCode();
-
- try
- {
- pSubCode->CMMN_CD = EdId2->Text.Trim();
- pSubCode->CMMN_CLSF_CD = FCode->CMMN_CLSF_CD;
- pSubCode->CMMN_CD_KOR_NM = EdKName2->Text.Trim();
- pSubCode->CMMN_CD_ENGL_NM = EdEName2->Text.Trim();
- pSubCode->CMMN_CD_ABBR = EdCdAbbr->Text.Trim();
- pSubCode->RMRK = EdRemark2->Text.Trim();
- pSubCode->ATRB1 = EdAtrb1->Text.Trim();
- pSubCode->ATRB2 = EdAtrb2->Text.Trim();
- pSubCode->USE_YN = (CbUseYn2->ItemIndex == 0) ? "Y" : "N";
- if (m_enJob2 == enJobSave) sMsgTitle = "세부코드 정보 등록";
- else sMsgTitle = "세부코드 정보 수정";
- if (MergeCmmnCd(pSubCode))
- {
- if (m_enJob2 == enJobSave)
- {
- FCode->FSubLists.Push(pSubCode->CMMN_CD, pSubCode);
- pSubCode->Completed = true;
- bMemDel = false;
- }
- else
- {
- //FSubCode->CMMN_CD = EdId2->Text.Trim();
- //FSubCode->CMMN_CLSF_CD = FCode->CMMN_CLSF_CD;
- FSubCode->CMMN_CD_KOR_NM = EdKName2->Text.Trim();
- FSubCode->CMMN_CD_ENGL_NM = EdEName2->Text.Trim();
- FSubCode->CMMN_CD_ABBR = EdCdAbbr->Text.Trim();
- FSubCode->RMRK = EdRemark2->Text.Trim();
- FSubCode->ATRB1 = EdAtrb1->Text.Trim();
- FSubCode->ATRB2 = EdAtrb2->Text.Trim();
- FSubCode->USE_YN = (CbUseYn2->ItemIndex == 0) ? "Y" : "N";
- }
- SelListData2();
- CMM_SetGridFocusRow(CxList2, TvList2, pSubCode->CMMN_CD, SColumn02->Index);
- DisplayListData2();
- ChangeButtonType2(1);
- Application->MessageBox(String(sMsgTitle + " 하였습니다.").c_str(), sMsgTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- }
- __finally
- {
- if (bMemDel)
- {
- if (pSubCode) delete pSubCode;
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TIFM0050M::MergeCmmnClsfCd(TItsCode *pCode)
- {
- bool bResult = false;
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "MERGE INTO TB_CMMN_CLSF_CD L \r\n"
- "USING (SELECT :p01 AS CMMN_CLSF_CD, \r\n"
- " :p02 AS MSG_TYPE_CD, \r\n"
- " :p03 AS CMMN_CLSF_KOR_NM, \r\n"
- " :p04 AS CMMN_CLSF_ENGL_NM, \r\n"
- " :p05 AS USE_SYST_CD, \r\n"
- " :p06 AS RMRK, \r\n"
- " :p07 AS USE_YN \r\n"
- " FROM DUAL \r\n"
- " ) M \r\n"
- "ON (L.CMMN_CLSF_CD = M.CMMN_CLSF_CD) \r\n"
- "WHEN MATCHED THEN \r\n"
- " UPDATE SET L.MSG_TYPE_CD = M.MSG_TYPE_CD, \r\n"
- " L.CMMN_CLSF_KOR_NM = M.CMMN_CLSF_KOR_NM, \r\n"
- " L.CMMN_CLSF_ENGL_NM = M.CMMN_CLSF_ENGL_NM, \r\n"
- " L.USE_SYST_CD = M.USE_SYST_CD, \r\n"
- " L.RMRK = M.RMRK, \r\n"
- " L.USE_YN = M.USE_YN \r\n"
- "WHEN NOT MATCHED THEN \r\n"
- " INSERT (L.CMMN_CLSF_CD, \r\n"
- " L.MSG_TYPE_CD, \r\n"
- " L.CMMN_CLSF_KOR_NM, \r\n"
- " L.CMMN_CLSF_ENGL_NM, \r\n"
- " L.USE_SYST_CD, \r\n"
- " L.RMRK, \r\n"
- " L.USE_YN) \r\n"
- " VALUES (M.CMMN_CLSF_CD, \r\n"
- " M.MSG_TYPE_CD, \r\n"
- " M.CMMN_CLSF_KOR_NM, \r\n"
- " M.CMMN_CLSF_ENGL_NM, \r\n"
- " M.USE_SYST_CD, \r\n"
- " M.RMRK, \r\n"
- " M.USE_YN) \r\n";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", pCode->CMMN_CLSF_CD);
- ITSDb_SQLBind(pADO, "p02", pCode->MSG_TYPE_CD);
- ITSDb_SQLBind(pADO, "p03", pCode->CMMN_CLSF_KOR_NM);
- ITSDb_SQLBind(pADO, "p04", pCode->CMMN_CLSF_ENGL_NM);
- ITSDb_SQLBind(pADO, "p05", pCode->USE_SYST_CD);
- ITSDb_SQLBind(pADO, "p06", pCode->RMRK);
- ITSDb_SQLBind(pADO, "p07", pCode->USE_YN);
- ITSDb_GetConnection()->BeginTrans();
- ITSDb_SQLExec(pADO);
- ITSDb_GetConnection()->CommitTrans();
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(exception.ClassName()) + exception.Message);
- }
- catch(...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(FrmLang->lblDbErr->Caption);//"데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- return bResult;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TIFM0050M::MergeCmmnCd(TItsSubCode *pSubCode)
- {
- bool bResult = false;
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "MERGE INTO TB_CMMN_CD L \r\n"
- "USING (SELECT :p01 AS CMMN_CD, \r\n"
- " :p02 AS CMMN_CLSF_CD, \r\n"
- " :p03 AS CMMN_CD_KOR_NM, \r\n"
- " :p04 AS CMMN_CD_ENGL_NM, \r\n"
- " :p05 AS CMMN_CD_ABBR, \r\n"
- " :p06 AS RMRK, \r\n"
- " :p07 AS ATRB1, \r\n"
- " :p08 AS ATRB2, \r\n"
- " :p09 AS USE_YN \r\n"
- " FROM DUAL \r\n"
- " ) M \r\n"
- "ON ( L.CMMN_CD = M.CMMN_CD \r\n"
- " AND L.CMMN_CLSF_CD = M.CMMN_CLSF_CD) \r\n"
- "WHEN MATCHED THEN \r\n"
- " UPDATE SET L.CMMN_CD_KOR_NM = M.CMMN_CD_KOR_NM, \r\n"
- " L.CMMN_CD_ENGL_NM = M.CMMN_CD_ENGL_NM, \r\n"
- " L.CMMN_CD_ABBR = M.CMMN_CD_ABBR, \r\n"
- " L.RMRK = M.RMRK, \r\n"
- " L.ATRB1 = M.ATRB1, \r\n"
- " L.ATRB2 = M.ATRB2, \r\n"
- " L.USE_YN = M.USE_YN \r\n"
- "WHEN NOT MATCHED THEN \r\n"
- " INSERT (L.CMMN_CD, \r\n"
- " L.CMMN_CLSF_CD, \r\n"
- " L.CMMN_CD_KOR_NM, \r\n"
- " L.CMMN_CD_ENGL_NM, \r\n"
- " L.CMMN_CD_ABBR, \r\n"
- " L.RMRK, \r\n"
- " L.ATRB1, \r\n"
- " L.ATRB2, \r\n"
- " L.USE_YN) \r\n"
- " VALUES (M.CMMN_CD, \r\n"
- " M.CMMN_CLSF_CD, \r\n"
- " M.CMMN_CD_KOR_NM, \r\n"
- " M.CMMN_CD_ENGL_NM, \r\n"
- " M.CMMN_CD_ABBR, \r\n"
- " M.RMRK, \r\n"
- " M.ATRB1, \r\n"
- " M.ATRB2, \r\n"
- " M.USE_YN) \r\n";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
-
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", pSubCode->CMMN_CD);
- ITSDb_SQLBind(pADO, "p02", pSubCode->CMMN_CLSF_CD);
- ITSDb_SQLBind(pADO, "p03", pSubCode->CMMN_CD_KOR_NM);
- ITSDb_SQLBind(pADO, "p04", pSubCode->CMMN_CD_ENGL_NM);
- ITSDb_SQLBind(pADO, "p05", pSubCode->CMMN_CD_ABBR);
- ITSDb_SQLBind(pADO, "p06", pSubCode->RMRK);
- ITSDb_SQLBind(pADO, "p07", pSubCode->ATRB1);
- ITSDb_SQLBind(pADO, "p08", pSubCode->ATRB2);
- ITSDb_SQLBind(pADO, "p09", pSubCode->USE_YN);
- ITSDb_GetConnection()->BeginTrans();
- ITSDb_SQLExec(pADO);
- ITSDb_GetConnection()->CommitTrans();
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(exception.ClassName()) + exception.Message);
- }
- catch(...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(FrmLang->lblDbErr->Caption);//"데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- return bResult;
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnCancelClick(TObject *Sender)
- {
- TcxButton *pBtn = (TcxButton*)Sender;
- if (pBtn->Tag == 0)
- {
- ChangeButtonType1(1);
- m_enJob1 = enJobNone;
- DisplayListData1();
- }
- else
- if (pBtn->Tag == 1)
- {
- ChangeButtonType2(1);
- m_enJob2 = enJobNone;
- DisplayListData2();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnInsertClick(TObject *Sender)
- {
- String sErrMsg = "";
- String sId = "";
- TcxButton *pBtn = (TcxButton*)Sender;
- if (pBtn->Tag == 0)
- {
- sId = InputBox("대표코드", "새로운 대표코드를 입력하세요.\r\n입력후에는 수정이 불가능합니다.", "최대5자리");
- sId.Trim();
- if (sId.IsEmpty() || AnsiString(sId).Length() > 5 || sId == "최대5자리")
- {
- Application->MessageBox(L"5자리를 초과하였거나 값이 없습니다.", L"대표코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
-
- TItsCode *pCode = ItsCodeManager->FLists.Find(sId);
- if (pCode)
- {
- sErrMsg = "[" + sId + "] 코드는 이미 사용 중인 코드입니다.\r\n다른 코드를 입력하세요.";
- Application->MessageBox(sErrMsg.c_str(), L"대표코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- ChangeButtonType1(2);
- FormClear1();
- FormClear2();
- EdId1->Text = sId;
- m_enJob1 = enJobSave;
- }
- else
- if (pBtn->Tag == 1)
- {
- if (m_pGDC1->FocusedRecordIndex < 0)
- {
- Application->MessageBox(L"대표코드를 선택후 사용해주십시오.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
-
- if (!FCode)
- {
- Application->MessageBox(L"대표코드를 선택후 사용해주십시오.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- sId = InputBox("세부코드", "새로운 세부코드를 입력하세요.\r\n입력후에는 수정이 불가능합니다.", "최대7자리");
- sId.Trim();
- if (sId.IsEmpty() || AnsiString(sId).Length() > 5 || sId == "최대7자리")
- {
- Application->MessageBox(L"7자리를 초과하였거나 값이 없습니다.", L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
-
- TItsSubCode *pSubCode = FCode->FSubLists.Find(sId);
- if (pSubCode)
- {
- sErrMsg = "[" + sId + "] 코드는 이미 사용 중인 코드입니다.\r\n다른 코드를 입력하세요.";
- Application->MessageBox(sErrMsg.c_str(), L"세부코드 추가 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- ChangeButtonType2(2);
- FormClear2();
- EdId2->Text = sId;
- m_enJob2 = enJobSave;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnEditClick(TObject *Sender)
- {
- TcxButton *pBtn = (TcxButton*)Sender;
- if (pBtn->Tag == 0)
- {
- ChangeButtonType1(2);
- m_enJob1 = enJobEdit;
- }
- else
- if (pBtn->Tag == 1)
- {
- ChangeButtonType2(2);
- m_enJob2 = enJobEdit;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::BtnDeleteClick(TObject *Sender)
- {
- TcxButton *pBtn = (TcxButton*)Sender;
- if (pBtn->Tag == 0)
- {
- DeleteData1();
- }
- else
- if (pBtn->Tag == 1)
- {
- DeleteData2();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::DeleteData1()
- {
- TADOQuery *pADO = NULL;
- String sQry;
- String sMsgString;
- if (TvList1->ViewData->RecordCount <= 0) return;
- if (TvList1->DataController->FocusedRecordIndex < 0) return;
- if (!FCode)
- {
- return;
- }
- sMsgString = "대표코드 정보를 삭제 하시겠습니까?\r\n세부코드 정보도 함께 삭제 됩니다." ;
- if (Application->MessageBox(sMsgString.c_str(), L"코드 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
- String sCode = FCode->CMMN_CLSF_CD;
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
-
- ITSDb_GetConnection()->BeginTrans();
- // 세부코드 삭제
- sQry = "DELETE FROM TB_CMMN_CD \r\n"
- " WHERE CMMN_CLSF_CD = :p01 \r\n";
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", sCode);
- ITSDb_SQLExec(pADO);
- // 대분류 코드 삭제
- sQry = "DELETE FROM TB_CMMN_CLSF_CD \r\n"
- " WHERE CMMN_CLSF_CD = :p01 \r\n";
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", sCode);
- ITSDb_SQLExec(pADO);
- ITSDb_GetConnection()->CommitTrans();
- ItsCodeManager->FLists.Remove(sCode);
- Application->MessageBox(L"대표코드와 세부코드 정보를 삭제하였습니다.", L"코드 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- BtnSearchClick(NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::DeleteData2()
- {
- TADOQuery *pADO = NULL;
- String sQry;
- String sMsgString;
- if (TvList2->ViewData->RecordCount <= 0) return;
- if (TvList2->DataController->FocusedRecordIndex < 0) return;
- if (!FCode || !FSubCode)
- {
- return;
- }
- sMsgString = "세부코드 정보를 삭제 하시겠습니까?" ;
- if (Application->MessageBox(sMsgString.c_str(), L"세부코드 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
- String sSubCode = FSubCode->CMMN_CD;
- String sCode = FSubCode->CMMN_CLSF_CD;
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
-
- // 세부코드 삭제
- sQry = "DELETE FROM TB_CMMN_CD \r\n"
- " WHERE CMMN_CD = :p01 \r\n"
- " AND CMMN_CLSF_CD = :p02 \r\n";
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", sSubCode);
- ITSDb_SQLBind(pADO, "p02", sCode);
- ITSDb_SQLExec(pADO);
- ITSDb_GetConnection()->CommitTrans();
- ITSDb_GetConnection()->BeginTrans();
- FCode->FSubLists.Remove(sSubCode);
- Application->MessageBox(L"세부코드 정보를 삭제하였습니다.", L"세부코드 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- SelListData2();
- DisplayListData2();
- ChangeButtonType2(1);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::TvList1FocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
- TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
- {
- DisplayListData1();
- SelListData2();
- ChangeButtonType2(1);
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::TvList2FocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
- TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
- {
- DisplayListData2();
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::DisplayListData1()
- {
- int ii;
- FormClear1();
- if (TvList1->ViewData->RecordCount <= 0) return;
- int nIndex = m_pGDC1->FocusedRecordIndex;
- if (nIndex < 0) return;
- int nMemPtr = m_pGDC1->Values[nIndex][MColumn98->Index];
- if (nMemPtr == 0) return;
- FCode = (TItsCode *)nMemPtr;
- try
- {
- EdId1->Text = FCode->CMMN_CLSF_CD;
- EdMsgCd->Text = FCode->MSG_TYPE_CD;
- EdKName1->Text = FCode->CMMN_CLSF_KOR_NM;
- EdEName1->Text = FCode->CMMN_CLSF_ENGL_NM;
- EdRemark1->Text = FCode->RMRK;
- EdSysCd->Text = FCode->USE_SYST_CD;
- CbUseYn1->ItemIndex = FCode->USE_YN == "Y" ? 0 : 1;
- EdCmmnClsfCd->Text = FCode->CMMN_CLSF_CD;
- EdCmmnClsfCdNm->Text= FCode->CMMN_CLSF_KOR_NM;
- }
- catch(Exception &e)
- {
- Application->MessageBox((e.Message + " - " +__FILE__+ " - " +__LINE__).c_str(), Caption.c_str(), MB_OK);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::DisplayListData2()
- {
- FormClear2();
- if (TvList2->ViewData->RecordCount <= 0) return;
- int nIndex = m_pGDC2->FocusedRecordIndex;
- if (nIndex < 0) return;
- int nMemPtr = m_pGDC2->Values[nIndex][SColumn98->Index];
- if (nMemPtr == 0) return;
- FSubCode = (TItsSubCode *)nMemPtr;
- try
- {
- EdId2->Text = FSubCode->CMMN_CD;
- EdCdAbbr->Text = FSubCode->CMMN_CD_ABBR;
- EdKName2->Text = FSubCode->CMMN_CD_KOR_NM;
- EdEName2->Text = FSubCode->CMMN_CD_ENGL_NM;
- EdRemark2->Text = FSubCode->RMRK;
- EdAtrb1->Text = FSubCode->ATRB1;
- EdAtrb2->Text = FSubCode->ATRB2;
- CbUseYn2->ItemIndex = FSubCode->USE_YN == "Y" ? 0 : 1;
- }
- catch(Exception &e)
- {
- Application->MessageBox((e.Message + " - " +__FILE__+ " - " +__LINE__).c_str(), Caption.c_str(), MB_OK);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TIFM0050M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- IFM0050M = NULL;
- Action = caFree;
- }
- //---------------------------------------------------------------------------
|