Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList GetAll()
- {
- ArrayList DishList = new ArrayList();
- using (SqlConnection connection = new SqlConnection(connectString))
- {
- SqlCommand command = new SqlCommand("SELECT * FROM Dish;", connection);
- connection.Open();
- SqlDataReader reader = command.ExecuteReader();
- if (reader.HasRows)
- {
- while (reader.Read())
- {
- int IdDish = reader.GetInt32(0);
- string NameDish = reader.GetString(1);
- int PriceDish = reader.GetInt32(2);
- byte[] ImageDish = (byte[])reader[3];
- int CatIdDish = reader.GetInt32(4);
- string CatNameDish = GetCategoryName(CatIdDish);
- DishList.Add(new DishData() { Id = IdDish, Name = NameDish, Price = PriceDish, CatId = CatIdDish, CatName = CatNameDish, Image = ImageDish});
- }
- }
- reader.Close();
- return DishList;
- }
- }
- private void LoadDishGridView()
- {
- DishGridView.Rows.Clear();
- if (CategoriesComboBox.SelectedIndex == 0)
- {
- btnEditCat.Enabled = false;
- foreach (DishData Dish in _Dish.GetAll())
- {
- DishGridView.Rows.Add(Dish.Id, Dish.Name, Dish.Price, Dish.CatName, Dish.Image);
- }
- }
- else if (CategoriesComboBox.SelectedIndex > 0)
- {
- btnEditCat.Enabled = true;
- string CategoryName = CategoriesComboBox.SelectedItem.ToString();
- int CategoryID = _Category.GetId(CategoryName);
- foreach (DishData Dish in _Dish.GetAllfromCat(CategoryID))
- {
- DishGridView.Rows.Add(Dish.Id, Dish.Name, Dish.Price, CategoryName, Dish.Image);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement