Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {//std_no,fn,mi,ln,email,home,contact,bday,age,yr,comitte,guar_name,gard_no,dpa
            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 com_flag          = Comm.Text != "";
            bool Guardname_flag    = GuardName.Text != "";
            bool Guardcontact_flag = GuardContact.MaskCompleted != false;
            bool DPA_flag          = checkBox1.Checked != false;
            bool membership        = radioButton1.Checked != false || radioButton2.Checked != false;

            error = null;
            if (!sn_flag || !fn_flag || !mi_flag || !ln_flag || !email_flag || !address_flag || !contact_flag || !bday_flag || !year_flag || !com_flag || !Guardname_flag || !Guardcontact_flag || !DPA_flag || !age_flag || !membership)
            {
                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";
                }
                if (!year_flag)
                {
                    error += "Year Level must not be Empty\n";
                }
                if (!com_flag)
                {
                    error += "Commitee Affiliation must not be Empty\n";
                }
                if (!Guardname_flag)
                {
                    error += "Guardian Name must not be Empty\n";
                }
                if (!Guardcontact_flag)
                {
                    error += "Guardian Contact Number must not be Empty\n";
                }
                if (!DPA_flag)
                {
                    error += "Data Privacy Act of 2012 not checked";
                }
                if (!membership)
                {
                    error += "Select Membership Type";
                }
                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,Year_Level,Comm,Guard_Name,Guard_Contact,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;
                Comm.Text            = null;
                GuardName.Text       = null;
                GuardContact.Text    = null;
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                if (DialogResult.Yes == MessageBox.Show("New Member Registered!\n\nWould you like to go back?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    Form mainmenu = new MainMenu();
                    mainmenu.Show();
                    Close();
                }
            }
        }