Exemple #1
0
 public bool Add(Product item)
 {
     try
     {
         item.ModifiedDate = DateTime.Today;
         item.rowguid      = Guid.NewGuid();
         production.GetTable <Product>().InsertOnSubmit(item);
         production.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #2
0
 public static void UpdateProduct(int id, Product product)
 {
     using (ProductionDataContext productionDataContext = new ProductionDataContext())
     {
         Product original = productionDataContext.GetTable <Product>().Single(p => p.ProductID == product.ProductID);
         original.Name                  = product.Name;
         original.ProductNumber         = product.ProductNumber;
         original.MakeFlag              = product.MakeFlag;
         original.FinishedGoodsFlag     = product.FinishedGoodsFlag;
         original.Color                 = product.Color;
         original.SafetyStockLevel      = product.SafetyStockLevel;
         original.ReorderPoint          = product.ReorderPoint;
         original.StandardCost          = product.StandardCost;
         original.ListPrice             = product.ListPrice;
         original.Size                  = product.Size;
         original.SizeUnitMeasureCode   = product.SizeUnitMeasureCode;
         original.WeightUnitMeasureCode = product.WeightUnitMeasureCode;
         original.Weight                = product.Weight;
         original.DaysToManufacture     = product.DaysToManufacture;
         original.ProductLine           = product.ProductLine;
         original.Class                 = product.Class;
         original.Style                 = product.Style;
         original.ProductSubcategoryID  = product.ProductSubcategoryID;
         original.ProductModelID        = product.ProductModelID;
         original.SellStartDate         = product.SellStartDate;
         original.SellEndDate           = product.SellEndDate;
         original.DiscontinuedDate      = product.DiscontinuedDate;
         original.ModifiedDate          = DateTime.Today;
         productionDataContext.SubmitChanges();
     }
 }
Exemple #3
0
 public static void UpdateProduct(Product product)
 {
     using (ProductionDataContext dataContext = new ProductionDataContext())
     {
         Product testProduct = dataContext.Product.Single(p => p.ProductID.Equals(product.ProductID));
         testProduct.Name                  = product.Name;
         testProduct.ProductNumber         = product.ProductNumber;
         testProduct.MakeFlag              = product.MakeFlag;
         testProduct.FinishedGoodsFlag     = product.FinishedGoodsFlag;
         testProduct.Color                 = product.Color;
         testProduct.SafetyStockLevel      = product.SafetyStockLevel;
         testProduct.ReorderPoint          = product.ReorderPoint;
         testProduct.StandardCost          = product.StandardCost;
         testProduct.ListPrice             = product.ListPrice;
         testProduct.Size                  = product.Size;
         testProduct.SizeUnitMeasureCode   = product.SizeUnitMeasureCode;
         testProduct.WeightUnitMeasureCode = product.WeightUnitMeasureCode;
         testProduct.Weight                = product.Weight;
         testProduct.DaysToManufacture     = product.DaysToManufacture;
         testProduct.ProductLine           = product.ProductLine;
         testProduct.Class                 = product.Class;
         testProduct.Style                 = product.Style;
         testProduct.ProductSubcategoryID  = product.ProductSubcategoryID;
         testProduct.ProductModelID        = product.ProductModelID;
         testProduct.SellStartDate         = product.SellStartDate;
         testProduct.SellEndDate           = product.SellEndDate;
         testProduct.DiscontinuedDate      = product.DiscontinuedDate;
         testProduct.ModifiedDate          = DateTime.Today;
         dataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
     }
 }
Exemple #4
0
 public static void RemoveProduct(Product p)
 {
     using (ProductionDataContext productionDataContext = new ProductionDataContext())
     {
         productionDataContext.Product.DeleteOnSubmit(p);
         productionDataContext.SubmitChanges();
     }
 }
Exemple #5
0
 public void AddColors(IEnumerable <Color> colors)
 {
     using (var context = new ProductionDataContext(_connectionString))
     {
         context.Colors.InsertAllOnSubmit(colors);
         context.SubmitChanges();
     }
 }
        public static void cleanUp()
        {
            ProductionDataContext production = new ProductionDataContext();
            Product product = production.Products.Where(p => p.ProductID == 316).First();

            product.Name = "Blade";
            production.SubmitChanges();
        }
Exemple #7
0
 public void AddProductCategory(ProductCategory productCategory)
 {
     using (ProductionDataContext db = new ProductionDataContext())
     {
         db.ProductCategories.InsertOnSubmit(productCategory);
         db.SubmitChanges();
     }
 }
Exemple #8
0
 public void AddLocation(Location location)
 {
     using (ProductionDataContext db = new ProductionDataContext())
     {
         db.Location.InsertOnSubmit(location);
         db.SubmitChanges();
     }
 }
 public void AddItems(IEnumerable <Item> items)
 {
     using (var context = new ProductionDataContext(_connectionString))
     {
         context.Items.InsertAllOnSubmit(items);
         context.SubmitChanges();
     }
 }
 public void AddItem(Item item)
 {
     using (var context = new ProductionDataContext(_connectionString))
     {
         context.Items.InsertOnSubmit(item);
         context.SubmitChanges();
     }
 }
Exemple #11
0
 public static void AddProduct(Product p)
 {
     using (ProductionDataContext productionDataContext = new ProductionDataContext())
     {
         productionDataContext.Product.InsertOnSubmit(p);
         productionDataContext.SubmitChanges();
     }
 }
Exemple #12
0
 public static void DeleteProduct(Product product)
 {
     using (ProductionDataContext dataContext = new ProductionDataContext())
     {
         Product current = dataContext.Product.Single(p => product.ProductID.Equals(p.ProductID));
         dataContext.Product.DeleteOnSubmit(current);
         dataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
     }
 }
 public IEnumerable <BodyStyle> AddBodyStyles(List <BodyStyle> styles)
 {
     using (var context = new ProductionDataContext(_connectionString))
     {
         context.BodyStyles.InsertAllOnSubmit(styles);
         context.SubmitChanges();
         return(styles);
     }
 }
 public IEnumerable <Sleeve> AddSleeves(List <Sleeve> sleeve)
 {
     using (var context = new ProductionDataContext(_connectionString))
     {
         context.Sleeves.InsertAllOnSubmit(sleeve);
         context.SubmitChanges();
         return(sleeve);
     }
 }
Exemple #15
0
        public void UpdateProductCategory(string name, int id)
        {
            using (ProductionDataContext db = new ProductionDataContext())
            {
                ProductCategory output = db.ProductCategories.SingleOrDefault(productCategory => productCategory.ProductCategoryID == id);

                output.Name = name;
                db.SubmitChanges();
            }
        }
Exemple #16
0
 public void DeleteProductCategory(int id)
 {
     using (ProductionDataContext db = new ProductionDataContext())
     {
         ProductCategory output = db.ProductCategories.SingleOrDefault(productCategory => productCategory.ProductCategoryID == id);
         if (output != null)
         {
             db.ProductCategories.DeleteOnSubmit(output);
             db.SubmitChanges();
         }
     }
 }
Exemple #17
0
        public void DeleteLocation(int id)
        {
            using (ProductionDataContext db = new ProductionDataContext())
            {
                Location result = db.Location.FirstOrDefault(l => l.LocationID == id);

                if (result != null)
                {
                    db.Location.DeleteOnSubmit(result);
                    db.SubmitChanges();
                }
            }
        }
Exemple #18
0
        public void UpdateLocation(int id, string name)
        {
            using (ProductionDataContext db = new ProductionDataContext())
            {
                Location result = db.Location.FirstOrDefault(l => l.LocationID == id);

                if (result != null)
                {
                    result.Name         = name;
                    result.ModifiedDate = DateTime.Today;
                    db.SubmitChanges();
                }
            }
        }