Exemplo n.º 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Говядина")
     {
         ICrud <Beef> crud = new ICrudBeef();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Beef(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                  (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Свинина")
     {
         ICrud <Pork> crud = new ICrudPork();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Pork(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                  (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Курица")
     {
         ICrud <Chicken> crud = new ICrudChicken();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Chicken(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                     (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Рыба")
     {
         ICrud <Fish> crud = new ICrudFish();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Fish(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                  (FishName)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Фрукты")
     {
         ICrud <Fruits> crud = new ICrudFruit();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Fruits(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                    (FruitType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Овощи")
     {
         ICrud <Vegetables> crud = new ICrudVegetable();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Vegetables(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                        (VegetableType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem));
     }
     else if (comboBox1.Text == "Растительность")
     {
         ICrud <Herbaceous> crud = new ICrudHerbaceous();
         crud.UpdateById(Convert.ToInt32(textBox4.Text),
                         new Herbaceous(Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text),
                                        (HerbaceousType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem));
     }
 }
Exemplo n.º 2
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));
     }
 }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "Фрукты")
            {
                double         price = double.Parse(textBox1.Text);
                int            count = int.Parse(textBox2.Text);
                AProducts      item  = new Fruits(price, count, (FruitType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Fruits> crud  = new ICrudFruit();
                crud.Create((Fruits)item);
            }
            else if (comboBox1.Text == "Овощи")
            {
                double             price = double.Parse(textBox1.Text);
                int                count = int.Parse(textBox2.Text);
                AProducts          item  = new Vegetables(price, count, (VegetableType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Vegetables> crud  = new ICrudVegetable();
                crud.Create((Vegetables)item);
            }
            else if (comboBox1.Text == "Зелень")
            {
                double             price = double.Parse(textBox1.Text);
                int                count = int.Parse(textBox2.Text);
                AProducts          item  = new Herbaceous(price, count, (HerbaceousType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Herbaceous> crud  = new ICrudHerbaceous();
                crud.Create((Herbaceous)item);
            }
            else if (comboBox1.Text == "Говядина")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Beef(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Beef> crud  = new ICrudBeef();
                crud.Create((Beef)item);
            }
            if (comboBox1.Text == "Свинина")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Pork(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Pork> crud  = new ICrudPork();
                crud.Create((Pork)item);
            }
            else if (comboBox1.Text == "Курица")
            {
                double          price = double.Parse(textBox1.Text);
                int             count = int.Parse(textBox2.Text);
                AProducts       item  = new Chicken(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Chicken> crud  = new ICrudChicken();
                crud.Create((Chicken)item);
            }


            else if (comboBox1.Text == "Рыба")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Fish(price, count, (FishName)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Fish> crud  = new ICrudFish();
                crud.Create((Fish)item);
            }
        }
Exemplo n.º 4
0
 private void textBox4_TextChanged(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     if (comboBox1.Text == "Говядина")
     {
         ICrud <Beef> crud = new ICrudBeef();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         Beef product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Свинина")
     {
         ICrud <Pork> crud = new ICrudPork();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Pork product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Курица")
     {
         ICrud <Chicken> crud = new ICrudChicken();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Chicken product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Рыба")
     {
         ICrud <Fish> crud = new ICrudFish();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Fish product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.FishName;
         comboBox3.SelectedItem = product.DealerCountry;
     }
     else if (comboBox1.Text == "Фрукты")
     {
         ICrud <Fruits> crud = new ICrudFruit();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Fruits product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
     else if (comboBox1.Text == "Овощи")
     {
         ICrud <Vegetables> crud = new ICrudVegetable();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Vegetables product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
     else if (comboBox1.Text == "Растительность")
     {
         ICrud <Herbaceous> crud = new ICrudHerbaceous();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Herbaceous product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
 }
Exemplo n.º 5
0
 private async void button1_Click(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     if (comboBox1.Text == "Говядина")
     {
         ICrud <Beef> crud = new ICrudBeef();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Свинина")
     {
         ICrud <Pork> crud = new ICrudPork();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Курица")
     {
         ICrud <Chicken> crud = new ICrudChicken();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Рыба")
     {
         ICrud <Fish> crud = new ICrudFish();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Фрукты")
     {
         ICrud <Fruits> crud = new ICrudFruit();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Овощи")
     {
         ICrud <Vegetables> crud = new ICrudVegetable();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
     else if (comboBox1.Text == "Растительность")
     {
         ICrud <Herbaceous> crud = new ICrudHerbaceous();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
     }
 }