Esempio n. 1
0
        public void AddProduct()
        {
            //Arrange
            DBManager business = new DBManager();
            List<Product> products = new List<Product>();
            string expected = "1, Product, 23, 1, 100";

            //Act
            business.AddProduct(1, "Product", 23, 1, 100, true, products);
            string result = products[0].Id + ", " + products[0].Name + ", " + products[0].VAT + ", " + products[0].Quantity + ", " + products[0].NettoPrice;
            //Assert
            Assert.AreEqual(expected, result);

        }
Esempio n. 2
0
 /// <summary>
 /// Add new product to ListView and List<T>
 /// </summary>
 /// <param name="name">Product name</param>
 /// <param name="vat">Product VAT</param>
 /// <param name="nettoprice">Netto price</param>
 /// <param name="quantity">Quantity</param>
 private void AddProduct(string name, decimal vat, decimal nettoprice, decimal quantity)
 {
     if (!string.IsNullOrWhiteSpace(txtProduct.Text) && !string.IsNullOrWhiteSpace(txtPrice.Text))
     {
         try
         {
             DBManager manager = new DBManager();
             manager.AddProduct(productId, name, vat, quantity, nettoprice, radioButton1.Checked, products);
             AddProductToListView();
             _itemscounter++;
             productId++;
         }
         catch (Exception)
         {
             MessageBox.Show("Wprowadziłeś niepoprawne dane!", "Błąd");
         }
     }
     else
     {
         MessageBox.Show("Wprowadź wszystkie dane!", "Błąd");
     }
 }