Ejemplo n.º 1
0
    //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();
    }
Ejemplo n.º 2
0
    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;
        }
    }
Ejemplo n.º 3
0
    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);
        }
    }
Ejemplo n.º 4
0
    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;
        }
    }
Ejemplo n.º 5
0
    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;
        }
    }
Ejemplo n.º 6
0
    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;
        }
    }
Ejemplo n.º 7
0
    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);
        }
    }
Ejemplo n.º 8
0
    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);
        }
    }
Ejemplo n.º 9
0
    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);
        }
    }
Ejemplo n.º 10
0
    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;
        }
    }
Ejemplo n.º 11
0
    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);
        }
    }
Ejemplo n.º 12
0
    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);
        }
    }
Ejemplo n.º 13
0
	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;
        }
    }
Ejemplo n.º 14
0
    //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();
    }
Ejemplo n.º 15
0
    //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!");
    }
Ejemplo n.º 16
0
    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);
        }
    }
Ejemplo n.º 17
0
    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;
        }
    }
Ejemplo n.º 18
0
    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);
        }
    }
Ejemplo n.º 19
0
    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;
        }
    }
Ejemplo n.º 20
0
    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;
        }
    }
Ejemplo n.º 21
0
    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);
        }
    }
Ejemplo n.º 22
0
    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;
        }
    }
Ejemplo n.º 23
0
    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;
        }
    }
Ejemplo n.º 24
0
    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);
        }
    }
Ejemplo n.º 25
0
    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;
        }
    }
Ejemplo n.º 26
0
    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);
        }
    }
Ejemplo n.º 27
0
    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);
        }
    }
Ejemplo n.º 28
0
    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;
        }
    }
Ejemplo n.º 29
0
    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);
        }
    }
Ejemplo n.º 30
0
    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;
        }
    }
Ejemplo n.º 31
0
    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;
        }
    }
Ejemplo n.º 32
0
    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);
        }
    }
Ejemplo n.º 33
0
    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;
        }
    }
Ejemplo n.º 34
0
    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);
        }
    }
Ejemplo n.º 35
0
    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);
        }
    }
Ejemplo n.º 36
0
    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);
        }
    }
Ejemplo n.º 37
0
    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;
        }
    }
Ejemplo n.º 38
0
    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;
        }
    }
Ejemplo n.º 39
0
    //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();
    }
Ejemplo n.º 40
0
    //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!";
    }
Ejemplo n.º 41
0
    //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();
    }