Example #1
0
        public static void incrementTotalSales(int id)
        {
            List <ShoeTable> data          = ShoeRepository.getShoeData();
            ShoeTable        incrementShoe = data.Where(y => y.ShoeId == id).SingleOrDefault();

            incrementShoe.TotalSales += 1;
            DBSingleton.getDB().SaveChanges();
        }
        protected void DeleteBtn_Click(object sender, EventArgs e)
        {
            int       deleteID = Int32.Parse(delShoeID.Text);
            ShoeTable delShoe  = ShoeHandler.findShoeByID(deleteID);

            ShoeRepository.deleteShoe(delShoe);
            loadData();
        }
 public static int checkStock(int id)
 {
     ShoeTable shoe = ShoeHandler.findShoeByID(id);
     if (shoe != null)
     {
         return shoe.ShoeStock;
     }
     return -1;
 }
Example #4
0
        //Update
        public static void updateShoe(int id, string updateName, int updatePrice, int updateStock, string updateImage)
        {
            ShoeTable updateShoe = DBSingleton.getDB().ShoeTable.Where(y => y.ShoeId == id).SingleOrDefault();

            updateShoe.ShoeName  = updateName;
            updateShoe.ShoeStock = updateStock;
            updateShoe.ShoePrice = updatePrice;
            updateShoe.ShoeImage = updateImage;
            DBSingleton.getDB().SaveChanges();
        }
 public static bool updateStockAfterCheckout(int qty, int id)
 {
     if (qty > 0)
     {
         ShoeTable shoe = ShoeHandler.findShoeByID(id);
         int stockNow = shoe.ShoeStock - qty;
         updateStock(stockNow, id);
         return true;
     }
     return false;
 }
 public static bool updateStock(int stock, int id)
 {
     if (stock > 0)
     {
         ShoeTable shoe = ShoeHandler.findShoeByID(id);
         ShoeRepository.updateShoe(shoe.ShoeId, shoe.ShoeName, shoe.ShoePrice, stock, shoe.ShoeImage);
         return true;
     }
     else
     {
         return false;
     }
 }
 public static bool addProduct(string shoeName, string price, string stock, string shoeImage)
 {
     if (shoeName != "" && checkPrice(price) && checkStock(stock))
     {
         int shoePrice = Int32.Parse(price);
         int shoeStock = Int32.Parse(stock);
         ShoeTable newShoe = ShoeFactory.createShoe(shoeName, shoePrice, shoeStock, shoeImage);
         ShoeRepository.insertShoe(newShoe);
         return true;
     }
     else
     {
         //Label_Error.Text = "Please Check the Data!";
         return false;
     }
 }
        public void loadData()
        {
            int             userID = Int32.Parse(Session["UserID"].ToString());
            List <UserCart> cart   = CartHandler.findCartByUserID(userID);

            cartDGV.DataSource = cart;
            cartDGV.DataBind();

            List <ShoeTable> shoeCart = new List <ShoeTable>();

            foreach (UserCart x in cart)
            {
                ShoeTable shoeTemp = ShoeHandler.findShoeByID(x.ShoeId);
                shoeCart.Add(shoeTemp);
            }

            productCart.DataSource = shoeCart;
            productCart.DataBind();


            shoeDGV.DataSource = ShoeRepository.getShoeData();
            shoeDGV.DataBind();
        }
Example #9
0
 //CRUD
 //Read
 public static List <ShoeTable> getShoeData()
 {
     try
     {
         List <ShoeTable> data = DBSingleton.getDB().ShoeTable.ToList();
         return(data);
     }
     catch
     {
         ShoeTable b = new ShoeTable()
         {
             ShoeId     = 0,
             ShoeImage  = "Error.jpg",
             ShoeName   = "Error",
             ShoePrice  = 0,
             ShoeStock  = 0,
             TotalSales = 0
         };
         List <ShoeTable> errorData = new List <ShoeTable>();
         errorData.Add(b);
         return(errorData);
     }
 }
Example #10
0
 public static void insertShoe(ShoeTable newShoe)
 {
     DBSingleton.getDB().ShoeTable.Add(newShoe); //lamda exprestion
     DBSingleton.getDB().SaveChanges();
 }
Example #11
0
 //Delete
 public static void deleteShoe(ShoeTable delShoe)
 {
     DBSingleton.getDB().ShoeTable.Remove(delShoe);
     DBSingleton.getDB().SaveChanges();
 }