//Update qty from shopping cart page public void UpdateQuantity(int id, int quantity) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Cart cart = db.Carts.Find(id); cart.Quantity = quantity; //Save changes to database db.SaveChanges(); }
public string InsertCategory(Category category) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Categories.Add(category); db.SaveChanges(); return category.Name + " was successfully inserted!"; } catch (Exception e) { return "Error:" + e; } }
public string InsertSupplier(Supplier supplier) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Suppliers.Add(supplier); db.SaveChanges(); return(supplier.Name + " was successfully inserted!"); } catch (Exception e) { return("Error:" + e); } }
public string InsertSupplier(Supplier supplier) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Suppliers.Add(supplier); db.SaveChanges(); return supplier.Name + " was successfully inserted!"; } catch (Exception e) { return "Error:" + e; } }
public string InsertCart(Cart cart) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Carts.Add(cart); db.SaveChanges(); return cart.DataPurchased + " was successfully inserted!"; } catch (Exception e) { return "Error:" + e; } }
public string InsertOrder(Order order) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Orders.Add(order); db.SaveChanges(); return order.ID.ToString(); } catch (Exception e) { return "Error:" + e; } }
public string InsertProduct(Product product) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Products.Add(product); db.SaveChanges(); return(product.Name + " was successfully inserted!"); } catch (Exception e) { return("Error:" + e); } }
public string InsertCart(Cart cart) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Carts.Add(cart); db.SaveChanges(); return(cart.DataPurchased + " was successfully inserted!"); } catch (Exception e) { return("Error:" + e); } }
public string InsertOrder(Order order) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Orders.Add(order); db.SaveChanges(); return(order.ID.ToString()); } catch (Exception e) { return("Error:" + e); } }
public string InsertClient(Client client) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Clients.Add(client); db.SaveChanges(); return client.Name + " was successfully inserted!"; } catch (Exception e) { return "Error:" + e; } }
public string InsertClient(Client client) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Clients.Add(client); db.SaveChanges(); return(client.Name + " was successfully inserted!"); } catch (Exception e) { return("Error:" + e); } }
public string InsertCategory(Category category) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Categories.Add(category); db.SaveChanges(); return(category.Name + " was successfully inserted!"); } catch (Exception e) { return("Error:" + e); } }
public string InsertProduct(Product product) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); db.Products.Add(product); db.SaveChanges(); return product.Name + " was successfully inserted!"; } catch (Exception e) { return "Error:" + e; } }
//Mark all the added products as paid, after checkout public void MarkOrderAsPaid(List <Cart> carts) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); if (carts != null) { foreach (Cart cart in carts) { Cart oldCart = db.Carts.Find(cart.ID); oldCart.DataPurchased = DateTime.Now; oldCart.IsInCart = false; } } db.SaveChanges(); }
//Update qty of same product from singleProduct page public string UpdateQty(int productId, int quantity, int clientId) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); var cart = (from x in db.Carts where x.ProductID == productId && x.IsInCart && x.ClientID == clientId select x).FirstOrDefault(); int oldQuantity = cart.Quantity; int newQuantity = oldQuantity + quantity; cart.Quantity = newQuantity; db.SaveChanges(); return("Update Successfully!"); }
public string DeleteProduct(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Product product = db.Products.Find(id); db.Products.Attach(product); db.Products.Remove(product); db.SaveChanges(); return(product.Name + " was successfully deleted!"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteOrder(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Order order = db.Orders.Find(id); db.Orders.Attach(order); db.Orders.Remove(order); db.SaveChanges(); return order.ID + " was successfully delected!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteClient(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Client client = db.Clients.Find(id); db.Clients.Attach(client); db.Clients.Remove(client); db.SaveChanges(); return(client.Name + " was successfully deleted!"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteProduct(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Product product = db.Products.Find(id); db.Products.Attach(product); db.Products.Remove(product); db.SaveChanges(); return product.Name + " was successfully deleted!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteCategory(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Category category = db.Categories.Find(id); db.Categories.Attach(category); db.Categories.Remove(category); db.SaveChanges(); return category.Name + " was successfully deleted!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteSupplier(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Supplier supplier = db.Suppliers.Find(id); db.Suppliers.Attach(supplier); db.Suppliers.Remove(supplier); db.SaveChanges(); return(supplier.Name + " was successfully delected!"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteSupplier(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Supplier supplier = db.Suppliers.Find(id); db.Suppliers.Attach(supplier); db.Suppliers.Remove(supplier); db.SaveChanges(); return supplier.Name + " was successfully delected!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteCart(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return cart.DataPurchased + " was successfully deleted!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteCategory(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Category category = db.Categories.Find(id); db.Categories.Attach(category); db.Categories.Remove(category); db.SaveChanges(); return(category.Name + " was successfully deleted!"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteClient(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Client client = db.Clients.Find(id); db.Clients.Attach(client); db.Clients.Remove(client); db.SaveChanges(); return client.Name + " was successfully deleted!"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteCart(int id) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return(cart.DataPurchased + " was successfully deleted!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCategory(int id, Category category) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Category p = db.Categories.Find(id); p.Name = category.Name; p.Description = category.Description; db.SaveChanges(); return(category.Name + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCategory(int id, Category category) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Category p = db.Categories.Find(id); p.Name = category.Name; p.Description = category.Description; db.SaveChanges(); return category.Name + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateSupplier(int id, Supplier supplier) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Supplier p = db.Suppliers.Find(id); p.Name = supplier.Name; p.PhoneNumber = supplier.PhoneNumber; p.EmailAddress = supplier.EmailAddress; db.SaveChanges(); return(supplier.Name + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateSupplier(int id, Supplier supplier) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Supplier p = db.Suppliers.Find(id); p.Name = supplier.Name; p.PhoneNumber = supplier.PhoneNumber; p.EmailAddress = supplier.EmailAddress; db.SaveChanges(); return supplier.Name + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateOrder(int id, Order order) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Order p = db.Orders.Find(id); p.ClientID = order.ClientID; p.Status = order.Status; p.TotalAmount = order.TotalAmount; p.OrderDate = order.OrderDate; db.SaveChanges(); return order.ID + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateOrder(int id, Order order) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Order p = db.Orders.Find(id); p.ClientID = order.ClientID; p.Status = order.Status; p.TotalAmount = order.TotalAmount; p.OrderDate = order.OrderDate; db.SaveChanges(); return(order.ID + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateClient(int id, Client client) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Client p = db.Clients.Find(id); p.Name = client.Name; p.Password = client.Password; p.PhoneNumber = client.PhoneNumber; p.EmailAddress = client.EmailAddress; p.HomeAddress = client.HomeAddress; db.SaveChanges(); return client.Name + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateClient(int id, Client client) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Client p = db.Clients.Find(id); p.Name = client.Name; p.Password = client.Password; p.PhoneNumber = client.PhoneNumber; p.EmailAddress = client.EmailAddress; p.HomeAddress = client.HomeAddress; db.SaveChanges(); return(client.Name + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProduct(int id, Product product) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.CategoryID = product.CategoryID; p.Description = product.Description; p.SupplierID = product.SupplierID; p.Image = product.Image; p.Color = product.Color; db.SaveChanges(); return(product.Name + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCart(int id, Cart cart) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Cart p = db.Carts.Find(id); p.ClientID = cart.ClientID; p.ProductID = cart.ProductID; p.Status = cart.Status; p.TotalCost = cart.TotalCost; p.IsInCart = cart.IsInCart; p.DataPurchased = cart.DataPurchased; db.SaveChanges(); return(cart.DataPurchased + " was successfully updated!"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProduct(int id, Product product) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.CategoryID = product.CategoryID; p.Description = product.Description; p.SupplierID = product.SupplierID; p.Image = product.Image; p.Color = product.Color; db.SaveChanges(); return product.Name + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateCart(int id, Cart cart) { try { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); //Fetch object from db Cart p = db.Carts.Find(id); p.ClientID = cart.ClientID; p.ProductID = cart.ProductID; p.Status = cart.Status; p.TotalCost = cart.TotalCost; p.IsInCart = cart.IsInCart; p.DataPurchased = cart.DataPurchased; db.SaveChanges(); return cart.DataPurchased + " was successfully updated!"; } catch (Exception e) { return "Error:" + e; } }
//Update qty from shopping cart page public void UpdateQuantity (int id, int quantity) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); Cart cart = db.Carts.Find(id); cart.Quantity = quantity; //Save changes to database db.SaveChanges(); }
//Update qty of same product from singleProduct page public string UpdateQty (int productId, int quantity, int clientId) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); var cart = (from x in db.Carts where x.ProductID == productId && x.IsInCart && x.ClientID == clientId select x).FirstOrDefault(); int oldQuantity = cart.Quantity; int newQuantity = oldQuantity + quantity; cart.Quantity = newQuantity; db.SaveChanges(); return "Update Successfully!"; }
//Mark all the added products as paid, after checkout public void MarkOrderAsPaid(List<Cart> carts) { ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities(); if(carts != null) { foreach(Cart cart in carts) { Cart oldCart = db.Carts.Find(cart.ID); oldCart.DataPurchased = DateTime.Now; oldCart.IsInCart = false; } } db.SaveChanges(); }