| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- //#include "EncryptionF.h"
- #pragma hdrstop
- #include "FrmPswdChngeF.h"
- #include "FrmLoginF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxGraphics"
- #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 resource "*.dfm"
- TFRMPswdChnge *FRMPswdChnge = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFRMPswdChnge::TFRMPswdChnge(TComponent* Owner)
- : TForm(Owner)
- {
- //ITSSkin_Load(this);
- }
- //---------------------------------------------------------------------------
- /*
- * 사용자가 비밀번호 변경을 요청함.
- * parameter
- * return
- *
- */
- void __fastcall TFRMPswdChnge::btnPswdChngeClick(TObject *Sender)
- {
- if (!ValidateInputField())
- return;
- int nRes;
- nRes = FRMLogin->GetUserPassword(EdUserID->Text, EdPswd->Text);
- if (LOGIN_DB_ERR == nRes)
- {
- return;
- }
- if (LOGIN_ID_ERR == nRes)
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"등록되지 않은 사용자 입니다.", L"아이디 오류", MB_OK|MB_ICONERROR); // 등록되지 않은 사용자 입니다.
- else Application->MessageBox(L"Unregistered user.", L"User ID Error", MB_OK|MB_ICONERROR); // 등록되지 않은 사용자 입니다.
- Application->RestoreTopMosts();
- EdUserID->SetFocus();
- return;
- }
- if (LOGIN_PSWD_ERR == nRes)
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"비밀번호가 일치하지 않습니다.", L"비밀번호 오류", MB_OK|MB_ICONERROR); // 비밀번호가 일치하지 않습니다.
- else Application->MessageBox(L"Passwords do not match.", L"Password Error", MB_OK|MB_ICONERROR); // 비밀번호가 일치하지 않습니다.
- Application->RestoreTopMosts();
- EdPswd->SetFocus();
- return;
- }
- EdUserID->Text = EdUserID->Text.Trim();
- EdCnfmNewPswd->Text = EdCnfmNewPswd->Text.Trim();
- if (EdNewPswd->Text == EdPswd->Text)
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"기존 비밀번호와 신규로 입력한 비밀번호가 일치합니다.\r\n새로운 비밀번호를 입력하세요.", L"비밀번호 변경 오류", MB_OK|MB_ICONERROR);
- else Application->MessageBox(L"Your old and new passwords match.\r\nEnter a new password.", L"Password change error", MB_OK|MB_ICONERROR);
- Application->RestoreTopMosts();
- EdNewPswd->SetFocus();
- return;
- }
- int nResult = UpdateUserPassword(EdUserID->Text.Trim(), EdCnfmNewPswd->Text.Trim());
- if (nResult > 0)
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"비밀번호가 변경되었습니다.", L"비밀번호 변경 확인", MB_OK); // 비밀번호가 변경되었습니다. , 확인
- else Application->MessageBox(L"Password changed.", L"Confirm password change", MB_OK); // 비밀번호가 변경되었습니다. , 확인
- Application->RestoreTopMosts();
- }
- Close();
- }
- //---------------------------------------------------------------------------
- /*
- * 사용자 아이디에 해당하는 비밀번호를 변경한다.
- * parameter
- * strUserID : 사용자 ID
- * strNewPswd : 변경한 새로운 비밀번호
- * return
- *
- */
- int __fastcall TFRMPswdChnge::UpdateUserPassword(String sUserID, String sNewPswd)
- {
- String sQry;
- TADOQuery *adoQry = NULL;
- #if 0
- sQry= "UPDATE TB_USER_INFR \r\n"
- " SET PWD = SCP.HASH_B64('71', :p01) \r\n"
- " WHERE USER_ID = :p02 \r\n";
- #else
- sQry= "UPDATE TB_USER_INFR \r\n"
- " SET PWD = :p01 \r\n"
- " WHERE USER_ID = :p02 \r\n";
- #endif
- try
- {
- try
- {
- adoQry = new TADOQuery(NULL);
- adoQry->Connection = ITSDb_GetConnection();
- ITSDb_GetConnection()->BeginTrans();
- adoQry->Close();
- adoQry->SQL->Text = sQry;
- adoQry->Parameters->ParamByName("p01")->Value = sNewPswd;
- adoQry->Parameters->ParamByName("p02")->Value = sUserID;
- int nRowCnt = adoQry->ExecSQL();
- //ShowMessage(String(nRowCnt));
- ITSDb_GetConnection()->CommitTrans();
- return nRowCnt;
- }
- catch (Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- catch (...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- }
- }
- __finally
- {
- if (adoQry)
- {
- adoQry->Close();
- delete adoQry;
- }
- }
- return -1;
- }
- //---------------------------------------------------------------------------
- /*
- * 비밀번호 입력전에 사용자가 입력하여야 할 항목이 입력되어 있는지를 확인한다.
- * parameter
- * return
- *
- */
- bool __fastcall TFRMPswdChnge::ValidateInputField(void)
- {
- if (0 == EdUserID->Text.Trim().Length())
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"아이디를 입력하십시요.", L"아이디 입력 오류", MB_OK|MB_ICONERROR); // ID를 입력하세요. , 확 인
- else Application->MessageBox(L"Please enter User ID.", L"Error entering User ID", MB_OK|MB_ICONERROR); // ID를 입력하세요. , 확 인
- Application->RestoreTopMosts();
- EdUserID->SetFocus();
- return false;
- }
- if (0 == EdPswd->Text.Trim().Length())
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"현재 비밀번호를 입력하십시요.", L"비밀번호 입력 오류", MB_OK|MB_ICONERROR); // 현재 비밀번호를 입력하십시요. 확인
- else Application->MessageBox(L"Please enter your current password.", L"Error entering User Password", MB_OK|MB_ICONERROR); // 현재 비밀번호를 입력하십시요. 확인
- Application->RestoreTopMosts();
- EdPswd->SetFocus();
- return false;
- }
- if (0 == EdNewPswd->Text.Trim().Length())
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"신규 비밀번호를 입력하십시요.", L"신규 비밀번호 입력 오류", MB_OK|MB_ICONERROR); // 새로운 비밀번호를 입력하십시요. 확인
- else Application->MessageBox(L"Please enter your new password.", L"Error entering New Password", MB_OK|MB_ICONERROR); // 새로운 비밀번호를 입력하십시요. 확인
- Application->RestoreTopMosts();
- EdNewPswd->SetFocus();
- return false;
- }
- if (EdNewPswd->Text != EdCnfmNewPswd->Text)
- {
- Application->NormalizeTopMosts();
- if (g_AppCfg.sLang == "kr") Application->MessageBox(L"신규로 입력한 비밀번호가 일치하지 않습니다.", L"신규 비밀번호 확인 오류", MB_OK|MB_ICONERROR); // 새로 입력한 비밀번호가 일치하지 않습니다. 확인
- else Application->MessageBox(L"The newly entered password does not match.", L"New password verification error", MB_OK|MB_ICONERROR); // 새로 입력한 비밀번호가 일치하지 않습니다. 확인
- Application->RestoreTopMosts();
- EdNewPswd->SetFocus();
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- /*
- * 비밀번호 변경 화면 종료
- * parameter
- * return
- *
- */
- void __fastcall TFRMPswdChnge::btnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRMPswdChnge::FormCreate(TObject *Sender)
- {
- SetLocalSkin();
- }
- //---------------------------------------------------------------------------
- /*
- * 공통으로 처리되지 않는 스킨을 변경한다.
- * arguments
- *
- * return
- * void
- */
- void __fastcall TFRMPswdChnge::SetLocalSkin()
- {
- }
- //---------------------------------------------------------------------------
- /*
- * form이 메모리에서 생성될때 호출되는 생성자 파라미터 핸들러
- * arguments
- * Sender : event handler 객체
- * return
- * void
- */
- void __fastcall TFRMPswdChnge::CreateParams(TCreateParams &Params)
- {
- TForm::CreateParams(Params);
- //Params.Style = (Params.Style | WS_POPUP) & ~WS_DLGFRAME; //캡션바 삭제
- }
- //---------------------------------------------------------------------------
- /*
- * 캡션타입틀 마우스 클릭시 화면 이동하기
- * arguments
- *
- * return
- * void
- */
- void __fastcall TFRMPswdChnge::ShpCaptionMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- ReleaseCapture();
- SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRMPswdChnge::EdUserIDKeyPress(TObject *Sender, wchar_t &Key)
- {
- if (Key == 13)
- {
- EdPswd->SetFocus();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRMPswdChnge::EdPswdKeyPress(TObject *Sender, wchar_t &Key)
- {
- if (Key == 13)
- {
- EdNewPswd->SetFocus();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRMPswdChnge::EdNewPswdKeyPress(TObject *Sender, wchar_t &Key)
- {
- if (Key == 13)
- {
- EdCnfmNewPswd->SetFocus();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRMPswdChnge::EdCnfmNewPswdKeyPress(TObject *Sender, wchar_t &Key)
- {
- if (Key == 13)
- {
- BtnConfirm->SetFocus();
- }
- }
- //---------------------------------------------------------------------------
|