static public bool AddNewProduct(Product NewProduct) { DentistToolsEntities context = new DentistToolsEntities(); if (SelectProduct(NewProduct.Code) == null) { context.Products.Add(NewProduct); context.SaveChanges(); return(true); } else { return(false); } }
static public bool RevokeQuantity(int Quantity, String Code) { try { DentistToolsEntities context = new DentistToolsEntities(); Product ModifiedProduct = new Product(); ModifiedProduct = context.Products.Where(p => p.Code == Code).FirstOrDefault(); ModifiedProduct.Qty -= Quantity; context.SaveChanges(); return(true); } catch { return(false); } }