Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool sn_flag      = SN.MaskCompleted != false;
            bool fn_flag      = FN.Text != "";
            bool mi_flag      = MI.Text != "";
            bool ln_flag      = LN.Text != "";
            bool email_flag   = EMail.Text != "";
            bool address_flag = Address.Text != "";
            bool contact_flag = Contact.MaskCompleted != false;
            bool bday_flag    = Bday.Value.ToShortDateString() != DateTime.Now.ToShortDateString();
            bool age_flag     = Int32.Parse(Age.Text) > 0;
            bool year_flag    = Year.Text != "";
            bool DPA_flag     = checkBox1.Checked != false;
            bool membership   = radioButton1.Checked != false || radioButton2.Checked != false;
            bool gender       = radioButton3.Checked != false || radioButton4.Checked != false;

            error = null;
            if (!sn_flag || !fn_flag || !mi_flag || !ln_flag || !email_flag || !address_flag || !contact_flag || !bday_flag || !year_flag || !DPA_flag || !age_flag || !membership || !gender)
            {
                if (!fn_flag)
                {
                    error += "First Name must not be Empty \n";
                }
                if (!mi_flag)
                {
                    error += "Middle Initial must not be Empty \n";
                }
                if (!ln_flag)
                {
                    error += "Last Name must not be Empty \n";
                }
                if (!sn_flag)
                {
                    error += "Student Number must not be Empty \n";
                }
                if (!email_flag)
                {
                    error += "Email must not be Empty \n";
                }
                if (!address_flag)
                {
                    error += "Address must not be Empty \n";
                }
                if (!contact_flag)
                {
                    error += "Contact Number must not be Empty\n";
                }
                if (!bday_flag)
                {
                    if (Bday.Value.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        error += "Date of Birth must not the same as Date Today\n";
                    }
                    else
                    {
                        error += "Date of Birth does not match your Age\n";
                    }
                }
                if (!age_flag)
                {
                    error += "Age must not be 0 or a Negative Value\n";
                }
                if (!year_flag)
                {
                    error += "Year Level must not be Empty\n";
                }
                if (!DPA_flag)
                {
                    error += "Data Privacy Act of 2012 not checked\n";
                }
                if (!membership)
                {
                    error += "Select Membership Type\n";
                }
                if (!gender)
                {
                    error += "Select Gender\n";
                }
                MessageBox.Show(error, "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Warning); //Error Message Box for Invalid Data
            }
            else
            {
                MainMenu.Insert("insert into member_list(SN,FN,MI,LN,Email,Address,Contact_No,BDay,Age,Gender,Year_Level,Membership,ID_Address) values('" + requirements() + "');");
                FN.Text              = null;
                MI.Text              = null;
                LN.Text              = null;
                SN.Text              = null;
                EMail.Text           = null;
                Address.Text         = null;
                Contact.Text         = null;
                Bday.Value           = DateTime.Today;
                Age.Text             = null;
                Year.Text            = null;
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                if (DialogResult.Yes == MessageBox.Show("New Member Registered!\n\nWould you like to go back?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    Form members = new Members();
                    members.Show();
                    Close();
                }
            }
        }