//--------------------------------------------------------------------------- #include #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(); } } //---------------------------------------------------------------------------