private void button4_Click(object sender, EventArgs e) { PaymentCard card = LoggedClient.FindCard(dataGridView1.CurrentRow.Cells["Nr"].Value.ToString()); card.Pay(Convert.ToDouble($"{intFundsBox.Text},{floatFundsBox.Text}")); dataGridView1.CurrentRow.Cells["Funds"].Value = card.CheckFunds(); }
public void RequestCard(string BankName, int Type) { Bank tmpBank = PaymentCardServiceCenter.FindBank(BankName); PaymentCard tmpCard = tmpBank.AuthorizeCard(Name, KRS, Type); AddCard(tmpCard); }
private void PaymentBtn_Click(object sender, EventArgs e) { try { PaymentCard card = LoggedClient.FindCard(dataGridView1.CurrentRow.Cells["Nr"].Value.ToString()); double amount = Convert.ToDouble($"{intPay.Text},{floatPay.Text}"); Payment pay = new Payment(LoggedClient.GetKRS(), card.GetNr(), amount.ToString(), RecievierNamePay.Text, RecievierCardPay.Text, TitlePay.Text, DateTime.Now.ToString()); LoggedClient.RequestAuthorization(pay, card); card.Pay(amount); dataGridView1.CurrentRow.Cells["Funds"].Value = card.CheckFunds(); dataGridView2.Rows.Add(pay.Title, pay.FromKRS, pay.Amount, pay.ToKRS, pay.ToCard, pay.Date); //PaymentCardServiceCenter.DB.Write(pay); } catch (FormatException) { ErrorLabel.Text = " Not a valid input"; } catch (InvalidValueException) { ErrorLabel.Text = "Enter a positive value."; } catch (RequestRejectedException ex) { ErrorLabel.Text = $"Bank {ex.BankName} has rejected Your request"; } catch (ClientNotFoundException ex) { ErrorLabel.Text = $"{ex.KRS} not found"; } catch (CardNotFoundException ex) { ErrorLabel.Text = $"{ex.nr} not found"; } }
static public bool AuthorizePayment(Payment PaymentRequested, PaymentCard CardUsed) { Bank tmp = null; tmp = FindBank(CardUsed.GetBank()); if (tmp.Authorize()) { CardUsed.Pay(Convert.ToDouble(PaymentRequested.Amount)); FindClient(PaymentRequested.ToKRS).FindCard(PaymentRequested.ToCard).AddFunds(Convert.ToDouble(PaymentRequested.Amount)); DB.Write(PaymentRequested); Payments.Add(PaymentRequested); return(true); } return(false); }
private void Creditbtn_Click(object sender, EventArgs e) { try { PaymentCard card = PaymentCardServiceCenter.FindBank(BankNameBox.Text).AuthorizeCard(LoggedClient.GetName(), LoggedClient.GetKRS(), 2); dataGridView1.Rows.Add(card.GetNr(), card.CheckFunds(), card.GetBank(), card.CardType()); LoggedClient.AddCard(card); } catch (RequestRejectedException ex) { ErrorLabel.Text = $"Bank {ex.BankName} has rejected Your request"; } catch (BanknotFoundException ex) { ErrorLabel.Text = $"Bank {ex.bank} not found"; } }
private void buttonDebit_Click(object sender, EventArgs e) { PaymentCard newCard = LoggedBank.AuthorizeCard(LoggedBank.FindClient(CardKRSBox.Text).GetName(), 1); dataGridView2.Rows.Add(newCard.GetOwner(), CardKRSBox.Text, newCard.CheckFunds().ToString(), newCard.GetType()); }
public static void LoadBankData() { StreamReader file = new StreamReader(PathToBankData); string line; while ((line = file.ReadLine()) != null) { string[] Words = line.Split(' '); string BankName = "", BankPass = ""; int i = 0; while (Words[i] != ";") { BankName += Words[i]; BankName += " ";//adds space if there should be one, if not its deleted when exiting loop i++; } i++; BankName = BankName.Remove(BankName.ToString().Length - 1);//skiping seperator and deleteing excessive space, bank read while (Words[i] != ";") { BankPass += Words[i];// BankName += " ";//adds space if there should be one, if not its deleted when exiting loop i++; } i++;// BankPass = BankPass.Remove(BankPass.ToString().Length - 1);//skiping seperator and deleteing excessive space, bank read Bank tmpBank = new Bank(BankName, BankPass); Client tmpClient = null; PaymentCard PCard = null; int Clientsnum = Convert.ToInt32(Words[i]); i++; while (Clientsnum > 0) { Clientsnum--; while (Words[i] != ";") { string KRS = Words[i]; i++; string Password = ""; while (Words[i] != "}") { Password += Words[i]; i++; } i++; string Name = ""; while (Words[i] != "}") { Name += Words[i]; i++; Name += " "; } i++; Name = Name.Remove(Name.ToString().Length - 1); //skiping seperator and deleteing excessive space string ClientType = Words[i]; i++; if (ClientType == "Trans") { TransFirm tmp = new TransFirm(KRS, Password, Name); tmpClient = tmp; } if (ClientType == "Shop") { Shop tmp = new Shop(KRS, Password, Name); tmpClient = tmp; } if (ClientType == "Serv") { ServiceEstablishment tmp = new ServiceEstablishment(KRS, Password, Name); tmpClient = tmp; } } i++; //skiping seperator, client read tmpBank.AddClient(tmpClient); int CardsNum = Convert.ToInt32(Words[i]); i++; while (CardsNum > 0) { CardsNum--; while (Words[i] != "|" && i < Words.Count()) { double CardFunds = Convert.ToDouble(Words[i]); i++; string CardNr = Words[i]; i++; string CardBankName = ""; while (Words[i] != "}") { CardBankName += Words[i]; i++; CardBankName += " "; } i++; CardBankName = CardBankName.Remove(CardBankName.ToString().Length - 1); //skiping seperator and deleteing excessive space string CardOwner = ""; while (Words[i] != "}") { CardOwner += Words[i]; i++; CardOwner += " "; } i++; CardOwner = CardOwner.Remove(CardOwner.ToString().Length - 1); //skiping seperator and deleteing excessive space string KRS = Words[i]; i++; string CardType = Words[i]; i++; if (CardType == "ATM") { ATMCard tmpATM = new ATMCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpATM; } if (CardType == "Debit") { DebitCard tmpDebit = new DebitCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpDebit; } if (CardType == "Credit") { CreditCard tmpCredit = new CreditCard(CardNr, CardFunds, CardBankName, CardOwner, KRS); PCard = tmpCredit; } tmpClient.AddCard(PCard); tmpBank.AddCard(PCard); } i++; //skiping seperator, cards read } i++; } PaymentCardServiceCenter.AddBank(tmpBank); } file.Close(); }
public void AddCard(PaymentCard ToAdd) { Cards.Add(ToAdd); }
public void RequestAuthorization(Payment payment, PaymentCard Card) { PaymentCardServiceCenter.AuthorizePayment(payment, Card); }
public void RequestAuthorization(PaymentCard Used, double Amount, string ToKRS, string ToCard, string Title) { PaymentCardServiceCenter.AuthorizePayment(new Payment(KRS, Used.GetNr(), Amount.ToString(), ToKRS, ToCard, Title, DateTime.Now.ToString()), Used); }