コード例 #1
0
        public static void CreateRequisition(List <Cart> carts, long empId)
        {
            List <long> reqs = RequisitionDAO.GetAllRequisitions();
            Employee    emp  = new Employee();

            emp.EmpId = empId;
            Requisition req = new Requisition();
            long        arg = reqs.Count == 0 ? 0 : reqs.Max();

            req.ReqCode       = string.Format(String.Format("#R{0:0000000000}", arg + 1));
            req.DateOfRequest = DateTime.Now;
            req.Status        = "Pending Approval";
            req.Employee      = emp;
            long reqId = RequisitionDAO.SaveRequisition(req);

            req.ReqId = reqId;
            List <RequisitionDetails> reqDetailsList = new List <RequisitionDetails>();
            Inventory item = null;

            foreach (Cart c in carts)
            {
                item        = new Inventory();
                item.ItemId = c.Item.ItemId;
                RequisitionDetails reqDetail = new RequisitionDetails();
                reqDetail.Requisition = req;
                reqDetail.Item        = item;
                reqDetail.Quantity    = c.Quantity;
                reqDetail.Balance     = c.Quantity;
                reqDetailsList.Add(reqDetail);
            }
            RequisitionDetailsDAO.SaveRequisitionDetails(reqDetailsList);
            CartDAO.DeleteCarts(empId);
        }
コード例 #2
0
    private void checkInventory()
    {
        DataTable dt = CartDAO.getCartDT(Session.SessionID);
        List <Dictionary <string, string> > errorList = new List <Dictionary <string, string> >();

        if (!CommonUtil.DT.isEmptyOrNull(dt))
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                int inventory = AjaxService.getInventory(dt.Rows[i]["SKU"] + "");
                if (inventory == 0)
                {
                    dic.Add("sku", dt.Rows[i]["SKU"] + "");
                    dic.Add("error", "Oops!! Sorry, Items is Sold Out");
                }
                else if (inventory < Int32.Parse(dt.Rows[i]["QTY"] + ""))
                {
                    string msg = "Only " + inventory + " Item(s) are left in inventory!!";
                    dic.Add("sku", dt.Rows[i]["SKU"] + "");
                    dic.Add("error", msg);
                }
                if (dic.Count > 0)
                {
                    errorList.Add(dic);
                }
            }
        }
        sendResponse(errorList);
    }
コード例 #3
0
        public static List <Cart> GetCartsByEmpId(long empId)
        {
            List <Cart> carts = CartDAO.GetCartsByEmpId(empId);

            carts = GetCartsWithObjects(carts);
            return(carts);
        }
コード例 #4
0
        public CartPO Map(CartDAO cartToMap)
        {
            // Create an instance of the object
            CartPO cartToView = new CartPO();

            // map the values
            cartToView.checkOutID         = cartToMap.checkOutID;
            cartToView.supplierID         = cartToMap.supplierID;
            cartToView.supplierName       = cartToMap.supplierName;
            cartToView.productDescription = cartToMap.productDescription;
            cartToView.productPrice       = cartToMap.productPrice;
            cartToView.checkOutQuantity   = cartToMap.checkOutQuantity;
            cartToView.checkOutTax        = cartToMap.checkOutTax;
            cartToView.checkOutShipping   = cartToMap.checkOutShipping;
            cartToView.checkOutTotal      = cartToMap.checkOutTotal;
            cartToView.checkOutDate       = cartToMap.checkOutDate;
            cartToView.userTableID        = cartToMap.userTableID;
            cartToView.productID          = cartToMap.productID;
            cartToView.userTransactionID  = cartToMap.userTransactionID;
            cartToView.datePurchase       = cartToMap.datePurchase;
            cartToView.productQuantity    = cartToMap.productQuantity;

            // return the values
            return(cartToView);
        }
