Ejemplo n.º 1
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;
     }
 }
Ejemplo n.º 2
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);
         }
     }
 }