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; }
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 List<OrderRow> GetAllOrderRows(DasDBDataContext dbcontext) { var item2 = dbcontext.OrderHeads.Max(a => a.OrderHeadID); return dbcontext.OrderRows .Where(a => a.OrderHeadID == item2) .Select(a => a).ToList(); }
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(); }
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; }
public void GetAllCategories(DasDBDataContext dbcontext) { var categories = Master.db.Categories.Select(a => new { dropdownID = a.CategoryID, dropdownName = a.CategoryName }); ProductCrudDDL.DataValueField = "dropdownID"; ProductCrudDDL.DataTextField = "dropdownName"; ProductCrudDDL.DataSource = categories; ProductCrudDDL.DataBind(); ProductCrudDDL.SelectedValue = ProductCrudDDL.SelectedItem.Value; }
public List<OrderRow> GetAllOrderRows(DasDBDataContext dbcontext) { return dbcontext.OrderRows .Where(a => a.OrderHeadID == TheOrderID) .Select(a => a).ToList(); }
public static List<Product> GetProductsWithoutCategories(DasDBDataContext dbcontext) { return dbcontext.Products.Where(a => a.ProductRelCategories.Count() == 0).ToList(); }
public static List<ProductRelCategory> GetAllProducts(DasDBDataContext dbcontext) { return dbcontext.ProductRelCategories.OrderByDescending(a => a.ProductID).Select(a => a).ToList(); }
public Repository() { db = new DasDBDataContext(); }
public static List<ProductRelCategory> GetAllProducts(DasDBDataContext dbcontext) { return dbcontext.ProductRelCategories.Select(a => a).ToList(); }
public static List<Category> GetAllCategories(DasDBDataContext dbcontext) { return dbcontext.Categories.Select(a => a).ToList(); }
public static List<OrderHead> GetAllOrders(DasDBDataContext dbcontext) { return db.OrderHeads.OrderByDescending(a => a.OrderDate).Select(a => a).ToList(); }