SMS00201F.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "SMS00201F.h"
  9. #include "FrmSmsUserF.h"
  10. #include "FrmSmsGroupF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  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 "cxStyles"
  35. #pragma link "cxTextEdit"
  36. #pragma link "dxSkinBlack"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinCaramel"
  39. #pragma link "dxSkinCoffee"
  40. #pragma link "dxSkinDarkRoom"
  41. #pragma link "dxSkinDarkSide"
  42. #pragma link "dxSkinFoggy"
  43. #pragma link "dxSkinGlassOceans"
  44. #pragma link "dxSkiniMaginary"
  45. #pragma link "dxSkinLilian"
  46. #pragma link "dxSkinLiquidSky"
  47. #pragma link "dxSkinLondonLiquidSky"
  48. #pragma link "dxSkinMcSkin"
  49. #pragma link "dxSkinMoneyTwins"
  50. #pragma link "dxSkinOffice2007Black"
  51. #pragma link "dxSkinOffice2007Blue"
  52. #pragma link "dxSkinOffice2007Green"
  53. #pragma link "dxSkinOffice2007Pink"
  54. #pragma link "dxSkinOffice2007Silver"
  55. #pragma link "dxSkinOffice2010Black"
  56. #pragma link "dxSkinOffice2010Blue"
  57. #pragma link "dxSkinOffice2010Silver"
  58. #pragma link "dxSkinsCore"
  59. #pragma link "dxSkinscxPCPainter"
  60. #pragma link "dxSkinSeven"
  61. #pragma link "dxSkinSharp"
  62. #pragma link "dxSkinSilver"
  63. #pragma link "dxSkinStardust"
  64. #pragma link "cxGridBandedTableView"
  65. #pragma resource "*.dfm"
  66. TSMS00201 *SMS00201 = NULL;
  67. //---------------------------------------------------------------------------
  68. __fastcall TSMS00201::TSMS00201(TComponent* Owner, TForm *ParentForm)
  69. : TForm(Owner)
  70. {
  71. ITSSkin_Load(this);
  72. //CMM_LoadForm(g_sFormsDir, this);
  73. FUserId = "";
  74. FGropId = "";
  75. FGroupChanged = false;
  76. //cxGroupBox2->PanelStyle->Active = true;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TSMS00201::FormClose(TObject *Sender, TCloseAction &Action)
  80. {
  81. CommClose();
  82. //SMS00201 = NULL;
  83. Action = caFree;
  84. }
  85. //---------------------------------------------------------------------------
  86. void __fastcall TSMS00201::CommClose()
  87. {
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TSMS00201::FormDestroy(TObject *Sender)
  91. {
  92. try
  93. {
  94. }
  95. catch (...)
  96. {
  97. }
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TSMS00201::FormShow(TObject *Sender)
  101. {
  102. Refresh();
  103. FormInit();
  104. Application->ProcessMessages();
  105. TmrShow->Enabled = true;
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TSMS00201::FormInit()
  109. {
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TSMS00201::TmrShowTimer(TObject *Sender)
  113. {
  114. TmrShow->Enabled = false;
  115. Application->ProcessMessages();
  116. DispData();
  117. }
  118. //---------------------------------------------------------------------------
  119. void __fastcall TSMS00201::BtnListAddClick(TObject *Sender)
  120. {
  121. // List Data Add
  122. TWaitCursor crs;
  123. TcxGridTableView *pTvList = TvList2;
  124. TcxDataController *pGDC = pTvList->DataController;
  125. if (pTvList->ViewData->RecordCount <= 0) return;
  126. int nRow = pGDC->FocusedRecordIndex;
  127. if (nRow < 0)
  128. {
  129. Application->MessageBox(L"추가할 대상 SMS 그룹을 먼저 선택하세요", L"SMS 그룹 목록 추가", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  130. return;
  131. }
  132. FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
  133. String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
  134. //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
  135. String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
  136. String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
  137. int nSelRows = TvList1->Controller->SelectedRowCount;
  138. if (nSelRows <= 0)
  139. {
  140. Application->MessageBox(L"추가할 SMS 발송 연락처를 선택하세요", L"SMS 그룹 목록 추가", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  141. return;
  142. }
  143. String sQry;
  144. TADOQuery *pADO = NULL;
  145. sQry = "MERGE INTO TB_SMS_USER_GROP_RLTN L \r\n"
  146. "USING (SELECT :p01 AS SMS_GROP_ID, \r\n"
  147. " :p02 AS SMS_USER_ID \r\n"
  148. " FROM DUAL \r\n"
  149. " ) M \r\n"
  150. "ON (L.SMS_GROP_ID = M.SMS_GROP_ID \r\n"
  151. "AND L.SMS_USER_ID = M.SMS_USER_ID) \r\n"
  152. "WHEN NOT MATCHED THEN \r\n"
  153. " INSERT (L.SMS_GROP_ID, \r\n"
  154. " L.SMS_USER_ID) \r\n"
  155. " VALUES (M.SMS_GROP_ID, \r\n"
  156. " M.SMS_USER_ID) \r\n";
  157. try
  158. {
  159. pADO = new TADOQuery(NULL);
  160. pADO->Close();
  161. pADO->Connection = ITSDb_GetConnection();
  162. ITSDb_SQLText(pADO, sQry);
  163. ITSDb_GetConnection()->BeginTrans();
  164. for (int ii = 0; ii < nSelRows; ii++)
  165. {
  166. int nSelIdx = TvList1->Controller->SelectedRows[ii]->RecordIndex;
  167. String sUserId = TvList1->DataController->Values[nSelIdx][MColumn02->Index];
  168. try
  169. {
  170. ITSDb_SQLBind(pADO, "p01", FGropId);
  171. ITSDb_SQLBind(pADO, "p02", sUserId);
  172. ITSDb_SQLExec(pADO);
  173. }
  174. catch(EDatabaseError &E)
  175. {
  176. ITSDb_GetConnection()->RollbackTrans();
  177. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  178. ShowMessage(String(E.ClassName()) + E.Message);
  179. break;
  180. }
  181. catch(Exception &exception)
  182. {
  183. ITSDb_GetConnection()->RollbackTrans();
  184. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  185. ShowMessage(String(exception.ClassName()) + exception.Message);
  186. break;
  187. }
  188. catch(...)
  189. {
  190. ITSDb_GetConnection()->RollbackTrans();
  191. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  192. ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
  193. break;
  194. }
  195. }
  196. ITSDb_GetConnection()->CommitTrans();
  197. }
  198. __finally
  199. {
  200. if (pADO)
  201. {
  202. pADO->Close();
  203. delete pADO;
  204. }
  205. SelSmsGroupRltnList(FGropId);
  206. }
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TSMS00201::BtnListDeleteClick(TObject *Sender)
  210. {
  211. // List Data Delete
  212. TWaitCursor crs;
  213. int nSelRows = TvList3->Controller->SelectedRowCount;
  214. if (nSelRows <= 0)
  215. {
  216. Application->MessageBox(L"삭제할 SMS 발송 그룹 정보를 선택하세요", L"SMS 그룹 목록 삭제", MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  217. return;
  218. }
  219. String sQry;
  220. TADOQuery *pADO = NULL;
  221. sQry = "DELETE TB_SMS_USER_GROP_RLTN L \r\n"
  222. " WHERE L.SMS_GROP_ID = :p01 \r\n"
  223. " AND L.SMS_USER_ID = :p02 \r\n";
  224. try
  225. {
  226. pADO = new TADOQuery(NULL);
  227. pADO->Close();
  228. pADO->Connection = ITSDb_GetConnection();
  229. ITSDb_SQLText(pADO, sQry);
  230. ITSDb_GetConnection()->BeginTrans();
  231. for (int ii = 0; ii < nSelRows; ii++)
  232. {
  233. int nSelIdx = TvList3->Controller->SelectedRows[ii]->RecordIndex;
  234. String sGropId = TvList3->DataController->Values[nSelIdx][RColumn02->Index];
  235. String sUserId = TvList3->DataController->Values[nSelIdx][RColumn04->Index];
  236. try
  237. {
  238. ITSDb_SQLBind(pADO, "p01", sGropId);
  239. ITSDb_SQLBind(pADO, "p02", sUserId);
  240. ITSDb_SQLExec(pADO);
  241. }
  242. catch(EDatabaseError &E)
  243. {
  244. ITSDb_GetConnection()->RollbackTrans();
  245. ShowMessage(String(E.ClassName()) + E.Message);
  246. break;
  247. }
  248. catch(Exception &exception)
  249. {
  250. ITSDb_GetConnection()->RollbackTrans();
  251. ShowMessage(String(exception.ClassName()) + exception.Message);
  252. break;
  253. }
  254. catch(...)
  255. {
  256. ITSDb_GetConnection()->RollbackTrans();
  257. ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
  258. break;
  259. }
  260. }
  261. ITSDb_GetConnection()->CommitTrans();
  262. }
  263. __finally
  264. {
  265. if (pADO)
  266. {
  267. pADO->Close();
  268. delete pADO;
  269. }
  270. SelSmsGroupRltnList(FGropId);
  271. }
  272. }
  273. //---------------------------------------------------------------------------
  274. void __fastcall TSMS00201::BtnInsert1Click(TObject *Sender)
  275. {
  276. String sNewId = "";
  277. try {
  278. if (!GetUserNewId(sNewId)) return;
  279. TFrmSmsUser *pDlg = new TFrmSmsUser(this->Parent);
  280. pDlg->EdId->Text = sNewId;
  281. pDlg->EdBackTel->Text = "044-300-5545";
  282. pDlg->FDbMode = enJobSave;
  283. pDlg->ShowModal();
  284. if (pDlg->FUpdated)
  285. {
  286. FUserId = pDlg->EdId->Text.Trim();
  287. String sName = pDlg->EdName->Text.Trim();
  288. String sCallTel = pDlg->EdCallTel->Text.Trim();
  289. String sBackTel = pDlg->EdBackTel->Text.Trim();
  290. String sDesc = pDlg->EdDesc->Text.Trim();
  291. String sRegDt = pDlg->EdRegDt->Text.Trim();
  292. SelSmsUserList();
  293. CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
  294. }
  295. delete pDlg;
  296. } catch(...) { }
  297. }
  298. //---------------------------------------------------------------------------
  299. void __fastcall TSMS00201::BtnEdit1Click(TObject *Sender)
  300. {
  301. TcxDataController *pGDC = TvList1->DataController;
  302. if (TvList1->ViewData->RecordCount <= 0) return;
  303. int nRow = pGDC->FocusedRecordIndex;
  304. if( nRow < 0 )
  305. {
  306. Application->MessageBox(L"목록에서 연락처를 선택하세요.", L"SMS 발송 연락처 등록", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  307. return;
  308. }
  309. FUserId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
  310. String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
  311. String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
  312. String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
  313. String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
  314. String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
  315. try {
  316. TFrmSmsUser *pDlg = new TFrmSmsUser(this->Parent);
  317. pDlg->EdId->Text = FUserId;
  318. pDlg->EdName->Text = sName;
  319. pDlg->EdCallTel->Text = sCallTel;
  320. pDlg->EdBackTel->Text = sBackTel;
  321. pDlg->EdDesc->Text = sDesc;
  322. pDlg->EdRegDt->Text = sRegDt;
  323. if (pDlg->EdBackTel->Text == "")
  324. {
  325. pDlg->EdBackTel->Text = "044-300-5545";
  326. }
  327. pDlg->FDbMode = enJobEdit;
  328. pDlg->ShowModal();
  329. if (pDlg->FUpdated)
  330. {
  331. FUserId = pDlg->EdId->Text.Trim();
  332. sName = pDlg->EdName->Text.Trim();
  333. sCallTel = pDlg->EdCallTel->Text.Trim();
  334. sBackTel = pDlg->EdBackTel->Text.Trim();
  335. sDesc = pDlg->EdDesc->Text.Trim();
  336. sRegDt = pDlg->EdRegDt->Text.Trim();
  337. SelSmsUserList();
  338. SelSmsGroupRltnList(FGropId);
  339. CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
  340. }
  341. delete pDlg;
  342. } catch(...) { }
  343. }
  344. //---------------------------------------------------------------------------
  345. void __fastcall TSMS00201::BtnDelete1Click(TObject *Sender)
  346. {
  347. TcxDataController *pGDC = TvList1->DataController;
  348. if (TvList1->ViewData->RecordCount <= 0) return;
  349. int nRow = pGDC->FocusedRecordIndex;
  350. if( nRow < 0 )
  351. {
  352. Application->MessageBox(L"목록에서 연락처를 선택하세요.", L"SMS 발송 연락처 삭제", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  353. return;
  354. }
  355. String sId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
  356. String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
  357. String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
  358. String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
  359. String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
  360. String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
  361. String sMsg = "";
  362. sMsg += "<<< ID: " + sId + " >>>\r\n";
  363. sMsg += "<<< 사용자: " + sName + " >>>\r\n";
  364. sMsg += "<<< 연락처 정보를 삭제 하시겠습니까? >>>\r\n";
  365. sMsg += "<<< 연락처-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
  366. if (Application->MessageBox(sMsg.c_str(), L"SMS 발송 연락처 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  367. TADOQuery *pADOD = NULL;
  368. String sQryD1, sQryD2;
  369. try
  370. {
  371. sQryD1 = "DELETE TB_SMS_USER_GROP_RLTN \r\n"
  372. " WHERE SMS_USER_ID = :p01 \r\n";
  373. sQryD2 = "DELETE TB_SMS_USER \r\n"
  374. " WHERE SMS_USER_ID = :p01 \r\n";
  375. try
  376. {
  377. pADOD = new TADOQuery(NULL);
  378. pADOD->Close();
  379. pADOD->Connection = ITSDb_GetConnection();
  380. ITSDb_GetConnection()->BeginTrans();
  381. ITSDb_SQLText(pADOD, sQryD1);
  382. ITSDb_SQLBind(pADOD, "p01", sId);
  383. ITSDb_SQLExec(pADOD);
  384. ITSDb_SQLText(pADOD, sQryD2);
  385. ITSDb_SQLBind(pADOD, "p01", sId);
  386. ITSDb_SQLExec(pADOD);
  387. ITSDb_GetConnection()->CommitTrans();
  388. Application->MessageBox(L"SMS 발송 연락처 정보를 삭제 하였습니다.",
  389. L"SMS 발송 연락처 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  390. FUserId = "";
  391. SelSmsUserList();
  392. SelSmsGroupRltnList(FGropId);
  393. CMM_SetGridFocusRow(CxList1, TvList1, FUserId, MColumn02->Index);
  394. }
  395. catch(EDatabaseError &E)
  396. {
  397. ITSDb_GetConnection()->RollbackTrans();
  398. ShowMessage(String(E.ClassName()) + E.Message);
  399. }
  400. catch(Exception &exception)
  401. {
  402. ITSDb_GetConnection()->RollbackTrans();
  403. ShowMessage(String(exception.ClassName()) + exception.Message);
  404. }
  405. catch(...)
  406. {
  407. ITSDb_GetConnection()->RollbackTrans();
  408. ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
  409. }
  410. }
  411. __finally
  412. {
  413. if (pADOD)
  414. {
  415. pADOD->Close();
  416. delete pADOD;
  417. }
  418. }
  419. }
  420. //---------------------------------------------------------------------------
  421. void __fastcall TSMS00201::BtnInsertGroupClick(TObject *Sender)
  422. {
  423. String sNewId = "";
  424. try {
  425. if (!GetGroupNewId(sNewId)) return;
  426. TFrmSmsGroup *pDlg = new TFrmSmsGroup(this->Parent);
  427. pDlg->EdId->Text = sNewId;
  428. pDlg->FDbMode = enJobSave;
  429. pDlg->ShowModal();
  430. if (pDlg->FUpdated)
  431. {
  432. FGropId = pDlg->EdId->Text;
  433. SelSmsGroupList();
  434. SelSmsGroupRltnList(FGropId);
  435. CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
  436. FGroupChanged = true;
  437. }
  438. delete pDlg;
  439. } catch(...) { }
  440. }
  441. //---------------------------------------------------------------------------
  442. void __fastcall TSMS00201::BtnEditGroupClick(TObject *Sender)
  443. {
  444. TcxDataController *pGDC = TvList2->DataController;
  445. if (TvList2->ViewData->RecordCount <= 0) return;
  446. int nRow = pGDC->FocusedRecordIndex;
  447. if( nRow < 0 )
  448. {
  449. Application->MessageBox(L"목록에서 그룹을 선택하세요.", L"SMS 발송 그룹 등록", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  450. return;
  451. }
  452. FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
  453. String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
  454. //String sGrade = pGDC->Values[nRow][SColumn04->Index];
  455. String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
  456. String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
  457. try {
  458. TFrmSmsGroup *pDlg = new TFrmSmsGroup(this->Parent);
  459. pDlg->FDbMode = enJobEdit;
  460. pDlg->EdId->Text = FGropId;
  461. pDlg->EdName->Text = sName;
  462. pDlg->EdDesc->Text = sDesc;
  463. pDlg->EdRegDt->Text = sRegDt;
  464. pDlg->ShowModal();
  465. if (pDlg->FUpdated)
  466. {
  467. FGropId = pDlg->EdId->Text;
  468. SelSmsGroupList();
  469. SelSmsGroupRltnList(FGropId);
  470. CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
  471. FGroupChanged = true;
  472. }
  473. delete pDlg;
  474. } catch(...) { }
  475. }
  476. //---------------------------------------------------------------------------
  477. void __fastcall TSMS00201::BtnDeleteGroupClick(TObject *Sender)
  478. {
  479. TcxDataController *pGDC = TvList2->DataController;
  480. if (TvList2->ViewData->RecordCount <= 0) return;
  481. int nRow = pGDC->FocusedRecordIndex;
  482. if( nRow < 0 )
  483. {
  484. Application->MessageBox(L"목록에서 그룹을 선택하세요.", L"SMS 발송 그룹 삭제", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  485. return;
  486. }
  487. String sId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
  488. String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
  489. //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
  490. String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
  491. String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
  492. String sMsg = "";
  493. sMsg += "<<< ID: " + sId + " >>>\r\n";
  494. sMsg += "<<< 그룹명: " + sName + " >>>\r\n";
  495. sMsg += "<<< SMS 발송 그룹 정보를 삭제 하시겠습니까? >>>\r\n\r\n";
  496. sMsg += "<<< 연락처-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
  497. sMsg += "<<< 장애유형-발송그룹 정보가 있는 경우 함께 삭제 됩니다. >>>\r\n";
  498. if (Application->MessageBox(sMsg.c_str(), L"SMS 발송 그룹 정보 삭제", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  499. // delete
  500. TADOQuery *pADOD = NULL;
  501. String sQryD1, sQryD2, sQryD3;
  502. try
  503. {
  504. sQryD1 = "DELETE TB_SMS_USER_GROP_RLTN \r\n"
  505. " WHERE SMS_GROP_ID = :p01 \r\n";
  506. sQryD2 = "DELETE TB_SMS_FAIL_GROP_RLTN \r\n"
  507. " WHERE SMS_GROP_ID = :p01 \r\n";
  508. sQryD3 = "DELETE TB_SMS_USER_GROP \r\n"
  509. " WHERE SMS_GROP_ID = :p01 \r\n";
  510. try
  511. {
  512. pADOD = new TADOQuery(NULL);
  513. pADOD->Close();
  514. pADOD->Connection = ITSDb_GetConnection();
  515. ITSDb_GetConnection()->BeginTrans();
  516. ITSDb_SQLText(pADOD, sQryD1);
  517. ITSDb_SQLBind(pADOD, "p01", sId);
  518. ITSDb_SQLExec(pADOD);
  519. ITSDb_SQLText(pADOD, sQryD2);
  520. ITSDb_SQLBind(pADOD, "p01", sId);
  521. ITSDb_SQLExec(pADOD);
  522. ITSDb_SQLText(pADOD, sQryD3);
  523. ITSDb_SQLBind(pADOD, "p01", sId);
  524. ITSDb_SQLExec(pADOD);
  525. ITSDb_GetConnection()->CommitTrans();
  526. Application->MessageBox(L"SMS 발송 그룹 정보를 삭제 하였습니다.",
  527. L"SMS 발송 그룹 정보 삭제", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  528. FGropId = "";
  529. SelSmsGroupList();
  530. SelSmsGroupRltnList(FGropId);
  531. CMM_SetGridFocusRow(CxList2, TvList2, FGropId, SColumn02->Index);
  532. FGroupChanged = true;
  533. }
  534. catch(EDatabaseError &E)
  535. {
  536. ITSDb_GetConnection()->RollbackTrans();
  537. ShowMessage(String(E.ClassName()) + E.Message);
  538. }
  539. catch(Exception &exception)
  540. {
  541. ITSDb_GetConnection()->RollbackTrans();
  542. ShowMessage(String(exception.ClassName()) + exception.Message);
  543. }
  544. catch(...)
  545. {
  546. ITSDb_GetConnection()->RollbackTrans();
  547. ShowMessage("데이터 작업 중에 알수없는 DB 오류가 발생하였습니다.");
  548. }
  549. }
  550. __finally
  551. {
  552. if (pADOD)
  553. {
  554. pADOD->Close();
  555. delete pADOD;
  556. }
  557. }
  558. }
  559. //---------------------------------------------------------------------------
  560. bool __fastcall TSMS00201::GetUserNewId(String &ANewId)
  561. {
  562. String sQry;
  563. TADOQuery *pADO = NULL;
  564. sQry = "SELECT NVL(MAX(SMS_USER_ID), 0) + 1 AS NEWID \r\n"
  565. " FROM TB_SMS_USER \r\n";
  566. ANewId = "";
  567. try
  568. {
  569. try
  570. {
  571. pADO = new TADOQuery(NULL);
  572. pADO->Close();
  573. pADO->Connection = ITSDb_GetConnection();
  574. pADO->SQL->Clear();
  575. pADO->SQL->Text = sQry;
  576. pADO->Open();
  577. ANewId = pADO->FieldByName("NEWID")->AsString;
  578. return true;
  579. }
  580. catch(EDatabaseError &E)
  581. {
  582. throw Exception(String(E.ClassName()) + E.Message);
  583. }
  584. catch(Exception &exception)
  585. {
  586. throw Exception(String(exception.ClassName()) + exception.Message);
  587. }
  588. catch(...)
  589. {
  590. throw Exception("알수없는 DB 오류가 발생하였습니다.");
  591. }
  592. }
  593. __finally
  594. {
  595. if (pADO)
  596. {
  597. pADO->Close();
  598. delete pADO;
  599. }
  600. }
  601. return false;
  602. }
  603. //---------------------------------------------------------------------------
  604. bool __fastcall TSMS00201::GetGroupNewId(String &ANewId)
  605. {
  606. String sQry;
  607. TADOQuery *pADO = NULL;
  608. sQry = "SELECT NVL(MAX(SMS_GROP_ID), 0) + 1 AS NEWID \r\n"
  609. " FROM TB_SMS_USER_GROP \r\n";
  610. ANewId = "";
  611. try
  612. {
  613. try
  614. {
  615. pADO = new TADOQuery(NULL);
  616. pADO->Close();
  617. pADO->Connection = ITSDb_GetConnection();
  618. pADO->SQL->Clear();
  619. pADO->SQL->Text = sQry;
  620. pADO->Open();
  621. ANewId = pADO->FieldByName("NEWID")->AsString;
  622. return true;
  623. }
  624. catch(EDatabaseError &E)
  625. {
  626. throw Exception(String(E.ClassName()) + E.Message);
  627. }
  628. catch(Exception &exception)
  629. {
  630. throw Exception(String(exception.ClassName()) + exception.Message);
  631. }
  632. catch(...)
  633. {
  634. throw Exception("알수없는 DB 오류가 발생하였습니다.");
  635. }
  636. }
  637. __finally
  638. {
  639. if (pADO)
  640. {
  641. pADO->Close();
  642. delete pADO;
  643. }
  644. }
  645. return false;
  646. }
  647. //---------------------------------------------------------------------------
  648. void __fastcall TSMS00201::DispData()
  649. {
  650. FUserId = "";
  651. FGropId = "";
  652. SelSmsUserList();
  653. SelSmsGroupList();
  654. SelSmsGroupRltnList(FGropId);
  655. }
  656. //---------------------------------------------------------------------------
  657. void __fastcall TSMS00201::SelSmsUserList()
  658. {
  659. TSqlCursor sqlCrs;
  660. String sQry;
  661. TADOQuery *pADO = ADOQry;
  662. TcxGridTableView *pTvList = TvList1;
  663. TcxDataController *pGDC = pTvList->DataController;
  664. CMM_ClearGridTableView(pTvList);
  665. sQry = "SELECT A.SMS_USER_ID, \r\n"
  666. " A.SMS_USER_NM, \r\n"
  667. " A.SMS_USER_TEL, \r\n"
  668. " A.SMS_USER_EXPL, \r\n"
  669. " A.SMS_RPLY_TEL, \r\n"
  670. " A.RGST_DT \r\n"
  671. " FROM TB_SMS_USER A \r\n"
  672. " ORDER BY A.SMS_USER_ID \r\n";
  673. try
  674. {
  675. pADO->Connection = ITSDb_GetConnection();
  676. ITSDb_SQLText(pADO, sQry);
  677. ITSDb_SQLOpen(pADO);
  678. int nRow = 0;
  679. try
  680. {
  681. pTvList->BeginUpdate();
  682. pGDC->RecordCount = pADO->RecordCount;
  683. for( ; !pADO->Eof; pADO->Next(), nRow++)
  684. {
  685. pGDC->Values[nRow][MColumn02->Index] = pADO->FieldByName("SMS_USER_ID")->AsString;
  686. pGDC->Values[nRow][MColumn03->Index] = pADO->FieldByName("SMS_USER_NM")->AsString;
  687. pGDC->Values[nRow][MColumn04->Index] = pADO->FieldByName("SMS_USER_TEL")->AsString;
  688. pGDC->Values[nRow][MColumn05->Index] = pADO->FieldByName("SMS_RPLY_TEL")->AsString;
  689. pGDC->Values[nRow][MColumn06->Index] = pADO->FieldByName("SMS_USER_EXPL")->AsString;
  690. pGDC->Values[nRow][MColumn07->Index] = ITSUtil_StrToTime(pADO->FieldByName("RGST_DT")->AsString);
  691. }
  692. }
  693. __finally
  694. {
  695. if (pADO)
  696. {
  697. pADO->Close();
  698. }
  699. pTvList->EndUpdate();
  700. //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
  701. }
  702. }
  703. catch(EDatabaseError &E)
  704. {
  705. throw Exception(String(E.ClassName()) + E.Message);
  706. }
  707. catch(...)
  708. {
  709. throw Exception("알수없는 오류가 발생하였습니다.");
  710. }
  711. }
  712. //---------------------------------------------------------------------------
  713. void __fastcall TSMS00201::SelSmsGroupList()
  714. {
  715. TSqlCursor sqlCrs;
  716. String sQry;
  717. TADOQuery *pADO = ADOQry;
  718. TcxGridTableView *pTvList = TvList2;
  719. TcxDataController *pGDC = pTvList->DataController;
  720. CMM_ClearGridTableView(pTvList);
  721. sQry = "SELECT A.SMS_GROP_ID, \r\n"
  722. " A.SMS_GROP_NM, \r\n"
  723. " A.SMS_GROP_EXPL, \r\n"
  724. " A.RGST_DT \r\n"
  725. " FROM TB_SMS_USER_GROP A \r\n"
  726. " ORDER BY A.SMS_GROP_ID \r\n";
  727. try
  728. {
  729. pADO->Connection = ITSDb_GetConnection();
  730. ITSDb_SQLText(pADO, sQry);
  731. ITSDb_SQLOpen(pADO);
  732. int nRow = 0;
  733. try
  734. {
  735. pTvList->BeginUpdate();
  736. pGDC->RecordCount = pADO->RecordCount;
  737. for( ; !pADO->Eof; pADO->Next(), nRow++)
  738. {
  739. pGDC->Values[nRow][SColumn02->Index] = pADO->FieldByName("SMS_GROP_ID")->AsString;
  740. pGDC->Values[nRow][SColumn03->Index] = pADO->FieldByName("SMS_GROP_NM")->AsString;
  741. pGDC->Values[nRow][SColumn05->Index] = pADO->FieldByName("SMS_GROP_EXPL")->AsString;
  742. pGDC->Values[nRow][SColumn06->Index] = ITSUtil_StrToTime(pADO->FieldByName("RGST_DT")->AsString);
  743. }
  744. }
  745. __finally
  746. {
  747. if (pADO)
  748. {
  749. pADO->Close();
  750. }
  751. pTvList->EndUpdate();
  752. //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
  753. }
  754. }
  755. catch(EDatabaseError &E)
  756. {
  757. throw Exception(String(E.ClassName()) + E.Message);
  758. }
  759. catch(...)
  760. {
  761. throw Exception("알수없는 오류가 발생하였습니다.");
  762. }
  763. }
  764. //---------------------------------------------------------------------------
  765. void __fastcall TSMS00201::SelSmsGroupRltnList(String AGroupId)
  766. {
  767. TSqlCursor sqlCrs;
  768. String sQry;
  769. TADOQuery *pADO = ADOQry;
  770. TcxGridTableView *pTvList = TvList3;
  771. TcxDataController *pGDC = pTvList->DataController;
  772. CMM_ClearGridTableView(pTvList);
  773. sQry = "SELECT A.SMS_GROP_ID, A.SMS_USER_ID, \r\n"
  774. " B.SMS_USER_NM, B.SMS_USER_TEL, B.SMS_USER_EXPL, \r\n"
  775. " B.SMS_RPLY_TEL, B.RGST_DT AS URGST_DT, \r\n"
  776. " C.SMS_GROP_NM, C.SMS_GROP_EXPL, C.RGST_DT AS GRGST_DT \r\n"
  777. " FROM TB_SMS_USER_GROP_RLTN A, \r\n"
  778. " TB_SMS_USER B, \r\n"
  779. " TB_SMS_USER_GROP C \r\n"
  780. " WHERE A.SMS_GROP_ID = :p01 \r\n"
  781. " AND A.SMS_GROP_ID = C.SMS_GROP_ID \r\n"
  782. " AND A.SMS_USER_ID = B.SMS_USER_ID \r\n";
  783. try
  784. {
  785. pADO->Connection = ITSDb_GetConnection();
  786. ITSDb_SQLText(pADO, sQry);
  787. ITSDb_SQLBind(pADO, "p01", AGroupId);
  788. ITSDb_SQLOpen(pADO);
  789. int nRow = 0;
  790. try
  791. {
  792. pTvList->BeginUpdate();
  793. pGDC->RecordCount = pADO->RecordCount;
  794. for( ; !pADO->Eof; pADO->Next(), nRow++)
  795. {
  796. pGDC->Values[nRow][RColumn02->Index] = pADO->FieldByName("SMS_GROP_ID")->AsString;
  797. pGDC->Values[nRow][RColumn03->Index] = pADO->FieldByName("SMS_GROP_NM")->AsString;
  798. pGDC->Values[nRow][RColumn04->Index] = pADO->FieldByName("SMS_USER_ID")->AsString;
  799. pGDC->Values[nRow][RColumn05->Index] = pADO->FieldByName("SMS_USER_NM")->AsString;
  800. pGDC->Values[nRow][RColumn06->Index] = pADO->FieldByName("SMS_USER_TEL")->AsString;
  801. pGDC->Values[nRow][RColumn07->Index] = pADO->FieldByName("SMS_RPLY_TEL")->AsString;
  802. }
  803. }
  804. __finally
  805. {
  806. if (pADO)
  807. {
  808. pADO->Close();
  809. }
  810. pTvList->EndUpdate();
  811. //LblRecords->Caption = FormatFloat("##,##0", pGDC->RecordCount) + " 건";
  812. }
  813. }
  814. catch(EDatabaseError &E)
  815. {
  816. throw Exception(String(E.ClassName()) + E.Message);
  817. }
  818. catch(...)
  819. {
  820. throw Exception("알수없는 오류가 발생하였습니다.");
  821. }
  822. }
  823. //---------------------------------------------------------------------------
  824. void __fastcall TSMS00201::TvList1FocusedRecordChanged(TcxCustomGridTableView *Sender,
  825. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  826. bool ANewItemRecordFocusingChanged)
  827. {
  828. DispSmsUser();
  829. }
  830. //---------------------------------------------------------------------------
  831. void __fastcall TSMS00201::TvList2FocusedRecordChanged(TcxCustomGridTableView *Sender,
  832. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  833. bool ANewItemRecordFocusingChanged)
  834. {
  835. DispSmsGroup();
  836. }
  837. //---------------------------------------------------------------------------
  838. void __fastcall TSMS00201::DispSmsUser()
  839. {
  840. BtnDelete1->Enabled = false;
  841. BtnEdit1->Enabled = false;
  842. TcxGridTableView *pTvList = TvList1;
  843. TcxDataController *pGDC = pTvList->DataController;
  844. if (pTvList->ViewData->RecordCount <= 0) return;
  845. int nRow = pGDC->FocusedRecordIndex;
  846. if (nRow < 0) return;
  847. FUserId = VarToStr(pGDC->Values[nRow][MColumn02->Index]);
  848. String sName = VarToStr(pGDC->Values[nRow][MColumn03->Index]);
  849. String sCallTel = VarToStr(pGDC->Values[nRow][MColumn04->Index]);
  850. String sBackTel = VarToStr(pGDC->Values[nRow][MColumn05->Index]);
  851. String sDesc = VarToStr(pGDC->Values[nRow][MColumn06->Index]);
  852. String sRegDt = VarToStr(pGDC->Values[nRow][MColumn07->Index]);
  853. BtnDelete1->Enabled = true;
  854. BtnEdit1->Enabled = true;
  855. }
  856. //---------------------------------------------------------------------------
  857. void __fastcall TSMS00201::DispSmsGroup()
  858. {
  859. BtnDeleteGroup->Enabled = false;
  860. BtnEditGroup->Enabled = false;
  861. TcxGridTableView *pTvList = TvList2;
  862. TcxDataController *pGDC = pTvList->DataController;
  863. if (pTvList->ViewData->RecordCount <= 0) return;
  864. int nRow = pGDC->FocusedRecordIndex;
  865. if (nRow < 0) return;
  866. FGropId = VarToStr(pGDC->Values[nRow][SColumn02->Index]);
  867. String sName = VarToStr(pGDC->Values[nRow][SColumn03->Index]);
  868. //String sGrade = VarToStr(pGDC->Values[nRow][SColumn04->Index]);
  869. String sDesc = VarToStr(pGDC->Values[nRow][SColumn05->Index]);
  870. String sRegDt = VarToStr(pGDC->Values[nRow][SColumn06->Index]);
  871. BtnDeleteGroup->Enabled = true;
  872. BtnEditGroup->Enabled = true;
  873. SelSmsGroupRltnList(FGropId);
  874. }
  875. //---------------------------------------------------------------------------