private void buttonDeleteSelectedMenuProduct_Click(object sender, EventArgs e)
 {
     if ((_currentTable == "menuproducts") && (dataGridViewRestaurantManagementSystem.SelectedRows.Count > 0))
     {
         var menuProductId = dataGridViewRestaurantManagementSystem.SelectedRows[0].Cells["ID"].Value.ToString();
         _writeMenuProductRepository.Delete(_readMenuProductRepository.GetByID(int.Parse(menuProductId)));
         ShowMenuProducts();
         ClearTextBoxes();
     }
     else
     {
         MessageBox.Show(@"Aby usunąc produkt menu w pierwszej kolejności musisz jakiś wybrać!");
     }
     ClearTextBoxes();
 }
 public void ShowOrders()
 {
     dataGridViewRestaurantManagementSystem.DataSource = null;
     dataGridViewRestaurantManagementSystem.DataSource = _readOrderRepository
                                                         .GetAll()
                                                         .Select(x => new
     {
         x.ID,
         Data        = x.Date,
         Sprzedajacy = _readSellerRepository.GetByID(x.SellerID).Name + " " + _readSellerRepository.GetByID(x.SellerID).Surname,
         Cena        = x.Price,
         Kalorie     = x.AmountOfCalories,
     }).ToList();
     _currentTable = "orders";
 }
 private void buttonDeleteSelectedSupply_Click(object sender, EventArgs e)
 {
     if ((_currentTable == "supplies") && (dataGridViewRestaurantManagementSystem.SelectedRows.Count > 0))
     {
         var supplyId = dataGridViewRestaurantManagementSystem.SelectedRows[0].Cells["ID"].Value.ToString();
         _writeSupplyRepository.Delete(_readSupplyRepository.GetByID(int.Parse(supplyId)));
         ShowSupplies();
         ClearTextBoxes();
     }
     else
     {
         MessageBox.Show(@"Aby usunąc dostawce w pierwszej kolejności musisz jakiegoś wybrać!");
     }
     ClearTextBoxes();
 }
Exemplo n.º 4
0
        //Dodawanie zaznaczonych produktów do listy produktów zamówienia.
        private void buttonAddProductToNewOrderListOfProducts_Click(object sender, EventArgs e)
        {
            var actualPrice            = 0;
            var actualAmountOfCalories = 0;

            if (dataGridViewListOfProducts.SelectedRows.Count > 0)
            {
                var menuProductId = dataGridViewListOfProducts.SelectedRows[0].Cells["ID"].Value.ToString();
                _products.Add(_readMenuProductRepository.GetByID(int.Parse(menuProductId)));

                dataGridViewNewOrderListOfProducts.DataSource = null;
                dataGridViewNewOrderListOfProducts.DataSource = _products;

                foreach (var product in _products)
                {
                    actualPrice            += product.Price;
                    actualAmountOfCalories += product.AmountOfCalories;
                }
                labelActualSumPrice.Text            = actualPrice.ToString();
                labelActualSumAmountOfCalories.Text = actualAmountOfCalories.ToString();
            }
            else
            {
                MessageBox.Show(@"Aby dodać produkt do listy nowego zamówienia w pierwszej kolejności musisz jakiś wybrać!");
            }
        }
 public void ShowSupplies()
 {
     dataGridViewRestaurantManagementSystem.DataSource = null;
     dataGridViewRestaurantManagementSystem.DataSource = _readSupplyRepository
                                                         .GetAll()
                                                         .Select(x => new
     {
         x.ID,
         Data_Zamowienia   = x.Date,
         Zamowiony_Produkt = x.OrderedProduct,
         Cena     = x.Price,
         Dostawca = _readSupplierRepository.GetByID(x.ProviderID).Name
     }).ToList();
     _currentTable = "supplies";
 }