Example #1
0
        private void FillForm(Shoes shoes)
        {
            textBox_name.Text          = shoes.Name;
            comboBox_dance.Text        = shoes.Dance;
            comboBox_manufacturer.Text = shoes.Manufacturer;
            comboBox_color.Text        = shoes.Color;
            comboBox_matherial.Text    = shoes.Matherial;

            numericUpDown_size.Value   = shoes.Size;
            numericUpDown_height.Value = shoes.HeelHeight;

            SelectGender(shoes.Gender);

            DisplayImages();
        }
Example #2
0
        public bool delete(string id)
        {
            Shoes shoes = findById(id);

            if (shoes == null)
            {
                return(false);
            }

            if (Directory.Exists(Path.Combine(PictureFolderPath, id)))
            {
                Directory.Delete(Path.Combine(PictureFolderPath, id), true);
            }

            return(list.Remove(findById(id)));
        }
Example #3
0
        public Shoes update(Shoes item)
        {
            Shoes shoes = findById(item.Id);

            if (shoes == null)
            {
                return(add(item));
            }

            int index = list.IndexOf(shoes);

            list.RemoveAt(index);
            list.Insert(index, item);

            return(get(index));
        }
Example #4
0
        private void FormFields_Load(object sender, EventArgs e)
        {
            shoes = form1.currentShoes;

            pictureBoxes.Add(pictureBox1);
            pictureBoxes.Add(pictureBox2);
            pictureBoxes.Add(pictureBox3);
            pictureBoxes.Add(pictureBox4);
            pictureBoxes.Add(pictureBox5);
            pictureBoxes.Add(pictureBox6);
            pictureBoxes.Add(pictureBox7);
            pictureBoxes.Add(pictureBox8);

            ShoesService shoesService = form1.shoesService;

            form1.loadListToComboBox(shoesService.getDances(), comboBox_dance);
            form1.loadListToComboBox(shoesService.getManufacturers(), comboBox_manufacturer);
            form1.loadListToComboBox(shoesService.getColors(), comboBox_color);
            form1.loadListToComboBox(shoesService.getMatherials(), comboBox_matherial);

            FillForm(shoes);
        }
Example #5
0
        private void GenerateData(int size)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            // отримати масив із перелічення
            Array genders = Enum.GetValues(typeof(Shoes.GenderEnum));

            for (int i = 0; i < size; i++)
            {
                Shoes shoes = new Shoes();

                shoes.Name         = names[random.Next(0, names.Length)];
                shoes.Manufacturer = manufacturers[random.Next(0, manufacturers.Length)];
                shoes.Dance        = dances[random.Next(0, dances.Length)];
                shoes.Color        = colors[random.Next(0, colors.Length)];;
                shoes.Matherial    = matherials[random.Next(0, matherials.Length)];;
                shoes.Size         = random.Next(5, 40);
                shoes.HeelHeight   = random.Next(0, 9);
                shoes.Gender       = (Shoes.GenderEnum)genders.GetValue(random.Next(0, genders.Length));

                shoesService.add(shoes);
            }
        }
Example #6
0
        private void ShowForm_Window(Mode mode)
        {
            if (mode == Mode.create)
            {
                currentShoes = shoesService.add(new Shoes());
            }

            FormFields form = new FormFields(this);

            if (form.ShowDialog() == DialogResult.OK)
            {
                currentShoes = form.shoes;
                shoesService.update(currentShoes);
            }
            else if (mode == Mode.create)
            {
                shoesService.delete(currentShoes.Id);
            }

            form.Dispose();

            FillForm(currentShoes);
            DisplayListFromService();
        }
Example #7
0
        public void FillForm(Shoes shoes)
        {
            groupBox_form.Visible = false;
            if (shoes == null)
            {
                return;
            }

            textBox_name.Text          = shoes.Name;
            comboBox_dance.Text        = shoes.Dance;
            comboBox_manufacturer.Text = shoes.Manufacturer;
            comboBox_color.Text        = shoes.Color;
            comboBox_matherial.Text    = shoes.Matherial;

            numericUpDown_size.Value   = shoes.Size;
            numericUpDown_height.Value = shoes.HeelHeight;

            SelectGender(shoes.Gender);

            DisplayImages();

            groupBox_form.Visible   = true;
            groupBox_pidbir.Visible = false;
        }
Example #8
0
 public Shoes add(Shoes shoes)
 {
     shoes.Id = GenerateId();
     list.Add(shoes);
     return(shoes);
 }
Example #9
0
        private void btn_pidibrat_Click(object sender, EventArgs e)
        {
            groupBox_pidbir.Visible = false;

            Shoes shoes = new Shoes();

            if (radioButton_old.Checked)
            {
                shoes.Gender = radioButton_gender_man.Checked
                    ? Shoes.GenderEnum.MAN
                    : Shoes.GenderEnum.WOMEN;
            }
            else
            {
                shoes.Gender = radioButton_gender_man.Checked
                    ? Shoes.GenderEnum.BOYS
                    : Shoes.GenderEnum.GIRLS;
            }

            shoes.Dance        = comboBox_dance_pidbir.Text.ToLower().Trim();
            shoes.Manufacturer = comboBox_manufacturer_pidbir.Text.ToLower().Trim();
            shoes.Color        = comboBox_color_pidbir.Text.ToLower().Trim();
            shoes.Matherial    = comboBox_matherial_pidbir.Text.ToLower().Trim();

            shoes.Size = (int)numericUpDown_size.Value;

            List <Shoes> shoeses = new List <Shoes>();

            foreach (Shoes sh in shoesService.getList())
            {
                // перевірки на вміст та відповідність
                // якщо не співпадає - пропускаємо та переходимо до наступного елементу
                if (shoes.Gender != sh.Gender)
                {
                    continue;
                }

                if (!(shoes.Dance.Contains(sh.Dance.ToLower()) ||
                      sh.Dance.ToLower().Contains(shoes.Dance)))
                {
                    continue;
                }

                if (!(shoes.Manufacturer.Contains(sh.Manufacturer.ToLower()) ||
                      sh.Manufacturer.ToLower().Contains(shoes.Manufacturer)))
                {
                    continue;
                }

                if (!(shoes.Color.Contains(sh.Color.ToLower()) ||
                      sh.Color.ToLower().Contains(shoes.Color)))
                {
                }

                if (!(shoes.Matherial.Contains(sh.Matherial.ToLower()) ||
                      sh.Matherial.ToLower().Contains(shoes.Matherial)))
                {
                }

                if (Math.Abs(sh.Size - shoes.Size) > 2)
                {
                    continue;
                }

                // пройшов фільтри отже додаємо
                shoeses.Add(sh);
            }

            DisplayList(shoeses);
        }
Example #10
0
        private void listBox_shoeses_SelectedIndexChanged(object sender, EventArgs e)
        {
            currentShoes = (Shoes)listBox_shoeses.SelectedItem;

            FillForm(currentShoes);
        }