コード例 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Говядина")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(MeatFactoryName));
         comboBox3.DataSource = Enum.GetValues(typeof(MeatProductType));
         ICrud <Beef> crud = new ICrudBeef();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Свинина")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(MeatFactoryName));
         comboBox3.DataSource = Enum.GetValues(typeof(MeatProductType));
         ICrud <Pork> crud = new ICrudPork();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Курица")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(MeatFactoryName));
         comboBox3.DataSource = Enum.GetValues(typeof(MeatProductType));
         ICrud <Chicken> crud = new ICrudChicken();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Рыба")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(FishName));
         comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
         ICrud <Beef> crud = new ICrudBeef();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Фрукты")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(FruitType));
         comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
         ICrud <Fruits> crud = new ICrudFruit();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Овощи")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(VegetableType));
         comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
         ICrud <Vegetables> crud = new ICrudVegetable();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
     else if (comboBox1.Text == "Растительность")
     {
         comboBox2.DataSource = Enum.GetValues(typeof(HerbaceousType));
         comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
         ICrud <Herbaceous> crud = new ICrudHerbaceous();
         crud.DeleteById(Convert.ToInt32(textBox1.Text));
     }
 }
コード例 #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text == "Говядина" || comboBox1.Text == "Свинина" || comboBox1.Text == "Курица")
            {
                dataGridView1.Columns[0].HeaderText = "ID";
                dataGridView1.Columns[1].HeaderText = "Тип";
                dataGridView1.Columns[2].HeaderText = "Фабрика";
                dataGridView1.Columns[3].HeaderText = "Цена за ящик";
                dataGridView1.Columns[4].HeaderText = "Количество ящиков";
                comboBox2.DataSource = Enum.GetValues(typeof(MeatFactoryName));
                comboBox3.DataSource = Enum.GetValues(typeof(MeatProductType));
            }
            else if (comboBox1.Text == "Фрукты" || comboBox1.Text == "Овощи" || comboBox1.Text == "Зелень")
            {
                dataGridView1.Columns[0].HeaderText = "ID";
                dataGridView1.Columns[1].HeaderText = "Вид";
                dataGridView1.Columns[2].HeaderText = "Страна";
                dataGridView1.Columns[3].HeaderText = "Цена за ящик";
                dataGridView1.Columns[4].HeaderText = "Количество ящиков";
            }
            else if (comboBox1.Text == "Рыба")
            {
                dataGridView1.Columns[0].HeaderText = "ID";
                dataGridView1.Columns[1].HeaderText = "Имя";
                dataGridView1.Columns[2].HeaderText = "Страна";
                dataGridView1.Columns[3].HeaderText = "Цена за ящик";
                dataGridView1.Columns[4].HeaderText = "Количество ящиков";
                comboBox2.DataSource = Enum.GetValues(typeof(FishName));
                comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
            }

            if (comboBox1.Text == "Фрукты")
            {
                comboBox2.DataSource = Enum.GetValues(typeof(FruitType));
                comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
            }
            else if (comboBox1.Text == "Овощи")
            {
                comboBox2.DataSource = Enum.GetValues(typeof(VegetableType));
                comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
            }
            else if (comboBox1.Text == "Зелень")
            {
                comboBox2.DataSource = Enum.GetValues(typeof(HerbaceousType));
                comboBox3.DataSource = Enum.GetValues(typeof(DealerCountry));
                ICrud <Herbaceous> crud = new ICrudHerbaceous();
                crud.DeleteById(Convert.ToInt32(textBox1.Text));
            }
        }