private void InsertarAtletas(List <AthleteDto> athletes)
        {
            var stringBuilder = new StringBuilder();

            foreach (var a in athletes)
            {
                if (!ComprobarDNI(a.Dni))
                {
                    stringBuilder.Append(a.Dni + " no registrado: DNI inválido.\n\n");
                    continue;
                }

                var cont = _athletesService.CountAthleteByDni(a.Dni);
                if (cont != 0)
                {
                    stringBuilder.Append(a.Dni + " registrado anteriormente.\n\n");
                    _validAthletes.Add(a);
                    continue;
                }

                if (DateTime.Now.Year - a.BirthDate.Year < 18 || DateTime.Now.Year - a.BirthDate.Year > 100)
                {
                    stringBuilder.Append(a.Dni + " no registrado: fecha de nacimiento no válida.\n\n");
                    continue;
                }

                _athletesService.InsertAthletesTable(a);
                _validAthletes.Add(a);
                stringBuilder.Append(a.Dni + " registrado correctamente.\n\n");
            }

            TxFileIns.Text = stringBuilder.ToString();
            GetListCompetition();
        }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (TxName.Text == null || TxSurname.Text == null || TxDni.Text == null ||
                DPBirthDate.SelectedDate == null)
            {
                MessageBox.Show(Properties.Resources.IncompleteFields);
                return;
            }

            if (!ComprobarDNI(TxDni.Text))
            {
                MessageBox.Show(Properties.Resources.InvalidDNI);
                return;
            }

            var date = (DateTime)DPBirthDate.SelectedDate;

            if (DateTime.Now.Year - date.Year < 18 || DateTime.Now.Year - date.Year > 100)
            {
                MessageBox.Show(Properties.Resources.InvalidAge);
                return;
            }

            var athlete = new AthleteDto {
                Name      = TxName.Text,
                Surname   = TxSurname.Text,
                Dni       = TxDni.Text.ToUpper(),
                BirthDate = date
            };

            if ((bool)RbMasc.IsChecked)
            {
                athlete.Gender = AthleteDto.MALE;
            }
            else
            {
                athlete.Gender = AthleteDto.FEMALE;
            }

            if (_athletesService.CountAthleteByDni(athlete.Dni) != 0)
            {
                _stringBuilder.Append(athlete.Dni + " registrado anteriormente.\n\n");
                _athletes.Add(athlete);
            }
            else
            {
                _stringBuilder.Append(athlete.Dni + " registrado correctamente.\n\n");
                _athletes.Add(athlete);
                _athletesService.InsertAthletesTable(athlete);
            }

            TxFormIns.Text           = _stringBuilder.ToString();
            TxName.Text              = "";
            TxSurname.Text           = "";
            TxDni.Text               = "";
            DPBirthDate.SelectedDate = null;
            RbMasc.IsChecked         = true;
            GetListCompetition();
        }
示例#3
0
        private void BtNext_Click(object sender, RoutedEventArgs e)
        {
            if (TxName.Text == null || TxSurname.Text == null || TxDNI.Text == null ||
                DPBirthDate.SelectedDate == null)
            {
                MessageBox.Show(Properties.Resources.IncompleteFields);
                return;
            }

            if (!ComprobarDNI(TxDNI.Text))
            {
                MessageBox.Show(Properties.Resources.InvalidDNI);
                return;
            }

            var date = (DateTime)DPBirthDate.SelectedDate;

            if (DateTime.Now.Year - date.Year < 18 || DateTime.Now.Year - date.Year > 100)
            {
                MessageBox.Show(Properties.Resources.InvalidAge);
                return;
            }

            var athlete = new AthleteDto {
                Name      = TxName.Text,
                Surname   = TxSurname.Text,
                Dni       = TxDNI.Text.ToUpper(),
                BirthDate = date
            };

            if ((bool)RBMasc.IsChecked)
            {
                athlete.Gender = AthleteDto.MALE;
            }
            else
            {
                athlete.Gender = AthleteDto.FEMALE;
            }

            if (_athletesService.CountAthleteByDni(athlete.Dni) == 0)
            {
                _athletesService.InsertAthletesTable(athlete);
            }

            CompetitionInscription.Dni = athlete.Dni;
            MainMenu.ChangeMenuSelected(Properties.Resources.TileAthletes,
                                        Properties.Resources.TileAthletesInscriptionCompetition);
        }