123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #pragma hdrstop
- #include "FrmSmsUserF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxGroupBox"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #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 "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "FRAME_NodeListF"
- #pragma link "cxTextEdit"
- #pragma resource "*.dfm"
- TFrmSmsUser *FrmSmsUser = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmSmsUser::TFrmSmsUser(TComponent* Owner)
- : TForm(Owner)
- {
- ITSSkin_Load(this);
- //CMM_LoadForm(g_sFormsDir, this);
- FUpdated = false;
- }
- //---------------------------------------------------------------------------
- /*
- * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
- * Form과 DataModule class를 delete시킨다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TFrmSmsUser::CommClose()
- {
- try
- {
- //CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- /*
- * Form을 보여줄때 호출되는 event 메서드이다.
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TFrmSmsUser::FormShow(TObject *Sender)
- {
- Refresh();
- }
- //---------------------------------------------------------------------------
- /*
- * Close 버튼 클릭 이벤트 핸들러
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TFrmSmsUser::BtnCloseClick(TObject *Sender)
- {
- FUpdated = false;
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmSmsUser::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- FrmSmsUser = NULL;
- //Action = caFree;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFrmSmsUser::CheckField()
- {
- String sId = EdId->Text.Trim();
- String sName = EdName->Text.Trim();
- String sCallTel = EdCallTel->Text.Trim();
- String sBackTel = EdBackTel->Text.Trim();
- String sDesc = EdDesc->Text.Trim();
- if (sId == "")
- {
- Application->MessageBox(L"ID를 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- if (sName == "")
- {
- Application->MessageBox(L"사용자명을 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- if (sCallTel == "")
- {
- Application->MessageBox(L"전화번호를 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- if (sBackTel == "")
- {
- Application->MessageBox(L"회신 전화번호를 확인 하세요.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmSmsUser::BtnSaveClick(TObject *Sender)
- {
- String sMsg;
- String sId = EdId->Text.Trim();
- String sName = EdName->Text.Trim();
- String sCallTel = EdCallTel->Text.Trim();
- String sBackTel = EdBackTel->Text.Trim();
- String sDesc = EdDesc->Text.Trim();
- String sRegDt = Now().FormatString("yyyymmddhhnnss");//EdRegDt->Text.Trim();
- EdRegDt->Text = sRegDt;
- if (!CheckField()) return;
- if (FDbMode == enJobSave)
- sMsg = "SMS 연락처 정보를 등록 하시겠습까?";
- else
- sMsg = "SMS 연락처 정보를 수정 하시겠습까?";
- if (Application->MessageBox(sMsg.c_str(), Caption.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "MERGE INTO TB_SMS_USER L \r\n"
- "USING (SELECT :p01 AS SMS_USER_ID, \r\n"
- " :p02 AS SMS_USER_NM, \r\n"
- " :p03 AS SMS_USER_TEL, \r\n"
- " :p04 AS SMS_RPLY_TEL, \r\n"
- " :p05 AS SMS_USER_EXPL, \r\n"
- " :p06 AS RGST_DT \r\n"
- " FROM DUAL \r\n"
- " ) M \r\n"
- "ON (L.SMS_USER_ID = M.SMS_USER_ID) \r\n"
- "WHEN MATCHED THEN \r\n"
- " UPDATE SET L.SMS_USER_NM = M.SMS_USER_NM, \r\n"
- " L.SMS_USER_TEL = M.SMS_USER_TEL, \r\n"
- " L.SMS_RPLY_TEL = M.SMS_RPLY_TEL, \r\n"
- " L.SMS_USER_EXPL = M.SMS_USER_EXPL, \r\n"
- " L.RGST_DT = M.RGST_DT \r\n"
- "WHEN NOT MATCHED THEN \r\n"
- " INSERT (L.SMS_USER_ID, \r\n"
- " L.SMS_USER_NM, \r\n"
- " L.SMS_USER_TEL, \r\n"
- " L.SMS_RPLY_TEL, \r\n"
- " L.SMS_USER_EXPL, \r\n"
- " L.RGST_DT) \r\n"
- " VALUES (M.SMS_USER_ID, \r\n"
- " M.SMS_USER_NM, \r\n"
- " M.SMS_USER_TEL, \r\n"
- " M.SMS_RPLY_TEL, \r\n"
- " M.SMS_USER_EXPL, \r\n"
- " M.RGST_DT) \r\n";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", sId);
- ITSDb_SQLBind(pADO, "p02", sName);
- ITSDb_SQLBind(pADO, "p03", sCallTel);
- ITSDb_SQLBind(pADO, "p04", sBackTel);
- ITSDb_SQLBind(pADO, "p05", sDesc);
- ITSDb_SQLBind(pADO, "p06", sRegDt);
- EdRegDt->Text = sRegDt;
- ITSDb_GetConnection()->BeginTrans();
- ITSDb_SQLExec(pADO);
- ITSDb_GetConnection()->CommitTrans();
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage(String(E.ClassName()) + E.Message);
- return;
- }
- catch(Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage(String(exception.ClassName()) + exception.Message);
- return;
- }
- catch(...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- ShowMessage("데이터 저장 중에 알수없는 DB 오류가 발생하였습니다.");
- return;
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- if (FDbMode == enJobSave)
- sMsg = "SMS 연락처 정보를 등록 하였습니다.";
- else
- sMsg = "SMS 연락처 정보를 수정 하였습니다.";
- Application->MessageBox(sMsg.c_str(), Caption.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- FUpdated = true;
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmSmsUser::EdCallTelKeyPress(TObject *Sender, wchar_t &Key)
- {
- if (Key > '9' || Key < '0')
- {
- if (Key != VK_BACK && Key != VK_TAB && Key != '-')
- Key = 0;
- }
- }
- //---------------------------------------------------------------------------
|