123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #pragma hdrstop
- #include "SMS00201F.h"
- #include "FrmSmsUserF.h"
- #include "FrmSmsGroupF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCalc"
- #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 "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinCaramel"
- #pragma link "dxSkinCoffee"
- #pragma link "dxSkinDarkRoom"
- #pragma link "dxSkinDarkSide"
- #pragma link "dxSkinFoggy"
- #pragma link "dxSkinGlassOceans"
- #pragma link "dxSkiniMaginary"
- #pragma link "dxSkinLilian"
- #pragma link "dxSkinLiquidSky"
- #pragma link "dxSkinLondonLiquidSky"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinMoneyTwins"
- #pragma link "dxSkinOffice2007Black"
- #pragma link "dxSkinOffice2007Blue"
- #pragma link "dxSkinOffice2007Green"
- #pragma link "dxSkinOffice2007Pink"
- #pragma link "dxSkinOffice2007Silver"
- #pragma link "dxSkinOffice2010Black"
- #pragma link "dxSkinOffice2010Blue"
- #pragma link "dxSkinOffice2010Silver"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "cxGridBandedTableView"
- #pragma resource "*.dfm"
- TSMS00201 *SMS00201 = NULL;
- //---------------------------------------------------------------------------
- __fastcall TSMS00201::TSMS00201(TComponent* Owner, TForm *ParentForm)
- : TForm(Owner)
- {
- ITSSkin_Load(this);
- //CMM_LoadForm(g_sFormsDir, this);
- FUserId = "";
- FGropId = "";
- FGroupChanged = false;
- //cxGroupBox2->PanelStyle->Active = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- //SMS00201 = NULL;
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::CommClose()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::FormDestroy(TObject *Sender)
- {
- try
- {
- }
- catch (...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::FormShow(TObject *Sender)
- {
- Refresh();
- FormInit();
- Application->ProcessMessages();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::FormInit()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- Application->ProcessMessages();
- DispData();
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnListAddClick(TObject *Sender)
- {
- // List Data Add
- TWaitCursor crs;
- TcxGridTableView *pTvList = TvList2;
- TcxDataController *pGDC = pTvList->DataController;
- if (pTvList->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if (nRow < 0)
- {
- Application->MessageBox(L"추가할 대상 SMS 그룹을 먼저 선택하세요", L"SMS 그룹 목록 추가", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- return;
- }
- FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
- //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
- int nSelRows = TvList1->Controller->SelectedRowCount;
- if (nSelRows <= 0)
- {
- Application->MessageBox(L"추가할 SMS 발송 연락처를 선택하세요", L"SMS 그룹 목록 추가", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- return;
- }
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "MERGE INTO TB_SMS_USER_GROP_RLTN L \r\n"
- "USING (SELECT :p01 AS SMS_GROP_ID, \r\n"
- " :p02 AS SMS_USER_ID \r\n"
- " FROM DUAL \r\n"
- " ) M \r\n"
- "ON (L.SMS_GROP_ID = M.SMS_GROP_ID \r\n"
- "AND L.SMS_USER_ID = M.SMS_USER_ID) \r\n"
- "WHEN NOT MATCHED THEN \r\n"
- " INSERT (L.SMS_GROP_ID, \r\n"
- " L.SMS_USER_ID) \r\n"
- " VALUES (M.SMS_GROP_ID, \r\n"
- " M.SMS_USER_ID) \r\n";
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_GetConnection()->BeginTrans();
- for (int ii = 0; ii < nSelRows; ii++)
- {
- int nSelIdx = TvList1->Controller->SelectedRows[ii]->RecordIndex;
- String sUserId = TvList1->DataController->Values[nSelIdx][MColumn02->Index];
- try
- {
- ITSDb_SQLBind(pADO, "p01", FGropId);
- ITSDb_SQLBind(pADO, "p02", sUserId);
- ITSDb_SQLExec(pADO);
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage(String(E.ClassName()) + E.Message);
- break;
- }
- catch(Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage(String(exception.ClassName()) + exception.Message);
- break;
- }
- catch(...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
- break;
- }
- }
- ITSDb_GetConnection()->CommitTrans();
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- SelSmsGroupRltnList(FGropId);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnListDeleteClick(TObject *Sender)
- {
- // List Data Delete
- TWaitCursor crs;
- int nSelRows = TvList3->Controller->SelectedRowCount;
- if (nSelRows <= 0)
- {
- Application->MessageBox(L"삭제할 SMS 발송 그룹 정보를 선택하세요", L"SMS 그룹 목록 삭제", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
- return;
- }
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "DELETE TB_SMS_USER_GROP_RLTN L \r\n"
- " WHERE L.SMS_GROP_ID = :p01 \r\n"
- " AND L.SMS_USER_ID = :p02 \r\n";
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_GetConnection()->BeginTrans();
- for (int ii = 0; ii < nSelRows; ii++)
- {
- int nSelIdx = TvList3->Controller->SelectedRows[ii]->RecordIndex;
- String sGropId = TvList3->DataController->Values[nSelIdx][RColumn02->Index];
- String sUserId = TvList3->DataController->Values[nSelIdx][RColumn04->Index];
- try
- {
- ITSDb_SQLBind(pADO, "p01", sGropId);
- ITSDb_SQLBind(pADO, "p02", sUserId);
- ITSDb_SQLExec(pADO);
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(E.ClassName()) + E.Message);
- break;
- }
- catch(Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage(String(exception.ClassName()) + exception.Message);
- break;
- }
- catch(...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
- break;
- }
- }
- ITSDb_GetConnection()->CommitTrans();
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- SelSmsGroupRltnList(FGropId);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnInsert1Click(TObject *Sender)
- {
- String sNewId = "";
- try {
- if (!GetUserNewId(sNewId)) return;
- TFrmSmsUser *pDlg = new TFrmSmsUser(this->Parent);
- pDlg->EdId->Text = sNewId;
- pDlg->EdBackTel->Text = "044-300-5545";
- pDlg->FDbMode = enJobSave;
- pDlg->ShowModal();
- if (pDlg->FUpdated)
- {
- FUserId = pDlg->EdId->Text.Trim();
- String sName = pDlg->EdName->Text.Trim();
- String sCallTel = pDlg->EdCallTel->Text.Trim();
- String sBackTel = pDlg->EdBackTel->Text.Trim();
- String sDesc = pDlg->EdDesc->Text.Trim();
- String sRegDt = pDlg->EdRegDt->Text.Trim();
- SelSmsUserList();
- CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
- }
- delete pDlg;
- } catch(...) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnEdit1Click(TObject *Sender)
- {
- TcxDataController *pGDC = TvList1->DataController;
- if (TvList1->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if( nRow < 0 )
- {
- Application->MessageBox(L"목록에서 연락처를 선택하세요.", L"SMS 발송 연락처 등록", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- FUserId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
- String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
- String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
- try {
- TFrmSmsUser *pDlg = new TFrmSmsUser(this->Parent);
- pDlg->EdId->Text = FUserId;
- pDlg->EdName->Text = sName;
- pDlg->EdCallTel->Text = sCallTel;
- pDlg->EdBackTel->Text = sBackTel;
- pDlg->EdDesc->Text = sDesc;
- pDlg->EdRegDt->Text = sRegDt;
- if (pDlg->EdBackTel->Text == "")
- {
- pDlg->EdBackTel->Text = "044-300-5545";
- }
- pDlg->FDbMode = enJobEdit;
- pDlg->ShowModal();
- if (pDlg->FUpdated)
- {
- FUserId = pDlg->EdId->Text.Trim();
- sName = pDlg->EdName->Text.Trim();
- sCallTel = pDlg->EdCallTel->Text.Trim();
- sBackTel = pDlg->EdBackTel->Text.Trim();
- sDesc = pDlg->EdDesc->Text.Trim();
- sRegDt = pDlg->EdRegDt->Text.Trim();
- SelSmsUserList();
- SelSmsGroupRltnList(FGropId);
- CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
- }
- delete pDlg;
- } catch(...) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnDelete1Click(TObject *Sender)
- {
- TcxDataController *pGDC = TvList1->DataController;
- if (TvList1->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if( nRow < 0 )
- {
- Application->MessageBox(L"목록에서 연락처를 선택하세요.", L"SMS 발송 연락처 삭제", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- String sId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
- String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
- String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
- String sMsg = "";
- sMsg += "<<< ID: " + sId + " >>>\r\n";
- sMsg += "<<< 사용자: " + sName + " >>>\r\n";
- sMsg += "<<< 연락처 정보를 삭제 하시겠습니까? >>>\r\n";
- sMsg += "<<< 연락처-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
- if (Application->MessageBox(sMsg.c_str(), L"SMS 발송 연락처 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
- TADOQuery *pADOD = NULL;
- String sQryD1, sQryD2;
- try
- {
- sQryD1 = "DELETE TB_SMS_USER_GROP_RLTN \r\n"
- " WHERE SMS_USER_ID = :p01 \r\n";
- sQryD2 = "DELETE TB_SMS_USER \r\n"
- " WHERE SMS_USER_ID = :p01 \r\n";
- try
- {
- pADOD = new TADOQuery(NULL);
- pADOD->Close();
- pADOD->Connection = ITSDb_GetConnection();
- ITSDb_GetConnection()->BeginTrans();
- ITSDb_SQLText(pADOD, sQryD1);
- ITSDb_SQLBind(pADOD, "p01", sId);
- ITSDb_SQLExec(pADOD);
- ITSDb_SQLText(pADOD, sQryD2);
- ITSDb_SQLBind(pADOD, "p01", sId);
- ITSDb_SQLExec(pADOD);
- ITSDb_GetConnection()->CommitTrans();
- Application->MessageBox(L"SMS 발송 연락처 정보를 삭제 하였습니다.",
- L"SMS 발송 연락처 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- FUserId = "";
- SelSmsUserList();
- SelSmsGroupRltnList(FGropId);
- CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
- }
- 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("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADOD)
- {
- pADOD->Close();
- delete pADOD;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnInsertGroupClick(TObject *Sender)
- {
- String sNewId = "";
- try {
- if (!GetGroupNewId(sNewId)) return;
- TFrmSmsGroup *pDlg = new TFrmSmsGroup(this->Parent);
- pDlg->EdId->Text = sNewId;
- pDlg->FDbMode = enJobSave;
- pDlg->ShowModal();
- if (pDlg->FUpdated)
- {
- FGropId = pDlg->EdId->Text;
- SelSmsGroupList();
- SelSmsGroupRltnList(FGropId);
- CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
- FGroupChanged = true;
- }
- delete pDlg;
- } catch(...) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnEditGroupClick(TObject *Sender)
- {
- TcxDataController *pGDC = TvList2->DataController;
- if (TvList2->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if( nRow < 0 )
- {
- Application->MessageBox(L"목록에서 그룹을 선택하세요.", L"SMS 발송 그룹 등록", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
- //String sGrade = pGDC->Values[nRow][SColumn04->Index];
- String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
- try {
- TFrmSmsGroup *pDlg = new TFrmSmsGroup(this->Parent);
- pDlg->FDbMode = enJobEdit;
- pDlg->EdId->Text = FGropId;
- pDlg->EdName->Text = sName;
- pDlg->EdDesc->Text = sDesc;
- pDlg->EdRegDt->Text = sRegDt;
- pDlg->ShowModal();
- if (pDlg->FUpdated)
- {
- FGropId = pDlg->EdId->Text;
- SelSmsGroupList();
- SelSmsGroupRltnList(FGropId);
- CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
- FGroupChanged = true;
- }
- delete pDlg;
- } catch(...) { }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::BtnDeleteGroupClick(TObject *Sender)
- {
- TcxDataController *pGDC = TvList2->DataController;
- if (TvList2->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if( nRow < 0 )
- {
- Application->MessageBox(L"목록에서 그룹을 선택하세요.", L"SMS 발송 그룹 삭제", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- String sId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
- //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
- String sMsg = "";
- sMsg += "<<< ID: " + sId + " >>>\r\n";
- sMsg += "<<< 그룹명: " + sName + " >>>\r\n";
- sMsg += "<<< SMS 발송 그룹 정보를 삭제 하시겠습니까? >>>\r\n\r\n";
- sMsg += "<<< 연락처-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
- sMsg += "<<< 장애유형-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
- if (Application->MessageBox(sMsg.c_str(), L"SMS 발송 그룹 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
- // delete
- TADOQuery *pADOD = NULL;
- String sQryD1, sQryD2, sQryD3;
- try
- {
- sQryD1 = "DELETE TB_SMS_USER_GROP_RLTN \r\n"
- " WHERE SMS_GROP_ID = :p01 \r\n";
- sQryD2 = "DELETE TB_SMS_FAIL_GROP_RLTN \r\n"
- " WHERE SMS_GROP_ID = :p01 \r\n";
- sQryD3 = "DELETE TB_SMS_USER_GROP \r\n"
- " WHERE SMS_GROP_ID = :p01 \r\n";
- try
- {
- pADOD = new TADOQuery(NULL);
- pADOD->Close();
- pADOD->Connection = ITSDb_GetConnection();
- ITSDb_GetConnection()->BeginTrans();
- ITSDb_SQLText(pADOD, sQryD1);
- ITSDb_SQLBind(pADOD, "p01", sId);
- ITSDb_SQLExec(pADOD);
- ITSDb_SQLText(pADOD, sQryD2);
- ITSDb_SQLBind(pADOD, "p01", sId);
- ITSDb_SQLExec(pADOD);
- ITSDb_SQLText(pADOD, sQryD3);
- ITSDb_SQLBind(pADOD, "p01", sId);
- ITSDb_SQLExec(pADOD);
- ITSDb_GetConnection()->CommitTrans();
- Application->MessageBox(L"SMS 발송 그룹 정보를 삭제 하였습니다.",
- L"SMS 발송 그룹 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- FGropId = "";
- SelSmsGroupList();
- SelSmsGroupRltnList(FGropId);
- CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
- FGroupChanged = 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("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADOD)
- {
- pADOD->Close();
- delete pADOD;
- }
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TSMS00201::GetUserNewId(String &ANewId)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT NVL(MAX(SMS_USER_ID), 0) + 1 AS NEWID \r\n"
- " FROM TB_SMS_USER \r\n";
- ANewId = "";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Open();
- ANewId = pADO->FieldByName("NEWID")->AsString;
- return true;
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- catch(...)
- {
- throw Exception("알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- return false;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TSMS00201::GetGroupNewId(String &ANewId)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT NVL(MAX(SMS_GROP_ID), 0) + 1 AS NEWID \r\n"
- " FROM TB_SMS_USER_GROP \r\n";
- ANewId = "";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Open();
- ANewId = pADO->FieldByName("NEWID")->AsString;
- return true;
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- catch(...)
- {
- throw Exception("알수없는 DB 오류가 발생하였습니다.");
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- return false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::DispData()
- {
- FUserId = "";
- FGropId = "";
- SelSmsUserList();
- SelSmsGroupList();
- SelSmsGroupRltnList(FGropId);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::SelSmsUserList()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- TcxGridTableView *pTvList = TvList1;
- TcxDataController *pGDC = pTvList->DataController;
- CMM_ClearGridTableView(pTvList);
- sQry = "SELECT A.SMS_USER_ID, \r\n"
- " A.SMS_USER_NM, \r\n"
- " A.SMS_USER_TEL, \r\n"
- " A.SMS_USER_EXPL, \r\n"
- " A.SMS_RPLY_TEL, \r\n"
- " A.RGST_DT \r\n"
- " FROM TB_SMS_USER A \r\n"
- " ORDER BY A.SMS_USER_ID \r\n";
- try
- {
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLOpen(pADO);
- int nRow = 0;
- try
- {
- pTvList->BeginUpdate();
- pGDC->RecordCount = pADO->RecordCount;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- pGDC->Values[nRow][MColumn02->Index] = pADO->FieldByName("SMS_USER_ID")->AsString;
- pGDC->Values[nRow][MColumn03->Index] = pADO->FieldByName("SMS_USER_NM")->AsString;
- pGDC->Values[nRow][MColumn04->Index] = pADO->FieldByName("SMS_USER_TEL")->AsString;
- pGDC->Values[nRow][MColumn05->Index] = pADO->FieldByName("SMS_RPLY_TEL")->AsString;
- pGDC->Values[nRow][MColumn06->Index] = pADO->FieldByName("SMS_USER_EXPL")->AsString;
- pGDC->Values[nRow][MColumn07->Index] = ITSUtil_StrToTime(pADO->FieldByName("RGST_DT")->AsString);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- pTvList->EndUpdate();
- //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
- }
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception("알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::SelSmsGroupList()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- TcxGridTableView *pTvList = TvList2;
- TcxDataController *pGDC = pTvList->DataController;
- CMM_ClearGridTableView(pTvList);
- sQry = "SELECT A.SMS_GROP_ID, \r\n"
- " A.SMS_GROP_NM, \r\n"
- " A.SMS_GROP_EXPL, \r\n"
- " A.RGST_DT \r\n"
- " FROM TB_SMS_USER_GROP A \r\n"
- " ORDER BY A.SMS_GROP_ID \r\n";
- try
- {
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLOpen(pADO);
- int nRow = 0;
- try
- {
- pTvList->BeginUpdate();
- pGDC->RecordCount = pADO->RecordCount;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- pGDC->Values[nRow][SColumn02->Index] = pADO->FieldByName("SMS_GROP_ID")->AsString;
- pGDC->Values[nRow][SColumn03->Index] = pADO->FieldByName("SMS_GROP_NM")->AsString;
- pGDC->Values[nRow][SColumn05->Index] = pADO->FieldByName("SMS_GROP_EXPL")->AsString;
- pGDC->Values[nRow][SColumn06->Index] = ITSUtil_StrToTime(pADO->FieldByName("RGST_DT")->AsString);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- pTvList->EndUpdate();
- //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
- }
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception("알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::SelSmsGroupRltnList(String AGroupId)
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- TcxGridTableView *pTvList = TvList3;
- TcxDataController *pGDC = pTvList->DataController;
- CMM_ClearGridTableView(pTvList);
- sQry = "SELECT A.SMS_GROP_ID, A.SMS_USER_ID, \r\n"
- " B.SMS_USER_NM, B.SMS_USER_TEL, B.SMS_USER_EXPL, \r\n"
- " B.SMS_RPLY_TEL, B.RGST_DT AS URGST_DT, \r\n"
- " C.SMS_GROP_NM, C.SMS_GROP_EXPL, C.RGST_DT AS GRGST_DT \r\n"
- " FROM TB_SMS_USER_GROP_RLTN A, \r\n"
- " TB_SMS_USER B, \r\n"
- " TB_SMS_USER_GROP C \r\n"
- " WHERE A.SMS_GROP_ID = :p01 \r\n"
- " AND A.SMS_GROP_ID = C.SMS_GROP_ID \r\n"
- " AND A.SMS_USER_ID = B.SMS_USER_ID \r\n";
- try
- {
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", AGroupId);
- ITSDb_SQLOpen(pADO);
- int nRow = 0;
- try
- {
- pTvList->BeginUpdate();
- pGDC->RecordCount = pADO->RecordCount;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- pGDC->Values[nRow][RColumn02->Index] = pADO->FieldByName("SMS_GROP_ID")->AsString;
- pGDC->Values[nRow][RColumn03->Index] = pADO->FieldByName("SMS_GROP_NM")->AsString;
- pGDC->Values[nRow][RColumn04->Index] = pADO->FieldByName("SMS_USER_ID")->AsString;
- pGDC->Values[nRow][RColumn05->Index] = pADO->FieldByName("SMS_USER_NM")->AsString;
- pGDC->Values[nRow][RColumn06->Index] = pADO->FieldByName("SMS_USER_TEL")->AsString;
- pGDC->Values[nRow][RColumn07->Index] = pADO->FieldByName("SMS_RPLY_TEL")->AsString;
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- pTvList->EndUpdate();
- //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
- }
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(...)
- {
- throw Exception("알수없는 오류가 발생하였습니다.");
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::TvList1FocusedRecordChanged(TcxCustomGridTableView *Sender,
- TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
- bool ANewItemRecordFocusingChanged)
- {
- DispSmsUser();
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::TvList2FocusedRecordChanged(TcxCustomGridTableView *Sender,
- TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
- bool ANewItemRecordFocusingChanged)
- {
- DispSmsGroup();
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::DispSmsUser()
- {
- BtnDelete1->Enabled = false;
- BtnEdit1->Enabled = false;
- TcxGridTableView *pTvList = TvList1;
- TcxDataController *pGDC = pTvList->DataController;
- if (pTvList->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if (nRow < 0) return;
- FUserId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
- String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
- String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
- BtnDelete1->Enabled = true;
- BtnEdit1->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSMS00201::DispSmsGroup()
- {
- BtnDeleteGroup->Enabled = false;
- BtnEditGroup->Enabled = false;
- TcxGridTableView *pTvList = TvList2;
- TcxDataController *pGDC = pTvList->DataController;
- if (pTvList->ViewData->RecordCount <= 0) return;
- int nRow = pGDC->FocusedRecordIndex;
- if (nRow < 0) return;
- FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
- String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
- //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
- String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
- String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
- BtnDeleteGroup->Enabled = true;
- BtnEditGroup->Enabled = true;
- SelSmsGroupRltnList(FGropId);
- }
- //---------------------------------------------------------------------------
|