Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                AddRegistration      reg       = new AddRegistration();
                LibraryBusinessLogic libraryBL = new LibraryBusinessLogic();
                string name   = nameTextBox.Text;
                int    number = 0;
                if (!int.TryParse(universityNumberTextBox.Text, out number))
                {
                    throw new Exception("University Number should be numeric only");
                }
                string emailID = emailIDTextBox.Text;
                string gender  = "";
                string password;

                if (maleRadioButton.Checked == true)
                {
                    gender = "Male";
                }

                if (femaleradioButton.Checked == true)
                {
                    gender = "female";
                }

                if (!passwordTextBox.Text.Equals(reEnterPasswordTextBox.Text))
                {
                    throw new Exception("Both Password don't match");
                }

                password = passwordTextBox.Text;

                string address = addressTextBox.Text;

                int contact = 0;

                if (!int.TryParse(contactNumberTextBox.Text, out contact))
                {
                    throw new Exception("Contact Number should be numeric only");
                }

                reg.StudentNumber = number;
                reg.StudentName   = name;
                reg.EmailID       = emailID;
                reg.Gender        = gender;
                reg.Address       = address;
                reg.ContactNumber = contact;
                reg.Password      = password;

                if (libraryBL.RegistrationAdd(reg))
                {
                    Home home = new Home();
                    home.SetData("Student", number.ToString());
                    home.Show();
                    this.Dispose();
                    ClearData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }