Esempio 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";
     }
 }
Esempio n. 2
0
        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();
        }
        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);
        }