Example #1
0
 private void FemaleRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (FemaleRadioButton.Checked)
     {
         SexErrorProvider.Clear();
     }
 }
Example #2
0
 private void ReadyButton_Click(object sender, EventArgs e)
 {
     if (NameTextBox.TextLength != 0 && SurnameTextBox.TextLength != 0 &&
         FathernameTextBox.TextLength != 0 &&
         (MaleRadioButton.Checked || FemaleRadioButton.Checked) &&
         (18 <= (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) &&
          (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) <= 100))
     {
         bool sex;
         if (MaleRadioButton.Checked)
         {
             sex = true;
         }
         else
         {
             sex = false;
         }
         Client client = new Client(NameTextBox.Text, SurnameTextBox.Text, FathernameTextBox.Text, sex,
                                    BirthdayDateTimePicker.Value.Date, DriverLicCheckBox.Checked, DriverLicDateTimePicker.Value.Date,
                                    false, CreationDateTimePicker.Value.Date);
         if (clientList.ClientRegistration(client))
         {
             MessageBox.Show("Регистрация нового клиента успешно завершена", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         this.Close();
     }
     else
     {
         if (NameTextBox.TextLength == 0)
         {
             NameTextBox.BackColor = Color.IndianRed;
         }
         if (SurnameTextBox.TextLength == 0)
         {
             SurnameTextBox.BackColor = Color.IndianRed;
         }
         if (FathernameTextBox.TextLength == 0)
         {
             FathernameTextBox.BackColor = Color.IndianRed;
         }
         if (18 > (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) ||
             (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) > 100)
         {
             BirthdayErrorProvider.SetError(BirthdayLabel, "Некорректный возраст");
         }
         if (!MaleRadioButton.Checked && !FemaleRadioButton.Checked)
         {
             SexErrorProvider.SetError(SexLabel, "Выберете пол");
         }
     }
 }
Example #3
0
        private void ReadyButton_Click(object sender, EventArgs e)
        {
            if (NameTextBox.TextLength != 0 && SurnameTextBox.TextLength != 0 &&
                FathernameTextBox.TextLength != 0 &&
                (MaleRadioButton.Checked || FemaleRadioButton.Checked) &&
                (18 <= (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) &&
                 (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) <= 120) &&
                (DriverLicDateTimePicker.Value.Date >= DateTime.Today.Date &&
                 DriverLicDateTimePicker.Value.Date <= DateTime.Today.Date.AddYears(10).Date))
            {
                bool sex;
                if (MaleRadioButton.Checked)
                {
                    sex = true;
                }
                else
                {
                    sex = false;
                }

                Client client = new Client(NameTextBox.Text, SurnameTextBox.Text, FathernameTextBox.Text, sex,
                                           BirthdayDateTimePicker.Value.Date, PassportMaskedTextBox.Text, DriverLicDateTimePicker.Value.Date,
                                           false, CreationDateTimePicker.Value.Date, ClientListStorage.Clients.Count + 1);
                client.ID = (new ClientService(client)).generateID();
                ClientListService.ClientRegistration(client);
                MessageBox.Show("Регистрация нового клиента успешно завершена", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                if (18 > (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) ||
                    (DateTime.Today.Year - BirthdayDateTimePicker.Value.Year) > 120)
                {
                    BirthdayErrorProvider.SetError(BirthdayLabel, "Некорректный возраст");
                }
                if (!MaleRadioButton.Checked && !FemaleRadioButton.Checked)
                {
                    SexErrorProvider.SetError(SexLabel, "Выберете пол");
                }

                if (DriverLicDateTimePicker.Value.Date < DateTime.Today.Date ||
                    DriverLicDateTimePicker.Value.Date > DateTime.Today.AddYears(10).Date)
                {
                    DriverLicErrorProvider.SetError(DriverLicDateTimePicker, "Некорректный срок действия прав");
                }
            }
        }