Ejemplo n.º 1
0
 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";
     }
 }
Ejemplo n.º 2
0
 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";
     }
 }
Ejemplo n.º 3
0
 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);
 }