コード例 #5
0
 public ActionResult ProfileView()
 {
     try
     {
         if (Session["Id"] != null)
         {
             UserDAO     dao    = new UserDAO();
             User        u      = dao.SearchById(int.Parse(Session["Id"].ToString()));
             CountryDAO  cdao   = new CountryDAO();
             LanguageDAO ldao   = new LanguageDAO();
             CartDAO     cardao = new CartDAO();
             if (Session["Id"] != null)
             {
                 ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             }
             ViewBag.User        = u;
             ViewBag.Country     = cdao.List();
             ViewBag.Lang        = ldao.List();
             ViewBag.UserCountry = cdao.SearchById(u.CountryId);
             return(View());
         }
         return(RedirectToAction("../Home/Index"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #6
0
        public ActionResult Wishlist()
        {
            try
            {
                if (Session["Id"] != null)
                {
                    WishlistDAO    wdao = new WishlistDAO();
                    ApplicationDAO adao = new ApplicationDAO();
                    CartDAO        cdao = new CartDAO();

                    int UserId = int.Parse(Session["Id"].ToString());

                    IList <Wishlist>    wishs = wdao.GetUserList(UserId);
                    IList <Application> apps  = new List <Application>();
                    foreach (var w in wishs)
                    {
                        apps.Add(adao.SearchById(w.ApplicationId));
                    }

                    ViewBag.Cart     = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
                    ViewBag.WishApps = wishs;
                    ViewBag.Apps     = apps;
                    return(View());
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #7
0
 public ActionResult SearchByGenre(int id)
 {
     try
     {
         ApplicationDAO           dao   = new ApplicationDAO();
         ApplicationGenreDAO      agdao = new ApplicationGenreDAO();
         IList <ApplicationGenre> agens = agdao.ListByGenre(id);
         IList <Application>      apps  = new List <Application>();
         CartDAO cdao = new CartDAO();
         if (Session["Id"] != null)
         {
             ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
         }
         foreach (var ag in agens)
         {
             apps.Add(dao.SearchById(ag.ApplicationId));
         }
         ViewBag.Apps = apps;
         return(View("Search"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #8
0
 public ActionResult Explore(string type)
 {
     try
     {
         ApplicationDAO dao  = new ApplicationDAO();
         CartDAO        cdao = new CartDAO();
         if (Session["Id"] != null)
         {
             ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
         }
         if (type.Equals("Featured"))
         {
             ViewBag.Apps = dao.GetTopApps();
         }
         else if (type.Equals("Explore"))
         {
             ViewBag.Apps = dao.List();
         }
         else if (type.Equals("Free"))
         {
             ViewBag.Apps = dao.GetFreeApps();
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
         return(View("Search"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #9
0
 public ActionResult Product(int id)
 {
     try
     {
         ApplicationDAO dao   = new ApplicationDAO();
         DeveloperDAO   ddao  = new DeveloperDAO();
         ImageDAO       idao  = new ImageDAO();
         UserDAO        udao  = new UserDAO();
         SellItemDAO    sidao = new SellItemDAO();
         Application    app   = dao.SearchById(id);
         Developer      dev   = ddao.SearchById(app.DeveloperId);
         CartDAO        cdao  = new CartDAO();
         PegiDAO        pdao  = new PegiDAO();
         ViewBag.SellItem = false;
         if (Session["Id"] != null)
         {
             ViewBag.Cart     = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             ViewBag.SellItem = sidao.SearchUserApp(int.Parse(Session["Id"].ToString()), id);
             WishlistDAO wdao = new WishlistDAO();
             ViewBag.IsInWish = wdao.IsInWishList(int.Parse(Session["Id"].ToString()), id);
         }
         ViewBag.App     = app;
         ViewBag.Dev     = dev;
         ViewBag.Pegi    = pdao.SearchById(app.PegiId);
         ViewBag.DevUser = udao.SearchByDev(dev.Id);
         ViewBag.Img     = idao.SearchAppImages(id);
         ViewBag.Similar = dao.ListLast10();
         return(View());
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
コード例 #10
0
        public int UpdateCartQuantity()
        {
            CartDAO dao    = new CartDAO();
            int     result = dao.Update(this);

            return(result);
        }
コード例 #11
0
 public bool deleteCart(CartDAO cartToDelete)
 {
     {
         bool yes = false;
         try
         {
             //This is creating a connection to the database
             using (SqlConnection _connection = new SqlConnection(connectionString))
             {
                 //This specifies what type of command
                 using (SqlCommand _command = new SqlCommand("SP_Cart_Delete", _connection))
                 {
                     //This specifies what type of command is being used
                     _command.CommandType = CommandType.StoredProcedure;
                     //Here is where the Values will be passed to the command
                     _command.Parameters.AddWithValue("@CartID", cartToDelete.CartID);
                     //Here is where the connection is opened
                     _connection.Open();
                     //This will excute the command
                     _command.ExecuteNonQuery();
                     yes = true;
                     _connection.Close();
                 }
             }
         }
         catch (Exception error)
         {
             Error_Logger Log = new Error_Logger();
             Log.Errorlogger(error);
         }
         return(yes);
     }
 }
コード例 #12
0
        public int DeleteItem()
        {
            CartDAO dao    = new CartDAO();
            int     result = dao.Delete(this);

            return(result);
        }
コード例 #13
0
        public static void SaveToCart(long itemId, long empId, int quantity)
        {
            Cart     cart = new Cart();
            Employee emp  = new Employee();

            emp.EmpId = empId;
            Inventory item = new Inventory();

            item.ItemId   = itemId;
            cart.Employee = emp;
            cart.Item     = item;
            cart.Quantity = quantity;
            List <Cart> carts = CartDAO.GetAllCart();

            carts = GetCartsWithObjects(carts);
            Cart checkCart = carts.Find(c => c.Employee.EmpId == cart.Employee.EmpId && c.Item.ItemId == cart.Item.ItemId);

            if (null != checkCart)
            {
                cart.Quantity = cart.Quantity + checkCart.Quantity;
                CartDAO.UpdateCart(cart);
            }
            else
            {
                CartDAO.SaveCart(cart);
            }
        }
コード例 #14
0
 public ActionResult Checkout()
 {
     try
     {
         CartDAO      cardao = new CartDAO();
         IList <Cart> cart   = cardao.GetUserCart(int.Parse(Session["Id"].ToString()));
         if (Session["Id"] != null && cart.Count() != 0)
         {
             UserDAO    udao = new UserDAO();
             CountryDAO cdao = new CountryDAO();
             User       u    = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.User        = u;
             ViewBag.CountryUser = cdao.SearchById(u.CountryId);
             ViewBag.Cart        = cardao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             ViewBag.FullCart    = cart;
             return(View());
         }
         else
         {
             return(RedirectToAction("../Home/Index"));
         }
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
コード例 #15
0
        public int AddCart()
        {
            CartDAO dao    = new CartDAO();
            int     result = dao.Insert(this);

            return(result);
        }
コード例 #16
0
 public ActionResult Index()
 {
     try
     {
         ApplicationDAO      appdao        = new ApplicationDAO();
         UpdateNotesDAO      updao         = new UpdateNotesDAO();
         CartDAO             cdao          = new CartDAO();
         IList <Application> apps          = appdao.ListLast10();
         IList <Application> bapps         = appdao.ListTop10();
         IList <UpdateNotes> updates       = updao.GetLast3();
         IList <Application> appsinupdates = new List <Application>();
         foreach (var u in updates)
         {
             if (u.Value.Length > 144)
             {
                 u.Value = u.Value.Substring(0, 144);
             }
             appsinupdates.Add(appdao.SearchById(u.ApplicationId));
         }
         if (Session["Id"] != null)
         {
             ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
         }
         ViewBag.Updates       = updates;
         ViewBag.AppsinUpdates = appsinupdates;
         ViewBag.BApps         = bapps;
         ViewBag.NApps         = apps;
         return(View());
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
コード例 #17
0
        public ActionResult CheckProductCart(string idProduct)
        {
            User user = Session["User"] as User;

            if (user != null)
            {
                string  status = "success";
                DBModel db     = new DBModel();
                var     cart   = db.carts.Where(x => x.ID_ACCOUNT.Equals(user.ID_ACCOUNT) && x.ID_PRODUCT.Equals(idProduct)).FirstOrDefault();
                if (cart.CHECKBOX == 1)
                {
                    cart.CHECKBOX = 0;
                    db.SaveChanges();
                }
                else
                {
                    cart.CHECKBOX = 1;
                    db.SaveChanges();
                }
                string price = CartDAO.TotalMoney(user.ID_ACCOUNT, true);
                return(new JsonResult {
                    Data = new { status = status, price = price }
                });
            }
            else
            {
                return(new JsonResult {
                    Data = new { url = Url.Action("Index", "Home") }
                });
            }
        }
コード例 #18
0
        public ActionResult DeleteProductInCart(string idProduct)
        {
            User user = Session["User"] as User;

            if (user != null)
            {
                string  status = "success";
                DBModel db     = new DBModel();
                var     cart   = db.carts.Where(x => x.ID_ACCOUNT.Equals(user.ID_ACCOUNT) && x.ID_PRODUCT.Equals(idProduct)).FirstOrDefault();
                db.carts.Remove(cart);
                db.SaveChanges();
                int    number           = CartDAO.NumberOfProduct(user.ID_ACCOUNT);
                string totalMoneyHeader = CartDAO.TotalMoney(user.ID_ACCOUNT, false);
                string totalMoneyCart   = CartDAO.TotalMoney(user.ID_ACCOUNT, true);
                return(new JsonResult {
                    Data = new { status = status, number = number, totalMoneyHeader = totalMoneyHeader, totalMoneyCart = totalMoneyCart }
                });
            }
            else
            {
                return(new JsonResult {
                    Data = new { url = Url.Action("Index", "Home") }
                });
            }
        }
コード例 #19
0
        public ActionResult CheckAllProductCart(string number)
        {
            User user = Session["User"] as User;

            if (user != null)
            {
                string  status = "success";
                DBModel db     = new DBModel();

                var tmp = db.carts.Where(x => x.ID_ACCOUNT.Equals(user.ID_ACCOUNT));
                foreach (cart cart in tmp)
                {
                    cart.CHECKBOX = (short?)int.Parse(number);
                }
                db.SaveChanges();
                string price = CartDAO.TotalMoney(user.ID_ACCOUNT, true);
                return(new JsonResult {
                    Data = new { status = status, price = price }
                });
            }
            else
            {
                return(new JsonResult {
                    Data = new { url = Url.Action("Index", "Home") }
                });
            }
        }
コード例 #20
0
        public ActionResult ChangeAmountProductInCart(string idProduct, string amount)
        {
            User user = Session["User"] as User;

            if (user != null)
            {
                string  status = "success";
                DBModel db     = new DBModel();
                var     cart   = db.carts.Where(x => x.ID_ACCOUNT.Equals(user.ID_ACCOUNT) && x.ID_PRODUCT.Equals(idProduct)).FirstOrDefault();
                cart.AMOUNT = (decimal?)int.Parse(amount);
                db.SaveChanges();
                int    number           = CartDAO.NumberOfProduct(user.ID_ACCOUNT);
                string totalMoneyHeader = CartDAO.TotalMoney(user.ID_ACCOUNT, false);
                string totalMoneyCart   = CartDAO.TotalMoney(user.ID_ACCOUNT, true);
                string moneyProduct     = Tools.StringToVND(CartDAO.TotalMoneyOfProduct(user.ID_ACCOUNT, idProduct).ToString());
                return(new JsonResult {
                    Data = new { status = status, number = number, totalMoneyHeader = totalMoneyHeader, totalMoneyCart = totalMoneyCart, moneyProduct = moneyProduct }
                });
            }
            else
            {
                return(new JsonResult {
                    Data = new { url = Url.Action("Index", "Home") }
                });
            }
        }
コード例 #21
0
        public ActionResult ProfileView()
        {
            try
            {
                if (Session["DevId"] != null)
                {
                    DeveloperDAO   dao    = new DeveloperDAO();
                    ApplicationDAO appdao = new ApplicationDAO();
                    UserDAO        udao   = new UserDAO();
                    CountryDAO     cdao   = new CountryDAO();
                    Developer      dev    = dao.SearchById(int.Parse(Session["DevId"].ToString()));
                    User           u      = udao.SearchById(int.Parse(Session["Id"].ToString()));

                    CartDAO cardao = new CartDAO();
                    if (Session["Id"] != null)
                    {
                        ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString()));
                    }

                    ViewBag.DevGames    = appdao.GetDevGames(dev.Id);
                    ViewBag.Dev         = dev;
                    ViewBag.User        = u;
                    ViewBag.CountryUser = cdao.SearchById(u.CountryId);
                    return(View());
                }
                else
                {
                    return(RedirectToAction("../Home/Index"));
                }
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #22
0
        public ActionResult Header()
        {
            User user        = Session["User"] as User;
            var  nameProduct = SearchDAO.loadNameProduct();

            if (user != null)
            {
                var       cart = CartDAO.LoadCart(user.ID_ACCOUNT);
                var       numberOfProductsInTheCart = CartDAO.NumberOfProduct(user.ID_ACCOUNT);
                var       totalMoney     = CartDAO.TotalMoney(user.ID_ACCOUNT, false);
                var       numberUserLike = new LikeDAO().getNumberUserLike(user.ID_ACCOUNT);
                ArrayList model          = new ArrayList();
                model.Add(cart);
                model.Add(numberOfProductsInTheCart);
                model.Add(totalMoney);
                model.Add(numberUserLike);
                model.Add(nameProduct);
                return(PartialView(model));
            }
            else
            {
                ArrayList model = new ArrayList();
                model.Add(nameProduct);
                return(PartialView(model));
            }
        }
コード例 #23
0
        public List <CartDAO> Map(List <CartPO> cartListToMap)
        {
            // instaniate a new list of type userPO
            List <CartDAO> cartListToReturn = new List <CartDAO>();

            // create a foreach loop to loop throught the list
            foreach (CartPO cartToMap in cartListToMap)
            {
                CartDAO cartToView = new CartDAO();

                // map the values
                cartToView.checkOutID         = cartToMap.checkOutID;
                cartToView.supplierID         = cartToMap.supplierID;
                cartToView.supplierName       = cartToMap.supplierName;
                cartToView.productDescription = cartToMap.productDescription;
                cartToView.productPrice       = cartToMap.productPrice;
                cartToView.checkOutQuantity   = cartToMap.checkOutQuantity;
                cartToView.checkOutTax        = cartToMap.checkOutTax;
                cartToView.checkOutShipping   = cartToMap.checkOutShipping;
                cartToView.checkOutTotal      = cartToMap.checkOutTotal;
                cartToView.checkOutDate       = cartToMap.checkOutDate;
                cartToView.userTableID        = cartToMap.userTableID;
                cartToView.productID          = cartToMap.productID;
                cartToView.userTransactionID  = cartToMap.userTransactionID;
                cartToView.datePurchase       = cartToMap.datePurchase;
                cartToView.productQuantity    = cartToMap.productQuantity;
                cartListToReturn.Add(cartToView);
            }
            // return the list
            return(cartListToReturn);
        }
コード例 #24
0
 public ActionResult IsCartEmpty()
 {
     if (!Authentication.IsValid())
     {
         return(Json(new { Error = "Not Authenticated" }));
     }
     return(Json(new { isEmpty = CartDAO.IsCartEmpty() }));
 }
コード例 #25
0
 private void updateSessionIdInTable()
 {
     CartDAO.updateCart(Session[Constant.Session.LOGED_IN_USER_ID] + "", Session.SessionID);
     FavDAO.updateFavList(Session[Constant.Session.LOGED_IN_USER_ID] + "", Session.SessionID);
     Session.Remove(Constant.Session.CART_ITEMS);
     Session.Remove(Constant.Session.FAV_LIST);
     Session.Remove(Constant.Session.TOTAL);
 }
コード例 #26
0
        public BaseResponse <Cart> Update(Cart obj)
        {
            bool result = new CartDAO().Update(obj);
            var  status = result ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <Cart> response = new BaseResponse <Cart>(status, "", null);

            return(response);
        }
コード例 #27
0
        public BaseResponse <Cart> Delete(string userName, int productID)
        {
            bool result = new CartDAO().Delete(userName, productID);
            var  status = result ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <Cart> response = new BaseResponse <Cart>(status, "", null);

            return(response);
        }
コード例 #28
0
        public BaseResponse <Cart> Add(Cart cart)
        {
            bool result = new CartDAO().AddProduct(cart);
            var  status = result ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <Cart> response = new BaseResponse <Cart>(status, "", null);

            return(response);
        }
コード例 #29
0
 public Exception AddToCart(string productID, string description)
 {
     if (CartDAO.FindByProductID(productID) == null)
     {
         return(CartDAO.Insert(productID, 1, description) ? null : new Exception("Have something wrong!"));
     }
     return(CartDAO.UpdateQuantity(productID) ? null : new Exception("Have something wrong!"));
 }
コード例 #30
0
        public List <CartDAO> ViewTransactions(int userTableID)
        {
            // create a new instance of productDOA that is a list
            List <CartDAO> itemList = new List <CartDAO>();

            // create try catch to catch any possible errors
            try
            {
                // create a using statment to use the connection string
                using (SqlConnection _Connection = new SqlConnection(connectionString))
                {
                    // create using statment to specify the stored procedure
                    using (SqlCommand _Command = new SqlCommand("sp_UserTransactionViewAllTransactions ", _Connection))
                    {
                        // specify the command is a stored procedure
                        _Command.CommandType = System.Data.CommandType.StoredProcedure;
                        _Command.Parameters.AddWithValue("@userTableID", userTableID);
                        // open the connection
                        _Connection.Open();

                        // create a using statement using the reader to reader through the list
                        using (SqlDataReader _Reader = _Command.ExecuteReader())
                        {
                            // create a while loop to read throught the whole record
                            while (_Reader.Read())
                            {
                                CartDAO itemToList = new CartDAO();
                                itemToList.userTransactionID  = Convert.ToInt32(_Reader["userTransactionID"]);
                                itemToList.datePurchase       = Convert.ToDateTime(_Reader["datePurchase"]);
                                itemToList.userTableID        = Convert.ToInt32(_Reader["userTableID"]);
                                itemToList.productID          = Convert.ToInt32(_Reader["productID"]);
                                itemToList.checkOutID         = Convert.ToInt32(_Reader["checkOutID"]);
                                itemToList.supplierID         = Convert.ToInt32(_Reader["supplierID"]);
                                itemToList.supplierName       = (String)_Reader["supplierName"];
                                itemToList.productDescription = (String)_Reader["productDescription"];
                                itemToList.productPrice       = Convert.ToDecimal(_Reader["productPrice"]);
                                itemToList.checkOutQuantity   = Convert.ToInt32(_Reader["checkOutQuantity"]);
                                itemToList.checkOutShipping   = 10.00M;
                                //itemToList.checkOutTotal = Convert.ToDecimal(_Reader["checkOutTotal"]);
                                itemList.Add(itemToList);
                            }
                        }
                        //close the connection
                        _Connection.Close();
                        //DeleteCart(userTableID);
                    }
                }
            }

            //pass the error message
            catch (Exception error)
            {
                // call the error method and pass the error
                ErrorMessage.logger(error);
            }
            // return the list
            return(itemList);
        }