Esempio n. 1
0
 //Button Clicks
 private void addMemberButton_Click(object sender, EventArgs e)
 {
     NewMemberForm newMember = new NewMemberForm();
     newMember.Show();
 }
Esempio n. 2
0
        private void addMemberButton_Click(object sender, EventArgs e)
        {
            int a, b;
            bool realAge = Int32.TryParse(ageTextBox.Text, out a);
            bool realPhone = Int32.TryParse(mobileTextBox.Text, out b);

            if (firstNameTextBox.Text.Length == 0 || firstNameTextBox.Text == "First Name")
            {
                firstNameCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.x));
                firstNameCheck.Visible = true;
            }

            else if (surnameTextBox.Text.Length == 0 || surnameTextBox.Text == "Surname")
            {
                surnameCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.x));
                surnameCheck.Visible = true;
            }

            else if (addressTextBox.Text.Length == 0 || addressTextBox.Text == "Address")
            {
                addressCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.x));
                addressCheck.Visible = true;
            }

            else if (mobileTextBox.Text.Length == 0 || mobileTextBox.Text == "Mobile" || !realPhone)
            {
                mobileCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.x));
                mobileCheck.Visible = true;
            }

            else if (ageTextBox.Text.Length == 0 || ageTextBox.Text == "Age" || !realAge)
            {
                ageCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.x));
                ageCheck.Visible = true;
            }

            else
            {
                firstNameCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.tick));
                firstNameCheck.Visible = true;
                surnameCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.tick));
                surnameCheck.Visible = true;
                addressCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.tick));
                addressCheck.Visible = true;
                mobileCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.tick));
                mobileCheck.Visible = true;
                ageCheck.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.tick));
                ageCheck.Visible = true;

                    int custID, age;
                    string firstName, surname, address, mobile;

                    custID = Int32.Parse(custIDTextBox.Text);
                    firstName = firstNameTextBox.Text;
                    surname = surnameTextBox.Text;
                    address = addressTextBox.Text;
                    mobile = mobileTextBox.Text;
                    age = Int32.Parse(ageTextBox.Text);

                    Customer newCustomer = new Customer(custID, firstName, surname, address, age, mobile);
                    Program.customerList.Add(newCustomer);

                    Account newAccount = new Account(Program.GetNextAccID(), newCustomer);
                    Program.accountList.Add(newAccount);

                    DialogResult dialogResult = MessageBox.Show("Customer was registered. Add another one?", "Success!", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {

                        NewMemberForm anotherCustomer = new NewMemberForm();
                        anotherCustomer.Show();
                        this.Close();

                    }
                    else
                    {
                        this.Close();
                    }

            }
        }