예제 #1
0
        private void CreateAccountButton_Click(object sender, EventArgs e)
        {
            string   customerName = CustomerNameTextBox.Text;
            DateTime birthDate    = BirthDatePicker.Value;

            // Validations
            if (!ValidateCustomerName(customerName))
            {
                MessageBox.Show("Customer name is invalid.");
                return;
            }
            if (!ValidateBirthdate(birthDate))
            {
                MessageBox.Show("Birthdate is invalid.");
                return;
            }

            string phone   = PhoneTextInput;
            string address = AddressTextInput;

            Account newAccount = new Account(customerName, birthDate, phone, address);

            newAccount.DepositMoney(1000);
            newAccount.WithdrawMoney(500);

            StorageUtilityFunctions.SaveAccount(newAccount);
            Account lastAccount = StorageUtilityFunctions.GetLastAccount();

            DisplayAccountForm displayAccountForm = new DisplayAccountForm(newAccount);

            this.Hide();
            displayAccountForm.ShowDialog();
            this.Show();
        }
예제 #2
0
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            // MessageBox.Show("Create button has been clicked");

            string   customerName = txtCustomerName.Text;
            DateTime birthDate    = BirthDatePicker.Value;

            if (!ValidateCustomerName(customerName))
            {
                MessageBox.Show("Customer Name is invalid");
                return;
            }
            else if (ValidateCustomerBirthDate(birthDate))
            {
                MessageBox.Show("You have to be at least 18 years old to create an account in our bank");
                return;
            }

            string phoneNumber = PhoneTextInput;
            string address     = AddressTextInput;

            //Account newAccount = new Account(customerName, birthDate, phoneNumber, address);

            CheckingAccount newCheckingAccount = new CheckingAccount(-1, customerName, birthDate, phoneNumber, address);

            SavingAccount newSavingAccount = new SavingAccount(-1, customerName, birthDate, phoneNumber, address);



            //StorageUtilityFunctions.SaveAccount(newAccount);

            Account lastAccount = StorageUtilityFunctions.GetLastAccount();

            DisplayAccountForm displayAccount  = new DisplayAccountForm(newSavingAccount);
            DisplayAccountForm displayAccount1 = new DisplayAccountForm(newCheckingAccount);

            displayAccount1.Text = "Checking Account";
            displayAccount.Text  = "Saving Account";

            this.Hide();
            displayAccount.Show();
            displayAccount1.Show();
            this.Show();

            // MessageBox.Show($"Account of customer {customerName} has been created.");
        }