public void Execute()
        {
            try {
                using (var command =
                           new SQLiteCommand(Resources.SQL_SELECT_CATEGORY_BY_COMPETITION, _conn.DbConnection)) {
                    command.Parameters.AddWithValue("@COMPETITION_ID", _competitionDto.ID);
                    using (var reader = command.ExecuteReader()) {
                        Categories = new List <AbsoluteCategory>();
                        while (reader.Read())
                        {
                            int[] id            = { reader.GetInt32(2), reader.GetInt32(3) };
                            var   childCategory = new CompetitionService().SelectCategoryByAbsoluteCategories(id);

                            var category = new AbsoluteCategory {
                                Id        = reader.GetInt32(0),
                                Name      = reader.GetString(1),
                                CategoryM = childCategory.ElementAt(0),
                                CategoryF = childCategory.ElementAt(1)
                            };

                            Categories.Add(category);
                        }
                    }
                }
            }
            catch (SQLiteException) {
                _conn.DbConnection?.Close();
                throw;
            }
        }
예제 #2
0
        public int GetIdAbsolute(AbsoluteCategory c)
        {
            var search = new GetAbsoluteCategory(ref _conn, c);

            search.Execute();
            return(search.id);
        }
예제 #3
0
 public SelectHasParticipatedTimeLogicByCategory(ref DBConnection conn, CompetitionDto competition,
                                                 AbsoluteCategory categorySelected, string gender)
 {
     _conn        = conn;
     Table        = new DataTable();
     _competition = competition;
     _category    = categorySelected;
     _gender      = gender;
 }
예제 #4
0
        public DataTable SelectCompetitionTimes(CompetitionDto competition, AbsoluteCategory categorySelected,
                                                string gender)
        {
            var selectCompetition =
                new SelectHasParticipatedTimeLogicByCategory(ref _conn, competition, categorySelected, gender);

            selectCompetition.Execute();
            return(selectCompetition.Table);
        }
        public CategoriesDialog(AbsoluteCategory category, List <AbsoluteCategory> absolutes)
        {
            InitializeComponent();
            cat            = category;
            this.absolutes = absolutes;
            Nombre.Text    = category.Name;

            DesdeF.Text = category.CategoryF.MinAge.ToString();
            HastaF.Text = category.CategoryF.MaxAge.ToString();
            DesdeM.Text = category.CategoryM.MinAge.ToString();
            HastaM.Text = category.CategoryM.MaxAge.ToString();
        }
        public void GeneratorDefaultCategoriesTest()
        {
            var json = new JsonDeserialize <AbsoluteCategory>("DefaultCategories.json");

            string[] categorias = { "JUNIOR", "SENIOR", "VETERAN_A", "VETERAN_B", "VETERAN_C" };
            int[]    agem       = { 18, 19, 35, 45, 55 };
            int[]    ageM       = { 18, 34, 44, 54, int.MaxValue };
            var      categories = new AbsoluteCategory[categorias.Length];

            for (var i = 0; i < categories.Length; i++)
            {
                var str = categorias[i];

                var absoluteCategory = new AbsoluteCategory {
                    Id        = 1,
                    Name      = str,
                    CategoryM = new CategoryDto {
                        Id     = 1,
                        Name   = $"{str}_M",
                        MinAge = agem[i],
                        MaxAge = ageM[i],
                        Gender = "M"
                    },
                    CategoryF = new CategoryDto {
                        Id     = 1,
                        Name   = $"{str}_F",
                        MinAge = agem[i],
                        MaxAge = ageM[i],
                        Gender = "F"
                    }
                };

                categories[i] = absoluteCategory;
            }

            json.Serialize(categories);
            foreach (var category in json.ListJson())
            {
                if (category != null)
                {
                    Console.WriteLine($@"{category.Name} {category.CategoryF.Name} {category.CategoryM.Name}");
                }
            }
        }
