private void Amount20000_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Withdraw, 20000);

            Delegates.SetWithdrawAction(WithdrawAction);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 2
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Cancel, null);

            Delegates.SetCancelBalancePage(CancelPage);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 3
0
        /// <summary>
        /// Sign out the user from the session
        /// </summary>
        private void SessionTimer_Tick(object sender, EventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Timeout, null);

            Delegates.SetTimeOutOp(TimeOutOp);
            ATMSimStateManager.AddToQueue(cmd);
        }
        private void WithdrawButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.ShowWithdrawPage, null);

            Delegates.SetShowWithdrawPage(ShowWithdrawPage);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 5
0
        private void InsertCardButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand showLoginPageCommand = new ATMSimCommand(CommandId.ShowLoginPage, navigationService);

            Delegates.SetShowLoginPage(RunLoginPage);
            ATMSimStateManager.AddToQueue(showLoginPageCommand);
        }
Esempio n. 6
0
        private void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Print, null);

            Delegates.SetPrintReceipt(PrintReceipt);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 7
0
        public SessionTransferPage(NavigationService navigationService)
        {
            InitializeComponent();
            TransferAccountTextBox.Focus();
            ATMSession.RestartSessionTimer();
            this._navigationService = navigationService;
            MainWindow mainWindow = MainWindow.Instance;

            mainWindow.Title = "ATMSim -Transfer";

            // Get balance and show it on text block
            DBHelper dBHelper = new DBHelper();
            double   balance  = dBHelper.GetBalance(ATMSession.AccountNo);

            if (balance >= 0)
            {
                BalanceTextBlock.Text = string.Concat("Rs. ", balance);
            }
            else
            {
                WpfMessageBox.Show("INTERNAL ERROR: Balance retireving failed", "ERROR", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error, WpfMessageBox.MessageBoxType.Error);
                ATMSimCommand cmd = new ATMSimCommand(CommandId.Cancel, null);
                Delegates.SetCancelBalancePage(CancelPage);
                ATMSimStateManager.AddToQueue(cmd);
            }
            // end get balance
        }
Esempio n. 8
0
        private void SignOutButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.SignOut, null);

            Delegates.SetSignOutOp(SignOutOp);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 9
0
        private void TransactionSuccessMsg()
        {
            DBHelper dBHelper        = new DBHelper();
            double   balance         = dBHelper.GetBalance(ATMSession.AccountNo);
            string   transSuccessMsg = "Transaction is successfull \n" +
                                       "\nAccount No: " + ATMSession.AccountNo +
                                       "\nWithdrawal amount: Rs. " + transaction.Amount +
                                       "\nTimestamp: " + DateTime.Now.ToString() +
                                       "\nAvailable balance: Rs. " + balance +
                                       "\n\nDo you need to do another transaction?";
            var result = WpfMessageBox.Show("Information", transSuccessMsg, MessageBoxButton.YesNo, WpfMessageBox.MessageBoxImage.Information);

            if (result.Equals(MessageBoxResult.Yes))
            {
                // change state to cancel
                ATMSimCommand cmd = new ATMSimCommand(CommandId.Cancel, null);
                Delegates.SetCancelTransferPage(CancelPage);
                ATMSimStateManager.AddToQueue(cmd);
            }
            if (result.Equals(MessageBoxResult.No))
            {
                ATMSimCommand cmd = new ATMSimCommand(CommandId.SignOut, null);
                Delegates.SetSignOutOp(SignOutOp);
                ATMSimStateManager.AddToQueue(cmd);
            }
        }
Esempio n. 10
0
        private void TransferButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Transfer, null);

            Delegates.SetTransferAction(TransferAction);
            ATMSimStateManager.AddToQueue(cmd);
        }
Esempio n. 11
0
        // Cancel operation
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Cancel, null);

            Delegates.SetCancelTransferPage(CancelPage);
            ATMSimStateManager.AddToQueue(cmd);
            //ATMSession.CancelCurrentOperation(_navigationService);
        }
Esempio n. 12
0
        private void SignInButton_Click(object sender, RoutedEventArgs e)
        {
            _accNo    = AccountNoTextBox.Text;
            _password = PinPasswordBox.Password;
            ATMSimCommand signInCommand = new ATMSimCommand(CommandId.SignIn, this);

            Delegates.SetAuthentication(Authenticate);
            ATMSimStateManager.AddToQueue(signInCommand);
        }
Esempio n. 13
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.IsEnabled = true;
            ATMSimCommand cancelLoginPageCommand = new ATMSimCommand(CommandId.Cancel, _navigationService);

            Delegates.SetShowLoginPage(CancelLoginPage);
            ATMSimStateManager.AddToQueue(cancelLoginPageCommand);
            this.Close();
        }
        // Withdraw action
        #region Withdraw Action Region
        private void WithdrawButton_Click(object sender, RoutedEventArgs e)
        {
            ATMSimCommand cmd = new ATMSimCommand(CommandId.Withdraw, null);

            Delegates.SetWithdrawAction(WithdrawAction);
            ATMSimStateManager.AddToQueue(cmd);

            //LoginWindow loginWindow = new LoginWindow();
            //loginWindow = DrawLoginWindowAsVerifyPinWindow(loginWindow);
            //loginWindow.ShowDialog();
            //ATMSession.TimeOutOperation();
        }
Esempio n. 15
0
        private MainWindow()
        {
            InitializeComponent();

            StartDateTimeTimer();
            MainPage mainPage = new MainPage(MainNavFrame.NavigationService);

            MainNavFrame.Navigate(mainPage);
            ATMSession.IsStarted = false;

            // declare and initialize state manager and start it as a async background thread
            ATMSimStateManager stateManager = new ATMSimStateManager();
        }
Esempio n. 16
0
 public override Result DoProcess(ATMSimCommand command)
 {
     if (command.CommandId == CommandId.SignIn)
     {
         ATMSimCommand authenticationCommand = new ATMSimCommand(CommandId.StartAuthentication, this);
         ATMSimStateManager.AddToQueue(authenticationCommand);
         return(Result.Success);
     }
     else if (command.CommandId == CommandId.Cancel)
     {
         StateHolder.PreviousState = StateHolder.IdleState;
         return(Result.GoBack);
     }
     else
     {
         return(Result.Error);
     }
 }
Esempio n. 17
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();
                        }
                    }
                }
            });
        }