private void Amount20000_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.Withdraw, 20000); Delegates.SetWithdrawAction(WithdrawAction); ATMSimStateManager.AddToQueue(cmd); }
private void PrintButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.Print, null); Delegates.SetPrintReceipt(PrintReceipt); ATMSimStateManager.AddToQueue(cmd); }
private void WithdrawButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.ShowWithdrawPage, null); Delegates.SetShowWithdrawPage(ShowWithdrawPage); ATMSimStateManager.AddToQueue(cmd); }
private void InsertCardButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand showLoginPageCommand = new ATMSimCommand(CommandId.ShowLoginPage, navigationService); Delegates.SetShowLoginPage(RunLoginPage); ATMSimStateManager.AddToQueue(showLoginPageCommand); }
public override Result DoProcess(ATMSimCommand command) { //if (command.CommandId == CommandId.Authenticating) //{ // return Result.NoReult; //} if (command.CommandId == CommandId.AuthenticationSuccess) { return(Result.Success); } else if (command.CommandId == CommandId.AuthenticationFailure) { ChangeToLoginState(); return(Result.NotSuccess); } else if (command.CommandId == CommandId.PinVerificationFailure) { ChangeToIdleState(); return(Result.NoResult); } else { return(Result.NoResult); } }
private void SignOutButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.SignOut, null); Delegates.SetSignOutOp(SignOutOp); ATMSimStateManager.AddToQueue(cmd); }
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); } }
private void CancelButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.Cancel, null); Delegates.SetCancelBalancePage(CancelPage); ATMSimStateManager.AddToQueue(cmd); }
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 }
private void TransferButton_Click(object sender, RoutedEventArgs e) { ATMSimCommand cmd = new ATMSimCommand(CommandId.Transfer, null); Delegates.SetTransferAction(TransferAction); ATMSimStateManager.AddToQueue(cmd); }
/// <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); }
// 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); }
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); }
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(); }
public override BaseState GetNextState(ATMSimCommand command) { if (command.CommandId == CommandId.Withdraw) { return(StateHolder.SessionState); } else { return(null); } }
public override BaseState GetNextState(ATMSimCommand command) { if (command.CommandId == CommandId.AuthenticationSuccess) { return(StateHolder.SessionState); } else { return(null); } }
// 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(); }
public override BaseState GetNextState(ATMSimCommand command) { command = StateManager.ATMSimStateManager.GeneralQueue.Dequeue(); if (command.CommandId == CommandId.StartAuthentication) { return(StateHolder.AuthenticationState); } else { return(null); } }
public override Result DoProcess(ATMSimCommand command) { base.DoProcess(command); if (command.CommandId == CommandId.Cancel) { Delegates.GetCancelTransferPage()(null); return(Result.GoBack); } else if (command.CommandId == CommandId.Transfer) { Delegates.GetTransferAction()(null); return(Result.NoResult); } else { return(Result.NoResult); } }
public override Result DoProcess(ATMSimCommand command) { base.DoProcess(command); if (command.CommandId == CommandId.Cancel) { Delegates.GetCancelBalancePage()(null); return(Result.GoBack); } else if (command.CommandId == CommandId.Print) { Delegates.GetPrintReceipt()(null); return(Result.NoResult); } else { return(Result.NoResult); } }
public override Result DoProcess(ATMSimCommand command) { base.DoProcess(command); if (command.CommandId == CommandId.Cancel) { Delegates.GetCancelWithdrawPage()(null); return(Result.GoBack); } else if (command.CommandId == CommandId.Withdraw) { Delegates.GetWithdrawAction()(command.Param); return(Result.NoResult); } else { return(Result.NoResult); } }
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); } }
public override BaseState GetNextState(ATMSimCommand command) { if (command.CommandId == CommandId.ShowBalancePage) { return(StateHolder.BalanceState); } else if (command.CommandId == CommandId.ShowWithdrawPage) { return(StateHolder.WithdrawState); } else if (command.CommandId == CommandId.ShowTransferPage) { return(StateHolder.TransferState); } else { return(null); } }
public override Result DoProcess(ATMSimCommand command) { if (command.CommandId == CommandId.Timeout) { Delegates.GetTimeOutOp()(null); ChangeToIdleState(); return(Result.NoResult); } else if (command.CommandId == CommandId.SignOut) { Delegates.GetSignOutOp()(null); ChangeToIdleState(); return(Result.NoResult); } else if (command.CommandId == CommandId.ShowBalancePage || command.CommandId == CommandId.ShowWithdrawPage || command.CommandId == CommandId.ShowTransferPage) { return(Result.Success); } else { return(Result.NoResult); } }
public override BaseState GetNextState(ATMSimCommand command) { return(null); }
// 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(); } } } }); }