protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Utilities.SetNoCache(Response); CurrentPassword.Focus(); } }
void ChangePassword(object sender, EventArgs args) { mainViewModel = MainViewModel.GetInstance(); employee = mainViewModel.Employee; CurrentPassword.Text = string.Empty; NewPassword.Text = string.Empty; ConfirmPassword.Text = string.Empty; PasswordModal.IsVisible = true; CurrentPassword.Focus(); }
private void DetectInputLogin() { string CurrPasswd = CurrentPassword.Password; string NewPasswd = Password.Password; string PasswdV = PasswordV.Password; if (string.IsNullOrEmpty(CurrPasswd) || string.IsNullOrEmpty(NewPasswd) || string.IsNullOrEmpty(PasswdV)) { if (string.IsNullOrEmpty(CurrPasswd)) { CurrentPassword.Focus(FocusState.Keyboard); } else if (string.IsNullOrEmpty(NewPasswd)) { Password.Focus(FocusState.Keyboard); } else if (string.IsNullOrEmpty(PasswdV)) { PasswordV.Focus(FocusState.Keyboard); } } else if (NewPasswd != PasswdV) { StringResources stx = StringResources.Load("Error"); ServerMessage.Text = stx.Str("PasswordMismatch"); Password.Focus(FocusState.Keyboard); } else { ServerMessage.Text = ""; IsPrimaryButtonEnabled = IsSecondaryButtonEnabled = CurrentPassword.IsEnabled = Password.IsEnabled = PasswordV.IsEnabled = false ; this.Focus(FocusState.Pointer); IndicateLoad(); RuntimeCache RCache = new RuntimeCache() { EN_UI_Thead = true }; RCache.POST( Shared.ShRequest.Server , Shared.ShRequest.ChangePassword(CurrPasswd, NewPasswd) , RequestComplete, RequestFailed, false); } }
private void RequestComplete(DRequestCompletedEventArgs e, string QueryId) { IndicateIdle(); try { JsonStatus.Parse(e.ResponseString); Canceled = false; Hide(); } catch (Exception ex) { ErrorMessage(ex.Message); CurrentPassword.Focus(FocusState.Keyboard); } }
private void Button_Click(object sender, RoutedEventArgs e) { ChangePasswords w = new ChangePasswords(); SqlConnection con1 = new SqlConnection(PublicVar.ConnectionString); con1.Open(); SqlCommand myCommand = new SqlCommand("Select (Password) from LockTable where Username = '******'", con1); object result = myCommand.ExecuteScalar(); string OldPassword = Regex.Replace(Convert.ToString(result), @"\s+", ""); if (PasswordID.Text.Trim() != "" && PasswordID2.Text.Trim() != "" && CurrentPassword.Text.Trim() != "") { if (CurrentPassword.Text.Trim() == OldPassword) // true { if (PasswordID.Text.Trim() == PasswordID2.Text.Trim()) // true { string newpassword = PasswordID.Text.Trim(); SqlCommand Commandcmdsz = new SqlCommand("update LockTable set Password = '******' Where Username = '******'", con1); Commandcmdsz.ExecuteScalar(); MessageBox.Show("رمز عبور شما با موفقیت تغیر کرد", "اطلاعات اکانت"); con1.Close(); Close(); } else { MessageBox.Show("رمز های عبور یکسان نیستند"); PasswordID.Focus(); } } else { MessageBox.Show("رمز عبور قبلی شما درست نیست", "اطلاعات اکانت"); CurrentPassword.Focus(); } } else { MessageBox.Show("قسمت های خالی را پر کنید"); PasswordID.Focus(); PasswordID2.BorderBrush = Brushes.Red; PasswordID.BorderBrush = Brushes.Red; } con1.Close(); }
async void SavePasswordClicked(object sender, EventArgs args) { if (string.IsNullOrEmpty(CurrentPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the current password."); CurrentPassword.Focus(); return; } if (string.IsNullOrEmpty(NewPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the new password."); NewPassword.Focus(); return; } if (string.IsNullOrEmpty(ConfirmPassword.Text)) { await dialogService.ShowMessage("Error", "You must enter the confirm password."); ConfirmPassword.Focus(); return; } if (!employee.Password.Equals(CurrentPassword.Text)) { await dialogService.ShowMessage("Error", "Current passwword incorrect"); CurrentPassword.Focus(); return; } if (!NewPassword.Text.Equals(ConfirmPassword.Text)) { await dialogService.ShowMessage("Error", "New password and confirm password must be equals"); NewPassword.Focus(); return; } var checkConnetion = await apiService.CheckConnection(); if (!checkConnetion.IsSuccess) { await dialogService.ShowMessage("Error", checkConnetion.Message); return; } var urlAPI = Application.Current.Resources["URLAPI"].ToString(); var changePassword = new ChangePasswordRequest { Email = employee.Email, CurrentPassword = CurrentPassword.Text, NewPassword = NewPassword.Text, }; var response = await apiService.PostPassword <ChangePasswordRequest>( urlAPI, "/api", "/Employees/ChangePassword", employee.TokenType, employee.AccessToken, changePassword); if (!response.IsSuccess) { await dialogService.ShowMessage("Error", response.Message); return; } mainViewModel.Employee.Password = changePassword.NewPassword; dataService.DeleteAllAndInsert(mainViewModel.Employee); await dialogService.ShowMessage("Accept", "Password has been successfully"); PasswordModal.IsVisible = false; }