async void FillGrid()
        {
            MakeApiService serviceMake = new MakeApiService();

            var listMake = await serviceMake.GetMakesAsync();

            cbMake.ItemsSource = listMake;
            ModelApiService service = new ModelApiService();
            List <ModelVM>  list    = await service.GetModelsAsync(txtModel.Text);

            ModelVM.Clear();
            ModelVM.AddRange(list);

            var count = ModelVM.Count();
            int numberOfObjectsPerPage = 10;//int.Parse(cbCount.Text);
            int pages = (int)Math.Ceiling((double)count / (double)numberOfObjectsPerPage);

            GenerationBtn(pages, pageNumber);

            int begin = (pageNumber - 1) * numberOfObjectsPerPage;
            int end   = pageNumber * numberOfObjectsPerPage;

            DBGrid.ItemsSource = ModelVM.Skip(numberOfObjectsPerPage * (pageNumber - 1))
                                 .Take(numberOfObjectsPerPage);
        }
        async void GetMakes()
        {
            MakeApiService service = new MakeApiService();

            txtMake.Clear();
            List <MakeVM> list = await service.GetMakesAsync(txtMake.Text);

            MakeVM.Clear();
            MakeVM.AddRange(list);
            FillGrid();
        }
 private async void BtnAddMake_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MakeApiService service = new MakeApiService();
         ShowMessage(await service.CreateAsync(new MakeAddModel {
             Name = txtMake.Text
         }));
         GetMakes();
         lblError.Foreground = Brushes.White;
         lblError.Content    = "";
     }
     catch (WebException wex)
     {
         ShowException(wex);
     }
 }
 private async void DeleteMenuItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (DBGrid.SelectedItem != null)
         {
             MakeVM         make    = (DBGrid.SelectedItem as MakeVM);
             MakeApiService service = new MakeApiService();
             int            id      = make.Id;
             ShowMessage(await service.DeleteAsync(new MakelDeleteVM {
                 Id = id
             }));
             GetMakes();
         }
     }
     catch (WebException wex)
     {
         ShowException(wex);
     }
 }
Exemple #5
0
        async void FillMake(int id)
        {
            MakeApiService service  = new MakeApiService();
            var            makes    = service.GetMakeByModels(id);
            var            listMake = await service.GetMakesAsync();

            foreach (var children in listMake)
            {
                var BoxItem = new ComboBoxItem()
                {
                    Content = children.Name, TabIndex = children.Id
                };
                make.Items.Add(BoxItem);
                if (BoxItem.TabIndex == makes)
                {
                    make.SelectedItem = BoxItem;
                }
            }
            make.SelectionChanged += BoxMake_SelectionChanged;
        }
 private async void BtnUpdate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (DBGrid.SelectedItem != null)
         {
             MakeApiService service = new MakeApiService();
             MakeVM         make    = (DBGrid.SelectedItem as MakeVM);
             int            id      = make.Id;
             ShowMessage(await service.UpdateAsync(new MakeVM {
                 Id = id, Name = txtMake.Text
             }));
             btnUpdate.IsEnabled = false;
             GetMakes();
         }
     }
     catch (WebException wex)
     {
         ShowException(wex);
     }
 }
Exemple #7
0
        //async void FillMake(int id)
        //{
        //    MakeApiService service = new MakeApiService();
        //    var makes = service.GetMakeByModels(id);
        //    var listMake = await service.GetMakesAsync();
        //    foreach (var children in listMake)
        //    {
        //        var BoxItem = new ComboBoxItem() { Content = children.Name, TabIndex = children.Id };
        //        make.Items.Add(BoxItem);
        //        if(BoxItem.TabIndex==makes)
        //        {
        //            make.SelectedItem = BoxItem;
        //        }
        //    }
        //    make.SelectionChanged += Box_SelectionChanged;
        //}
        async void FillPanel()
        {
            spCars.Children.Clear();
            spCars.Children.Add(new Label {
                Content = "Характеристики авто", FontSize = 25, Margin = new Thickness(20, 15, 30, 15)
            });
            var listComboBox = new List <ComboBox>();

            MakeApiService makeApi  = new MakeApiService();
            var            listMake = await makeApi.GetMakesAsync();

            FilterApiService      service = new FilterApiService();
            List <FNameViewModel> list    = await service.GetFiltersAsync();

            CarApiService apiService = new CarApiService();

            Label Name = new Label();

            Name.Content  = "Марка";
            Name.Width    = 90;
            Name.Margin   = new Thickness(20, 15, 30, 15);
            Name.FontSize = 15;

            ComboBox box = new ComboBox();

            foreach (var children in listMake)
            {
                box.Items.Add(new ComboBoxItem()
                {
                    Content = children.Name, TabIndex = children.Id
                });
            }
            box.SelectionChanged += Box_SelectionChanged;
            box.Name              = "Марка";
            box.Width             = 150;
            box.Margin            = new Thickness(5, 15, 10, 15);
            spCars.Children.Add(Name);
            spCars.Children.Add(box);


            FilterVM.Clear();
            FilterVM.AddRange(list);

            models.Name   = "Модель";
            models.Width  = 150;
            models.Margin = new Thickness(5, 15, 10, 15);

            Name          = new Label();
            Name.Content  = "Модель";
            Name.FontSize = 15;
            Name.Width    = 90;
            Name.Margin   = new Thickness(20, 15, 30, 15);
            spCars.Children.Add(Name);
            models.SelectionChanged += Models_SelectionChanged;
            spCars.Children.Add(models);
            id = new int[FilterVM.Count];
            int i = 0;

            foreach (var item in FilterVM)
            {
                string name = item.Name.Replace(" ", "_");

                if (name != ("Модель"))
                {
                    int j         = i;
                    var listValue = new List <string>();
                    Name          = new Label();
                    Name.Content  = item.Name;
                    Name.Width    = 90;
                    Name.Margin   = new Thickness(20, 15, 30, 15);
                    Name.FontSize = 15;
                    box           = new ComboBox()
                    {
                        TabIndex = i
                    };
                    foreach (var children in item.Children)
                    {
                        box.Items.Add(new ComboBoxItem()
                        {
                            Content = children.Name, TabIndex = children.Id
                        });
                    }
                    box.SelectionChanged += Box_SelectionChanged1;
                    box.Name              = name;
                    box.Width             = 150;
                    box.Margin            = new Thickness(5, 15, 10, 15);
                    box.Tag = item.Id;


                    spCars.Children.Add(Name);
                    spCars.Children.Add(box);
                }
                else
                {
                    continue;
                }
                i++;
            }
        }