Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbFullName.Text) ||
                string.IsNullOrEmpty(tbMobile.Text) || string.IsNullOrEmpty(tbPhotoFile.Text))
            {
                MessageBox.Show("Null fields!", "Error");
            }
            else if (dpBirth.Value > DateTime.Now.AddYears(-22))
            {
                MessageBox.Show("The competitor must be less than 22 years old at the time of registration!", "Error");
            }
            else if (!tbPassword.Text.Equals(tbPasswordAgain.Text))
            {
                MessageBox.Show("Passwords not equals!", "Error");
            }
            else if (!ValidatePassword(tbPassword.Text))
            {
                MessageBox.Show("Passwords invalid!", "Error");
            }
            else
            {
                User.FullName    = tbFullName.Text;
                User.Gender      = cbGender.SelectedText;
                User.DateOfBirth = dpBirth.Value;
                Competitor.City  = cbCity.SelectedText;
                User.MobileNo    = tbMobile.Text;
                User.Photo       = tbPhotoFile.Text;

                Competitor.Edit();
                User.Edit();

                MessageBox.Show("Success update", "Success");
            }
        }