Exemplo n.º 1
0
 private void SignOutOp(object param)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         if (param == null)
         {
             ATMSession.SignOut();
         }
     });
 }
Exemplo n.º 2
0
 private void SignOutButton_Click(object sender, RoutedEventArgs e)
 {
     ATMSession.SignOut();
 }
Exemplo n.º 3
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();
                        }
                    }
                }
            });
        }