FrmSmsGroupF.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2011/12/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "ITSSkinF.h"
  13. #include "ITSUtilF.h"
  14. #include "ITSDbF.h"
  15. #include "AppGlobalF.h"
  16. #pragma hdrstop
  17. #include "FrmSmsGroupF.h"
  18. //---------------------------------------------------------------------------
  19. #pragma package(smart_init)
  20. #pragma link "cxButtons"
  21. #pragma link "cxContainer"
  22. #pragma link "cxControls"
  23. #pragma link "cxEdit"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGroupBox"
  26. #pragma link "cxLookAndFeelPainters"
  27. #pragma link "cxLookAndFeels"
  28. #pragma link "dxSkinBlack"
  29. #pragma link "dxSkinBlue"
  30. #pragma link "dxSkinCaramel"
  31. #pragma link "dxSkinCoffee"
  32. #pragma link "dxSkinDarkRoom"
  33. #pragma link "dxSkinDarkSide"
  34. #pragma link "dxSkinFoggy"
  35. #pragma link "dxSkinGlassOceans"
  36. #pragma link "dxSkiniMaginary"
  37. #pragma link "dxSkinLilian"
  38. #pragma link "dxSkinLiquidSky"
  39. #pragma link "dxSkinLondonLiquidSky"
  40. #pragma link "dxSkinMcSkin"
  41. #pragma link "dxSkinMoneyTwins"
  42. #pragma link "dxSkinOffice2007Black"
  43. #pragma link "dxSkinOffice2007Blue"
  44. #pragma link "dxSkinOffice2007Green"
  45. #pragma link "dxSkinOffice2007Pink"
  46. #pragma link "dxSkinOffice2007Silver"
  47. #pragma link "dxSkinOffice2010Black"
  48. #pragma link "dxSkinOffice2010Blue"
  49. #pragma link "dxSkinOffice2010Silver"
  50. #pragma link "dxSkinsCore"
  51. #pragma link "dxSkinSeven"
  52. #pragma link "dxSkinSharp"
  53. #pragma link "dxSkinSilver"
  54. #pragma link "dxSkinStardust"
  55. #pragma link "FRAME_NodeListF"
  56. #pragma link "cxTextEdit"
  57. #pragma resource "*.dfm"
  58. TFrmSmsGroup *FrmSmsGroup = NULL;
  59. //---------------------------------------------------------------------------
  60. __fastcall TFrmSmsGroup::TFrmSmsGroup(TComponent* Owner)
  61. : TForm(Owner)
  62. {
  63. ITSSkin_Load(this);
  64. //CMM_LoadForm(g_sFormsDir, this);
  65. FUpdated = false;
  66. }
  67. //---------------------------------------------------------------------------
  68. /*
  69. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  70. * Form과 DataModule class를 delete시킨다.
  71. * arguments
  72. *
  73. * return
  74. * void
  75. */
  76. void __fastcall TFrmSmsGroup::CommClose()
  77. {
  78. try
  79. {
  80. //CMM_SaveForm(g_sFormsDir, this);
  81. }
  82. catch(...)
  83. {
  84. }
  85. }
  86. //---------------------------------------------------------------------------
  87. /*
  88. * Form을 보여줄때 호출되는 event 메서드이다.
  89. * arguments
  90. * Sender : event handler 객체
  91. * return
  92. * void
  93. */
  94. void __fastcall TFrmSmsGroup::FormShow(TObject *Sender)
  95. {
  96. Refresh();
  97. }
  98. //---------------------------------------------------------------------------
  99. /*
  100. * Close 버튼 클릭 이벤트 핸들러
  101. * arguments
  102. * Sender : event handler 객체
  103. * return
  104. * void
  105. */
  106. void __fastcall TFrmSmsGroup::BtnCloseClick(TObject *Sender)
  107. {
  108. FUpdated = false;
  109. Close();
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TFrmSmsGroup::FormClose(TObject *Sender, TCloseAction &Action)
  113. {
  114. CommClose();
  115. FrmSmsGroup = NULL;
  116. //Action = caFree;
  117. }
  118. //---------------------------------------------------------------------------
  119. bool __fastcall TFrmSmsGroup::CheckField()
  120. {
  121. String sId = EdId->Text.Trim();
  122. String sName = EdName->Text.Trim();
  123. //String sGrade = EdGrade->Text.Trim();
  124. if (sId == "")
  125. {
  126. Application->MessageBox(L"ID를 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  127. return false;
  128. }
  129. if (sName == "")
  130. {
  131. Application->MessageBox(L"그룹명을 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  132. return false;
  133. }
  134. #if 0
  135. if (sGrade == "")
  136. {
  137. Application->MessageBox(L"등급을 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  138. return false;
  139. }
  140. #endif
  141. return true;
  142. }
  143. //---------------------------------------------------------------------------
  144. void __fastcall TFrmSmsGroup::BtnSaveClick(TObject *Sender)
  145. {
  146. String sMsg;
  147. String sId = EdId->Text.Trim();
  148. String sName = EdName->Text.Trim();
  149. //String sGrade = EdGrade->Text.Trim();
  150. String sDesc = EdDesc->Text.Trim();
  151. String sRegDt = Now().FormatString("yyyymmddhhnnss");//EdRegDt->Text.Trim();
  152. if (!CheckField()) return;
  153. if (FDbMode == enJobSave)
  154. sMsg = "SMS 연락처 그룹 정보를 등록 하시겠습까?";
  155. else
  156. sMsg = "SMS 연락처 그룹 정보를 수정 하시겠습까?";
  157. if (Application->MessageBox(sMsg.c_str(), Caption.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  158. String sQry;
  159. TADOQuery *pADO = NULL;
  160. sQry = "MERGE INTO TB_SMS_USER_GROP L \r\n"
  161. "USING (SELECT :p01 AS SMS_GROP_ID, \r\n"
  162. " :p02 AS SMS_GROP_NM, \r\n"
  163. " :p03 AS SMS_GROP_EXPL, \r\n"
  164. " :p04 AS RGST_DT \r\n"
  165. " FROM DUAL \r\n"
  166. " ) M \r\n"
  167. "ON (L.SMS_GROP_ID = M.SMS_GROP_ID) \r\n"
  168. "WHEN MATCHED THEN \r\n"
  169. " UPDATE SET L.SMS_GROP_NM = M.SMS_GROP_NM, \r\n"
  170. " L.SMS_GROP_EXPL = SMS_GROP_EXPL, \r\n"
  171. " L.RGST_DT = M.RGST_DT \r\n"
  172. "WHEN NOT MATCHED THEN \r\n"
  173. " INSERT (L.SMS_GROP_ID, \r\n"
  174. " L.SMS_GROP_NM, \r\n"
  175. " L.SMS_GROP_EXPL, \r\n"
  176. " L.RGST_DT) \r\n"
  177. " VALUES (M.SMS_GROP_ID, \r\n"
  178. " M.SMS_GROP_NM, \r\n"
  179. " M.SMS_GROP_EXPL, \r\n"
  180. " M.RGST_DT) \r\n";
  181. try
  182. {
  183. try
  184. {
  185. pADO = new TADOQuery(NULL);
  186. pADO->Close();
  187. pADO->Connection = ITSDb_GetConnection();
  188. ITSDb_SQLText(pADO, sQry);
  189. ITSDb_SQLBind(pADO, "p01", sId);
  190. ITSDb_SQLBind(pADO, "p02", sName);
  191. ITSDb_SQLBind(pADO, "p03", sDesc);
  192. ITSDb_SQLBind(pADO, "p04", sRegDt);
  193. EdRegDt->Text = sRegDt;
  194. ITSDb_GetConnection()->BeginTrans();
  195. ITSDb_SQLExec(pADO);
  196. ITSDb_GetConnection()->CommitTrans();
  197. }
  198. catch(EDatabaseError &E)
  199. {
  200. ITSDb_GetConnection()->RollbackTrans();
  201. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  202. ShowMessage(String(E.ClassName()) + E.Message);
  203. return;
  204. }
  205. catch(Exception &exception)
  206. {
  207. ITSDb_GetConnection()->RollbackTrans();
  208. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  209. ShowMessage(String(exception.ClassName()) + exception.Message);
  210. return;
  211. }
  212. catch(...)
  213. {
  214. ITSDb_GetConnection()->RollbackTrans();
  215. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  216. ShowMessage("데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
  217. return;
  218. }
  219. }
  220. __finally
  221. {
  222. if (pADO)
  223. {
  224. pADO->Close();
  225. delete pADO;
  226. }
  227. }
  228. if (FDbMode == enJobSave)
  229. sMsg = "SMS 연락처 그룹 정보를 등록 하였습니다.";
  230. else
  231. sMsg = "SMS 연락처 그룹 정보를 수정 하였습니다.";
  232. Application->MessageBox(sMsg.c_str(), Caption.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  233. FUpdated = true;
  234. Close();
  235. }
  236. //---------------------------------------------------------------------------