예제 #1
0
 public LoginWindow(NavigationService navigationService)
 {
     InitializeComponent();
     _navigationService = navigationService;
     AccountNoTextBox.Focus();
     PinTryOuts = 1;
 }
예제 #2
0
        // try to authenticate
        private void Authenticate(object param)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                if (param == null)
                {
                    if (AccountNoTextBox.IsVisible)
                    {
                        if (!_accNo.Equals("") && !_password.Equals(""))
                        {
                            DBHelper dBHelper = new DBHelper();
                            if (dBHelper.CheckAccountNo(_accNo))
                            {
                                if (PinTryOuts <= _maxPinTryouts)
                                {
                                    if (dBHelper.VerifyPin(_accNo, _password))
                                    {
                                        ATMSimCommand cmd = new ATMSimCommand(CommandId.AuthenticationSuccess, null);
                                        Delegates.SetShowSessionPage(ShowSessionPage);
                                        ATMSimStateManager.AddToQueue(cmd);
                                        MainWindow.Instance.IsEnabled = true;
                                    }
                                    else
                                    {
                                        var messageBoxResult = WpfMessageBox.Show("Error", "PIN verification failed", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error, WpfMessageBox.MessageBoxType.Error);
                                        if (messageBoxResult != MessageBoxResult.OK)
                                        {
                                            return;
                                        }
                                        PinPasswordBox.SelectAll();
                                        PinPasswordBox.Focus();

                                        ATMSimCommand cmd;
                                        if (PinTryOuts < _maxPinTryouts)
                                        {
                                            cmd = new ATMSimCommand(CommandId.AuthenticationFailure, this);
                                            ATMSimStateManager.AddToQueue(cmd);
                                        }
                                        else if (PinTryOuts == _maxPinTryouts)
                                        {
                                            cmd = new ATMSimCommand(CommandId.PinVerificationFailure, this);
                                            ATMSimStateManager.AddToQueue(cmd);
                                            MainWindow.Instance.IsEnabled = true;
                                            this.Close();
                                        }

                                        PinTryOuts++;
                                    }
                                }
                            }
                            else
                            {
                                var messageBoxResult = WpfMessageBox.Show("Error", "Invalid account number.", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error, WpfMessageBox.MessageBoxType.Error);
                                if (messageBoxResult != MessageBoxResult.OK)
                                {
                                    return;
                                }
                                PinPasswordBox.Password = "";
                                AccountNoTextBox.SelectAll();
                                AccountNoTextBox.Focus();
                                ATMSimCommand cmd = new ATMSimCommand(CommandId.AuthenticationFailure, this);
                                ATMSimStateManager.AddToQueue(cmd);
                            }
                        }
                        else
                        {
                            var messageBoxResult = WpfMessageBox.Show("Warning", "Please fill all fields", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Warning, WpfMessageBox.MessageBoxType.Warning);
                            ATMSimCommand cmd    = new ATMSimCommand(CommandId.AuthenticationFailure, this);
                            ATMSimStateManager.AddToQueue(cmd);
                            AccountNoTextBox.Focus();
                        }
                    }
                    else
                    {
                        if (!PinPasswordBox.Password.Equals(""))
                        {
                            if (PinTryOuts <= _maxPinTryouts)
                            {
                                if (PinPasswordBox.Password.Equals("1234"))
                                {
                                    this.DialogResult    = true;
                                    ATMSession.AccountNo = AccountNoTextBox.Text;
                                    this.Close();
                                }
                                else
                                {
                                    var messageBoxResult = WpfMessageBox.Show("Error", "PIN verification failed", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error, WpfMessageBox.MessageBoxType.Error);
                                    if (messageBoxResult != MessageBoxResult.OK)
                                    {
                                        return;
                                    }
                                    if (PinTryOuts == _maxPinTryouts)
                                    {
                                        this.Close();
                                        ATMSession.SignOut();
                                    }
                                    PinTryOuts++;
                                    PinPasswordBox.Focus();
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            var messageBoxResult = WpfMessageBox.Show("Warning", "Please enter your PIN", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Warning, WpfMessageBox.MessageBoxType.Warning);
                            PinPasswordBox.Focus();
                        }
                    }
                }
            });
        }
예제 #3
0
 public LoginWindow()
 {
     InitializeComponent();
     AccountNoTextBox.Focus();
     PinTryOuts = 1;
 }