Exemple #1
0
        public static int UpdateProduct(
            DasDBDataContext dbcontext,
            int productID,
            string productName,
            string productNumber,
            decimal productPrice,
            string productImage,
            string productDescription,
            string productImageBox,
            string productImageOOBox
            )
        {
            var prod = dbcontext.ProductRelCategories.FirstOrDefault(p => p.ProductID == productID);

            if (prod == null)
            {
                return 0;
            }
            prod.Product.ProductName = productName;
            prod.Product.ProductNumber = productNumber;
            prod.Product.ProductPrice = productPrice;
            prod.Product.ProductImage = productImage;
            prod.Product.ProductDescription = productDescription;
            prod.Product.ProductImageBox = productImageBox;
            prod.Product.ProductImageOOBox = productImageOOBox;

            dbcontext.SubmitChanges();

            return 1;
        }
Exemple #2
0
        public static int InsertProduct(
            DasDBDataContext dbcontext,
            string productName,
            string productNumber,
            decimal productPrice,
            string productImage,
            string productDescription,
            string productImageBox,
            string productImageOOBox

            )
        {
            var prod = new Product()
            {
                ProductName = productName,
                ProductNumber = productNumber,
                ProductPrice = productPrice,
                ProductImage = productImage,
                ProductDescription = productDescription,
                ProductImageBox = productImageBox,
                ProductImageOOBox = productImageOOBox
            };

            dbcontext.Products.InsertOnSubmit(prod);
            dbcontext.SubmitChanges();
            return 1;
        }
        public static void Deletecategory(int categoryID, DasDBDataContext dbcontext)
        {
            var cat = dbcontext.Categories.FirstOrDefault(c => c.CategoryID == categoryID);
            if (cat == null)
            {
                return;
            }

            dbcontext.Categories.DeleteOnSubmit(cat);
            dbcontext.SubmitChanges();
        }
        public static void WriteToDB(DasDBDataContext db, Exception ex)
        {
            try
            {
                var log = new LogEntry();
                log.Date = DateTime.Now.ToLocalTime();
                log.IsError = true;
                log.Message = ex.ToString();

                db.LogEntries.InsertOnSubmit(log);
                db.SubmitChanges();

            }
            catch (Exception)
            {
                throw;
                // Game over
            }
        }
 public static int InsertCategory(
     DasDBDataContext dbcontext,
     string categoryName,
     string categoryDescription,
     string categoryImage,
     string categoryParallax
     )
 {
     var cat = new Category()
     {
         CategoryName = categoryName,
         CategoryDescription = categoryDescription,
         CategoryImage = categoryImage,
         CategoryParallax = categoryParallax
     };
     dbcontext.Categories.InsertOnSubmit(cat);
     dbcontext.SubmitChanges();
     return 1;
 }
        public static int UpdateCategory(
            DasDBDataContext dbcontext,
            int categoryID,
            string categoryName,
            string categoryDescription,
            string categoryImage,
            string categoryParallax
            )
        {
            var cat = dbcontext.Categories.FirstOrDefault(c => c.CategoryID == categoryID);

            if (cat == null)
            {
                return 0;
            }
            cat.CategoryName = categoryName;
            cat.CategoryDescription = categoryDescription;
            cat.CategoryImage = categoryImage;
            cat.CategoryParallax = categoryParallax;

            dbcontext.SubmitChanges();

            return 1;
        }
Exemple #7
0
        public static void DeleteProduct(DasDBDataContext dbcontext, int productID)
        {
            var prod = dbcontext.Products.FirstOrDefault(c => c.ProductID == productID);
            if (prod == null)
            {
                return;
            }
            dbcontext.Products.DeleteOnSubmit(prod);
            dbcontext.SubmitChanges();

        }