예제 #7
0
        private void CompetitionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LayoutButtons.Children.Clear();
            var but = GenerateButton();

            var cat = new AbsoluteCategory {
                Id        = -1,
                Name      = Properties.Resources.Absolute.ToUpper(),
                CategoryM = new CategoryDto {
                    Name = $"{Properties.Resources.Absolute.ToUpper()}_M"
                },
                CategoryF = new CategoryDto {
                    Name = $"{Properties.Resources.Absolute.ToUpper()}_F"
                }
            };

            but.Content = cat.Name;

            Competition = new CompetitionDto {
                ID = _ids[CompetitionList.SelectedIndex]
            };

            Competition = _competitionService.SearchCompetitionById(Competition);

            _categories = _competitionService.SelectAllCategoriesByCompetitionId(Competition);
            _categories = _categories.Reverse().Append(cat).Reverse();

            CategorySelected = _categories.First();

            var count = 0;

            foreach (var category in _categories)
            {
                but         = GenerateButton();
                but.Content = category.Name.Replace('_', ' ').ToUpper();
                but.Tag     = count++;

                LayoutButtons.Children.Add(but);
            }

            ButtonBase_OnClick(LayoutButtons.Children[0], null);
        }
예제 #8
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var bt = (Button)sender;

            if ((int?)bt.Tag != null)
            {
                var indexOldBut = _categories.ToList().FindIndex(c => c.Name.Equals(CategorySelected.Name));
                var old         = (Button)LayoutButtons.Children[indexOldBut];
                old.FontWeight = FontWeights.Normal;
                old.Background = Brushes.Transparent;

                LayoutButtons.Children[indexOldBut] = old;

                bt.FontWeight = FontWeights.Bold;
                bt.Background = Brushes.AliceBlue;


                CategorySelected = _categories.ElementAt((int)bt.Tag);

                Gender_OnClick(null, null);
            }
        }
예제 #9
0
 public GetAbsoluteCategory(ref DBConnection conn, AbsoluteCategory comp)
 {
     _conn     = conn;
     _absolute = comp;
 }
예제 #10
0
 public AddAbsoluteCategory(ref DBConnection conn, AbsoluteCategory category)
 {
     _absolute = category;
     _conn     = conn;
 }
예제 #11
0
        public void AddAbsoluteCategory(AbsoluteCategory category)
        {
            var add = new AddAbsoluteCategory(ref _conn, category);

            add.Execute();
        }
        private void BtAdd_Click(object sender, RoutedEventArgs e)
        {
            if (CheckAll())
            {
                checkFields();

                _competition.Rules  = bytes;
                _competition.Status = "OPEN";
                if (PreinscriptionIsChecked())
                {
                    _competition.Preinscription     = true;
                    _competition.DaysPreinscription = int.Parse(PrecioInscripcion.Text);
                }
                else
                {
                    _competition.Preinscription = false;
                }

                checkAges();

                foreach (AbsoluteCategory c in Categories.Items
                         ) //modificar las categorias que te devuelve el dialogo no el listbox
                {
                    _serviceCategories.AddCategory(c.CategoryF);
                    _serviceCategories.AddCategory(c.CategoryM);
                }

                //añadir absoluta categoria vincular
                _serviceComp.AddCompetition(_competition);
                _competition.ID = _serviceComp.GetIdCompetition(_competition);
                _serviceEnroll  = new EnrollService(_competition);
                foreach (AbsoluteCategory c in Categories.Items)
                {
                    var idm   = _serviceCategories.GetCategory(c.CategoryM);
                    var idf   = _serviceCategories.GetCategory(c.CategoryF);
                    var nueva = new AbsoluteCategory {
                        Name      = c.Name,
                        CategoryF = idf,
                        CategoryM = idm
                    };

                    _serviceCategories.AddAbsoluteCategory(nueva);
                    long id = _serviceComp.GetIdAbsolute(nueva);

                    _serviceEnroll.EnrollAbsoluteCompetition(_competition.ID, id);
                }


                //vincular refunds y competicion
                foreach (var c in refundsList)
                {
                    _serviceEnroll.EnrollRefundsCompetition(_competition.ID, c.date_refund, c.refund / 100);
                }


                //METER PLAZOS en inscription dates

                foreach (InscriptionDatesDto p in Plazos_list.Items)
                {
                    _serviceComp.AddInscriptionDate(p, _competition);
                }


                MessageBox.Show("Competicion agregada correctamente.");

                clearAll();
            }
            else
            {
                MessageBox.Show("Por favor, revise que todos los campos se han introducido correctamente");
            }
        }