private void Submit(object sender, RoutedEventArgs e)
        {
            Card card = null;

            try
            {
                switch (box.Text)
                {
                case "Karta bankomatowa":
                    card = PaymentCenter.Instance.AddNewCardRequest(number.Text, CardType.ATMCard, bank.Text);
                    MessageBox.Show("Dodano kartę o numerze: " + card.Number);
                    break;

                case "Karta kredytowa":
                    DebitHeight debit = new DebitHeight(number.Text, bank.Text);
                    debit.ShowDialog();
                    break;

                case "Karta debetowa":
                    card = PaymentCenter.Instance.AddNewCardRequest(number.Text, CardType.DebitCard, bank.Text);
                    MessageBox.Show("Dodano kartę o numerze: " + card.Number);
                    break;

                default:
                    MessageBox.Show("Nie wybrano typu karty");
                    break;
                }
            }
            catch (NullUserException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (WrongUserException ex2)
            {
                MessageBoxResult result = MessageBox.Show(ex2.Message + "\r\nCzy chcesz dodać nowego klienta?", "Word Processor", MessageBoxButton.YesNo);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    AddUserDialog user = new AddUserDialog(number.Text, CardType.ATMCard, bank.Text);
                    user.ShowDialog();
                    break;

                case MessageBoxResult.No:
                    return;
                }
            }
            catch (NoSuchBankException ex3)
            {
                MessageBox.Show(ex3.Message + "\r\n" + ex3.Name);
            }
            catch (InactiveBankException ex4)
            {
                MessageBox.Show(ex4.Message);
            }
        }
Exemplo n.º 2
0
        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            bool success = false;
            Card card    = null;

            try
            {
                card    = PaymentCenter.Instance.AddNewCardRequest(ClientNumber, CardType.CreditCard, BankName, decimal.Parse(debit.Text));
                success = true;
            }
            catch (NullUserException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (WrongUserException ex2)
            {
                MessageBoxResult result = MessageBox.Show(ex2.Message + "\r\nCzy chcesz dodać nowego klienta?", "", MessageBoxButton.YesNo);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    AddUserDialog user = new AddUserDialog(ClientNumber, CardType.CreditCard, BankName);
                    user.ShowDialog();
                    break;

                case MessageBoxResult.No:
                    return;
                }
            }
            catch (NoSuchBankException ex3)
            {
                MessageBox.Show(ex3.Message + "\r\n" + ex3.Name);
            }
            catch (InactiveBankException ex4)
            {
                MessageBox.Show(ex4.Message);
            }
            catch (Exception)
            {
                MessageBox.Show("Coś poszło nie tak.\r\nKarta nie została dodana.");
            }
            if (success)
            {
                MessageBox.Show("Pomyślnie dodano kartę o numerze: " + card.Number);
            }
            Close();
        }