public string AddProduct(Product product) { try { garageDBEntities.Products.Add(product); garageDBEntities.SaveChanges(); return(product.Name + " is successfully added"); } catch (Exception) { throw; } }
public string AddPurchase(Purchase purchase) { try { garageDBEntities.Purchases.Add(purchase); garageDBEntities.SaveChanges(); return("The Purchase: " + purchase.DatePurchased + " is successfully added"); } catch (Exception e) { return(e.Message); } }
private void Change() { using (GarageDBEntities db = new GarageDBEntities()) { var sel = DataGrid.SelectedItem as ViewJob; if (sel != null) { var result = db.ViewJob.Where(r => r.id == sel.id).FirstOrDefault(); if (result != null) { result.id = sel.id; db.Entry(result).State = EntityState.Modified; db.SaveChanges(); MessageBox.Show("Запись измнена!"); } else { MessageBox.Show("Нельзя изменть шфир оборудования!"); Load(); return; } } else { MessageBox.Show("Необходимо выбрать строку в таблице!"); return; } } }
public void InsertUserInformation(UserInformation info) { GarageDBEntities db = new GarageDBEntities(); db.UserInformations.Add(info); db.SaveChanges(); }
private void Add() { using (GarageDBEntities db = new GarageDBEntities()) { var sel = DataGrid.SelectedItem as ViewJob; if (sel != null) { var result = db.ViewJob.Where(r => r.id == sel.id).FirstOrDefault(); if (result == null) { db.ViewJob.Add(sel); } else { result.id = sel.id; db.Entry(result).State = EntityState.Added; } db.SaveChanges(); MessageBox.Show("Запись добавлена"); } else { MessageBox.Show("Необходимо выбрать строку в таблице!"); return; } } }
public void updateQuantity(int id, int quantity) { GarageDBEntities db = new GarageDBEntities(); Purchase purchase = db.Purchases.Find(id); purchase.Amount = quantity; db.SaveChanges(); }
public void UpdateQuantity(int id, int quantity) { GarageDBEntities db = new GarageDBEntities(); cart p = db.carts.Find(id); p.Amount = quantity; db.SaveChanges(); }
public void UpdateQuantity(int id, int quantity) { //Update the quantity of the selected product GarageDBEntities db = new GarageDBEntities(); Cart p = db.Carts.Find(id); p.Amount = quantity; db.SaveChanges(); }
public void MarkOrdersAsPaid(List <cart> carts) { GarageDBEntities db = new GarageDBEntities(); if (carts != null) { foreach (cart cart in carts) { cart oldCart = db.carts.Find(cart.ID); oldCart.DatePurchased = DateTime.Now; oldCart.IsInCart = false; } db.SaveChanges(); } }
public string InsertCart(Cart cart) { try { GarageDBEntities db = new GarageDBEntities(); db.Carts.Add(cart); db.SaveChanges(); return("Order was succesfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public void markOrdersAsPaid(List <Purchase> purchases) { GarageDBEntities db = new GarageDBEntities(); if (purchases != null) { foreach (Purchase purchase in purchases) { Purchase oldPurchases = db.Purchases.Find(purchase.ID); oldPurchases.Date = DateTime.Now; oldPurchases.IsInCart = false; } db.SaveChanges(); } }
public string InsertCart(Cart cart) { try { GarageDBEntities db = new GarageDBEntities(); db.Carts.Add(cart); //Will add the carts from the DB db.SaveChanges(); // Save changes to the db entity. return(cart.DatePurchased + "Was successfully Inserted..."); } catch (Exception e) { return("Error :" + e); } }
public void MarkOrdersAsPaid(List <Cart> carts) { //List of cart objects to mark as paid GarageDBEntities db = new GarageDBEntities(); if (carts != null) { foreach (Cart ct in carts) { Cart oldCart = db.Carts.Find(ct.ID); oldCart.DatePurchased = DateTime.Now; oldCart.IsInCart = false; } db.SaveChanges(); } }
public string InsertCart(Cart cart) { try { GarageDBEntities db = new GarageDBEntities(); db.Carts.Add(cart); db.SaveChanges(); return "Order was succesfully inserted"; } catch (Exception e) { return "Error:" + e; } }
public string InsertCart(cart cart) { try { GarageDBEntities db = new GarageDBEntities(); db.carts.Add(cart); db.SaveChanges(); return(cart.DatePurchased + " was successfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public string insertPurchase(Purchase purchase) { try { GarageDBEntities db = new GarageDBEntities(); db.Purchases.Add(purchase); db.SaveChanges(); return(purchase.Date + " was succesfully added to cart"); } catch (Exception e) { return("Error:" + e); } }
public string InsertProduct(Product product) { try { GarageDBEntities db = new GarageDBEntities(); db.Products.Add(product); //Will add the products from the DB db.SaveChanges(); // Save changes to the db entity. return(product.Name + "Was successfully Inserted..."); } catch (Exception e) { return("Error :" + e); } }
public string InsertProductType(ProductType productType) { try { GarageDBEntities db = new GarageDBEntities(); db.ProductTypes.Add(productType); db.SaveChanges(); return(productType.Name + "was succesfully inserted"); } catch (Exception e) { return("Error:" + e); } }
private void Delete() { using (GarageDBEntities db = new GarageDBEntities()) { var s = dg.SelectedItem as Employess; var emS = db.Employess.Where(r => r.Id == s.Id).FirstOrDefault(); var newEmpl = db.NewEmployee.Where(t => t.id == emS.Id).FirstOrDefault(); if (emS != null && newEmpl != null) { db.Entry(newEmpl).State = EntityState.Deleted; db.Entry(emS).State = EntityState.Deleted; db.SaveChanges(); } } }
public string InsertProductType(ProductType productType) { try { GarageDBEntities db = new GarageDBEntities(); db.ProductTypes.Add(productType); db.SaveChanges(); return productType.Name + "was succesfully inserted"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteProduct(int id) // Delete from the primary key value { try { GarageDBEntities db = new GarageDBEntities(); //First to find the objects to be deleted 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 DeleteProductType(int id) { try { GarageDBEntities db = new GarageDBEntities(); ProductType productType = db.ProductTypes.Find(id); db.ProductTypes.Attach(productType); db.ProductTypes.Remove(productType); db.SaveChanges(); return productType.Name + "was succesfully deleted"; } catch (Exception e) { return "Error:" + e; } }
public string deletePurchase(int id) { try { GarageDBEntities db = new GarageDBEntities(); Purchase purchase = db.Purchases.Find(id); db.Purchases.Attach(purchase); db.Purchases.Remove(purchase); db.SaveChanges(); return(purchase.Date + " was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteCart(int id) // Delete from the primary key value { try { GarageDBEntities db = new GarageDBEntities(); //First to find the objects to be deleted Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return(cart.DatePurchased + "was successfully Deleted..."); } catch (Exception e) { return("Error :" + e); } }
public string DeleteCart(int id) { try { GarageDBEntities db = new GarageDBEntities(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return cart.DatePurchased + "was succesfully deleted"; } catch (Exception e) { return "Error:" + e; } }
public string DeleteCart(int id) { try { GarageDBEntities db = new GarageDBEntities(); cart cart = db.carts.Find(id); db.carts.Attach(cart); db.carts.Remove(cart); db.SaveChanges(); return(cart.DatePurchased + " was successfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteProductType(int id) { try { GarageDBEntities db = new GarageDBEntities(); ProductType productType = db.ProductTypes.Find(id); db.ProductTypes.Attach(productType); db.ProductTypes.Remove(productType); db.SaveChanges(); return(productType.Name + "was succesfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProductType(int id, ProductType productType) { try { GarageDBEntities db = new GarageDBEntities(); //Fetch object from db ProductType p = db.ProductTypes.Find(id); p.Name = productType.Name; db.SaveChanges(); return(productType.Name + "was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProductType(int id, ProductType productType) { try { GarageDBEntities db = new GarageDBEntities(); //To fetch productTypes from database ProductType p = db.ProductTypes.Find(id); //find will return the entity with the given primary key values //To replace the data stored in object p by the data given in 'productType'. //We can actually update only the parameters in the 'productTypes' p.Name = productType.Name; db.SaveChanges(); return(productType.Name + "was successfully updated..."); } catch (Exception e) { return("Error :" + e); } }
private void AcceptChange() { using (GarageDBEntities db = new GarageDBEntities()) { var getOrder = dataGistoryOrder.SelectedItem as History; if (getOrder != null) { var seekOrder = db.History.Where(r => r.id == getOrder.id).FirstOrDefault(); seekOrder.Result = true; db.Entry(seekOrder).State = EntityState.Modified; db.SaveChanges(); GetData(); } else { MessageBox.Show("Выберите строку с заказ-нарядом!"); return; } } }
public string UpdateProductType(int id, ProductType productType) { try { GarageDBEntities db = new GarageDBEntities(); //Fetch object from db ProductType p = db.ProductTypes.Find(id); p.Name = productType.Name; db.SaveChanges(); return productType.Name + "was succesfully updated"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateCart(int id, cart cart) { try { GarageDBEntities db = new GarageDBEntities(); cart p = db.carts.Find(id); p.DatePurchased = cart.DatePurchased; p.ClientID = cart.ClientID; p.Amount = cart.Amount; p.IsInCart = cart.IsInCart; p.ProductID = cart.ProductID; db.SaveChanges(); return(cart.DatePurchased + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string updatePurchase(int id, Purchase purchase) { try { GarageDBEntities db = new GarageDBEntities(); Purchase p = db.Purchases.Find(id); p.Date = purchase.Date; p.CustomerID = purchase.CustomerID; p.Amount = purchase.Amount; p.IsInCart = purchase.IsInCart; p.ProductID = purchase.ProductID; db.SaveChanges(); return(purchase.Date + " was succesfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProduct(int id, Product product) { try { GarageDBEntities db = new GarageDBEntities(); Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.TypeId = product.TypeId; p.Description = product.Description; p.Image = product.Image; db.SaveChanges(); return(product.Name + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateCart(int id, Cart cart) { try { GarageDBEntities db = new GarageDBEntities(); //To fetch carts from database Cart p = db.Carts.Find(id); //find will return the entity with the given primary key values //To replace the data stored in object p by the data given in 'cart'. //We can actually update only the parameters in the 'carts' p.DatePurchased = cart.DatePurchased; p.ClientID = cart.ClientID; p.Amount = cart.Amount; p.IsInCart = cart.IsInCart; p.ProductID = cart.ProductID; db.SaveChanges(); return(cart.DatePurchased + "was successfully updated..."); } catch (Exception e) { return("Error :" + e); } }
//mark all the products in the shopping cart as paid //as soon as the user has completed the transaction public void MarkOrdersAsPaid(List<Cart> carts) { GarageDBEntities db = new GarageDBEntities(); if (carts != null) { foreach (Cart cart in carts) { Cart oldCart = db.Carts.Find(cart.id); oldCart.DatePurchased = DateTime.Now; oldCart.IsInCart = false; } db.SaveChanges(); } }
public string UpdateCart(int id, Cart cart) { try { GarageDBEntities db = new GarageDBEntities(); //Fetch object from db Cart p = db.Carts.Find(id); p.DatePurchased = cart.DatePurchased; p.ClientID = cart.ClientID; p.Amount = cart.Amount; p.IsInCart = cart.IsInCart; p.ProductID = cart.ProductID; db.SaveChanges(); return cart.DatePurchased + " was succesfully updated"; } catch (Exception e) { return "Error:" + e; } }
public string UpdateProduct(int id, Product product) { try { GarageDBEntities db = new GarageDBEntities(); //Fetch object from db Product p = db.Products.Find(id); p.Name = product.Name; p.Price = product.Price; p.TypeID = product.TypeID; p.Description = product.Description; p.Image = product.Image; db.SaveChanges(); return product.Name + " was succesfully updated"; } catch (Exception e) { return "Error:" + e; } }
//this method will be called whenever a new user is created public void InsertUserDetail(UserInformation info) { GarageDBEntities db = new GarageDBEntities(); db.UserInformations.Add(info); db.SaveChanges(); }
//update the quantity of a selected product in the shopping cart public void UpdateQuantity(int id, int quantity) { GarageDBEntities db = new GarageDBEntities(); Cart p = db.Carts.Find(id); p.Amount = quantity; db.SaveChanges(); }