Ejemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (Account.Password == PasswordBox.ToString())
     {
         if (NewPass.ToString() == Confirm.ToString())
         {
             Account.Password = NewPass.Password;
             _context.Entry(Account).State = System.Data.Entity.EntityState.Modified;
             _context.SaveChanges();
             SuccessMessage sm = new SuccessMessage();
             sm.MessageText.Text = "Password Changed";
             sm.Show();
         }
     }
 }
Ejemplo n.º 2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (AccountRole == 2)
     {
         admins.RoleId           = Convert.ToInt64(RoleId.SelectedIndex);
         admins.Username         = Username.Text.Trim();
         admins.Password         = PasswordBox.ToString();
         admins.AdminUpgradeDate = DateTime.Now.Date;
         _context.UserAccounts.Add(admins);
         _context.SaveChanges();
         SucessMessage Sm = new SucessMessage();
         Sm.MessageText.Text = "Admin Added Successfully";
         Sm.Show();
     }
     else
     {
         ErrorMessage Sm = new ErrorMessage();
         Sm.MessageText.Text = "Access Denied";
         Sm.Show();
     }
 }
        private bool ValidatePasswords(string TraderId, PasswordBox oNewPasswordBox, PasswordBox oConfirmPwd)
        {
            if (string.IsNullOrEmpty(TraderId))
            {
                txtReply = "Trader Id is Mandatory";
                return(false);
            }
            if (string.IsNullOrEmpty(oNewPasswordBox.Password.ToString()))
            {
                txtReply = "New Password is Mandatory";
                return(false);
            }
            if (string.IsNullOrEmpty(oConfirmPwd.Password.ToString()))
            {
                txtReply = "Confirm Password is Mandatory";
                return(false);
            }

            if (Convert.ToUInt32(TraderId) == UtilityLoginDetails.GETInstance.TraderId)
            {
                txtReply = "Cannot change Password for " + TraderId + " Trader Id";
                return(false);
            }
            if (UtilityLoginDetails.GETInstance.TraderId == 200 && TraderId == "0")
            {
                txtReply = "Cannot change Password for " + TraderId + " Trader Id";
                return(false);
            }

            if (!TraderId.All(c => "0123456789".Contains(c)))
            {
                txtReply = "Please Enter Numeric Trader Id";
                return(false);
            }
            if (oNewPasswordBox.Password.ToString().All(c => "0123456789".Contains(c)))
            {
                txtReply = "New Password should be AlphaNumeric";
                return(false);
            }
            if (oConfirmPwd.Password.ToString().All(c => "0123456789".Contains(c)))
            {
                txtReply = "Confirm Password should be AlphaNumeric";
                return(false);
            }
            if (Regex.IsMatch(oNewPasswordBox.Password.ToString(), @"^[a-zA-Z]+$"))
            {
                txtReply = "New Password should be AlphaNumeric";
                return(false);
            }
            if (Regex.IsMatch(oConfirmPwd.Password, @"^[a-zA-Z]+$"))
            {
                txtReply = "Confirm Password should be AlphaNumeric";
                return(false);
            }

            //if (oNewPasswordBox.Password.ToString() != Regex.Replace(oNewPasswordBox.Password.ToString(), "^[ ]+", ""))
            //{
            //    txtReply = "New Password should not contain space";

            //    return false;
            //}
            //if (oConfirmPwd.Password.ToString() != Regex.Replace(oConfirmPwd.Password.ToString(), "^[ ]+", ""))
            //{
            //    txtReply = "Confirm Password should not contain space";
            //    return false;
            //}
            if (oNewPasswordBox != null && !string.IsNullOrEmpty(oNewPasswordBox.Password))
            {
                if (oNewPasswordBox.Password.Any(x => Char.IsWhiteSpace(x)))
                {
                    txtReply = "New Password should not contain space";
                    return(false);
                }
            }
            if (oConfirmPwd != null && !string.IsNullOrEmpty(oConfirmPwd.Password))
            {
                if (oConfirmPwd.Password.Any(x => Char.IsWhiteSpace(x)))
                {
                    txtReply = "Confirm Password should not contain space";
                    return(false);
                }
            }
            if (oNewPasswordBox.ToString().Length < 8)
            {
                txtReply = "New Password should be more than 8 digits";
                return(false);
            }
            if (oConfirmPwd.Password.ToString().Length < 8)
            {
                txtReply = "Confirm Password should be more than 8 digits";
                return(false);
            }
            if (oNewPasswordBox.Password.ToString() != oConfirmPwd.Password.ToString())
            {
                txtReply = "Password Mismatch";
                return(false);
            }

            txtReply = "";
            return(true);
        }