/// <summary> /// Adds a product with the category White Wood. /// </summary> /// <param name="product"></param> private void AddProductToDatabase(Product product) { try { product.Category.Add(ProductDb.GetCategory(WhiteWood)); if (!ProductDb.CheckForExistingProduct(product)) { ProductDb.Add(product); ClearTxtBoxesAndCheckBoxes(); messageLbl.Text = $"{product.Height} x {product.Width} x {product.Length} added successfully"; } else { messageLbl.Text = "Product already exists in database"; } } catch (SqlException) { messageLbl.Text = "Failed to add Product"; } }
/// <summary> /// Adds a product with multiple categories. /// </summary> /// <param name="p"></param> /// <param name="treatmentLevel"></param> /// <param name="treatmentType"></param> private void AddProductToDatabase(Product p, int treatmentLevel, int treatmentType) { try { p.Category.Add(ProductDb.GetCategory(treatmentLevel)); p.Category.Add(ProductDb.GetCategory(treatmentType)); if (!ProductDb.CheckForExistingProduct(p)) { ProductDb.Add(p); ClearTxtBoxesAndCheckBoxes(); messageLbl.Text = $"{p.Height} x {p.Width} x {p.Length} added successfully"; } else { messageLbl.Text = "Product already exists in database"; } } catch (SqlException) { messageLbl.Text = "Failed to add Product"; } }