private async void Confirm(object obj) { LoaderManager.Instance.ShowLoader(); await Task.Run(() => { int res = DbManager.TransferMoney(StaticManager.CurrentCard, StaticManager.CurrentTransfer.RecipientCard, StaticManager.CurrentTransfer.Amount); if (res != -1) { MessageBox.Show("You have successfully transfer " + StaticManager.CurrentTransfer.Amount + " points to " + RecipientName); } else { MessageBox.Show("There is not enough money in your account!", "Refusal!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, StaticManager.CurrentTransfer.Amount + " Transfer", StaticManager.CurrentTransfer.RecipientCard)); DbManager.SaveATM(StaticManager.CurrentAtm); }); LoaderManager.Instance.HideLoader(); NavigationManager.Instance.Navigate(ModesEnum.AskContinue); }
private async void SaveAction() { LoaderManager.Instance.ShowLoader(); await Task.Run(() => { DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, "BalanceInquiry")); DbManager.SaveATM(StaticManager.CurrentAtm); }); LoaderManager.Instance.HideLoader(); }
private async void Delete(object obj) { LoaderManager.Instance.ShowLoader(); await Task.Run(() => { _payments.Remove(SelectedPayment); DbManager.DeleteRegularPayment(SelectedPayment); DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, "RegularPayment")); DbManager.SaveATM(StaticManager.CurrentAtm); }); LoaderManager.Instance.HideLoader(); MessageBox.Show("Regular Payment was successfully deleted!"); NavigationManager.Instance.Navigate(ModesEnum.AskContinue); }
private async void ChangePin(object obj) { bool correct = true; LoaderManager.Instance.ShowLoader(); await Task.Run(() => { if (!StaticManager.CurrentCard.CheckPassword(_oldPin) || _newPin1 != _newPin2 || _oldPin == _newPin1) { correct = false; string txt = (_oldPin == _newPin1 ? "Password wasn`t change!" : "Something is wrong! Check all information!"); MessageBox.Show(txt, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { StaticManager.CurrentCard.CardPassword = Encrypting.GetMd5HashForString(NewPin1); DbManager.SaveAccount(StaticManager.CurrentCard); MessageBox.Show("You PIN was successfully changed!"); } DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, "ChangePin")); DbManager.SaveATM(StaticManager.CurrentAtm); }); LoaderManager.Instance.HideLoader(); if (correct) { NavigationManager.Instance.Navigate(ModesEnum.AskContinue); } else { NavigationManager.Instance.Navigate(ModesEnum.ChangePin); } }
//get money to the client protected async void GetMoney(int n, int[] res) { LoaderManager.Instance.ShowLoader(); await Task.Run(() => { int commission = DbManager.WithdrawMoney(StaticManager.CurrentCard, n); if (commission == -1) //if there was an exception { MessageBox.Show("There is not enough money at your account!", "Refusal!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { string txt = ""; if (commission == 0) { StaticManager.CurrentCard = DbManager.GetAccountByNum(StaticManager.CurrentCard.CardNumber); } else //if there was a commission { txt = "\nСommission = 3% (" + commission + " points)"; } DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, n + " CashWithdrawal")); RemoveBanknotes(res); DbManager.SaveATM(StaticManager.CurrentAtm); MessageBox.Show("You have successfully been issued " + n + " points!" + txt + "\nBanknotes " + string.Join(",", res)); } }); LoaderManager.Instance.HideLoader(); NavigationManager.Instance.Navigate(ModesEnum.AskContinue); }
private async void Confirm(object obj) { Recipient = _recipient.Replace(" ", ""); Account recipient = null; LoaderManager.Instance.ShowLoader(); await Task.Run(() => { recipient = DbManager.GetAccountByNum(Recipient); if (recipient == null) { DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, "Transfer", recipient)); DbManager.SaveATM(StaticManager.CurrentAtm); } }); LoaderManager.Instance.HideLoader(); if (recipient == null) { MessageBox.Show("The card " + Recipient + " does not exist!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); NavigationManager.Instance.Navigate(ModesEnum.Transfer); } else if (Recipient == StaticManager.CurrentCard.CardNumber) { MessageBox.Show("Number of card sender and card recipient must not match!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); NavigationManager.Instance.Navigate(ModesEnum.Transfer); } else { StaticManager.CurrentTransfer = new CurrentTransfer(recipient, Amount, Description); NavigationManager.Instance.Navigate(ModesEnum.CheckTransferInfo); } }
private async void NextImplementation(object obj) { bool correct = false; LoaderManager.Instance.ShowLoader(); await Task.Run(() => { StaticManager.Attempts = StaticManager.Attempts - 1; if ((StaticManager.CurrentCard != null && StaticManager.CurrentCard.CheckPassword(Pin)) || (StaticManager.CurrentManager != null && StaticManager.CurrentManager.CheckPassword(Pin))) { correct = true; } else if (StaticManager.CurrentCard != null && StaticManager.Attempts == 0) { StaticManager.CurrentCard.IsActive = false; DbManager.SaveAccount(StaticManager.CurrentCard); } else if (StaticManager.CurrentManager != null && StaticManager.Attempts == 0) { StaticManager.CurrentAtm.Status = false; } if (StaticManager.CurrentCard != null) { DbManager.AddATMAccountAction(new ATMAccountAction(StaticManager.CurrentAtm, StaticManager.CurrentCard, "Authentication")); DbManager.SaveATM(StaticManager.CurrentAtm); } else { DbManager.AddATMManagerAction(new ATMManagerAction(StaticManager.CurrentManager, StaticManager.CurrentAtm, "Authentication")); DbManager.SaveATM(StaticManager.CurrentAtm); } }); LoaderManager.Instance.HideLoader(); if (!StaticManager.CurrentAtm.Status) { NavigationManager.Instance.Navigate(ModesEnum.CardPin); } else if (!correct) { if (StaticManager.CurrentCard != null) { MessageBox.Show("Your have " + StaticManager.Attempts + " attempts!", "Wrong PIN!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } ModesEnum mode = (StaticManager.Attempts == 0 ? ModesEnum.CardNumber : ModesEnum.CardPin); NavigationManager.Instance.Navigate(mode); } else if (StaticManager.CurrentCard != null) { NavigationManager.Instance.Navigate(ModesEnum.ClientMenu); } else if (StaticManager.CurrentManager != null) { NavigationManager.Instance.Navigate(ModesEnum.ManagerMenu); } }