Esempio n. 1
0
        private void AcceptButton(object sender, EventArgs e)
        {
            float cash = 0;

            if (paymentsMethod != PaymentsMethod.None)
            {
                button1.BackColor = Color.White;

                PaymentFactory pf = new PaymentFactory();

                if (paymentsMethod == PaymentsMethod.Cash)
                {
                    textBox1.BackColor = Color.White;
                    try
                    {
                        cash = float.Parse(textBox1.Text);
                    }
                    catch (Exception exception)
                    {
                        textBox1.BackColor = Color.Brown;
                    }
                }

                var res = pf.CreatePaymentMethod(paymentsMethod).MakePayment(100, cash);

                if (res.Result)
                {
                    this.DialogResult = DialogResult.Yes;
                    this.Close();
                }
            }
            else
            {
                button1.BackColor = Color.Brown;
            }
        }