Пример #1
0
        public bool AddProduct(ProductVM displayP)
        {
            hasError = false;
            try
            {
                ProductModel    p            = new ProductModel(displayP);
                LinqDataContext dc           = new LinqDataContext();
                int?            newProductId = 0;
                dc.AddProduct(p.CategoryName, p.ModelNumber, p.ModelName, p.UnitCost, p.Description, ref newProductId);
                p.ProductId = (int)newProductId;
                displayP.ProductAdded2DB(p); //update corresponding Product ProductId using ProductModel
            }
            catch (Exception ex)
            {
                errorMessage = "Add error, " + ex.Message;
                hasError     = true;
            }

            return(!hasError);
        }