Exemplo n.º 1
0
        // GET: Admin/ChiTietDatHang
        public ActionResult Index(int?searchStr, int page = 1, int pageSize = 8)
        {
            var ls = new ChiTietDatHangDao().GetByStr(searchStr, page, pageSize);

            ViewBag.searchStr = searchStr;
            return(View(ls));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Thanh toán
        /// </summary>
        /// <returns></returns>
        public ActionResult Checkout()
        {
            if (Session[CommonContants.USER_SESSION] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var lsCart = (List <WebBanQuanAo.Models.CartModel>)Session[CommonContants.CART_SESSION];

            if (lsCart == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                var us = (UserLogin)Session[CommonContants.USER_SESSION];

                var DDHdao     = new DonDatHangDao();
                var dondathang = new DONDATHANG();
                dondathang.makhachhang = us.UserID;
                dondathang.noigiaohang = new KhachHangDao().ViewDetail(us.UserID).diachi;
                dondathang.ngaydathang = DateTime.Now;

                int res = new DonDatHangDao().Insert(dondathang);

                var CTHDdao = new ChiTietDatHangDao();
                foreach (var item in lsCart)
                {
                    var ctdh = new CHITIETDATHANG()
                    {
                        sohoadon = res, mahang = item.SanPham.ma, giaban = (double)item.SanPham.giaban, soluong = item.SoLuong
                    };
                    if (!CTHDdao.Insert(ctdh))
                    {
                        ModelState.AddModelError("", "Lõi hệ thống");
                        //break;
                    }
                }
                Session[CommonContants.CART_SESSION]       = null;
                Session[CommonContants.COUNT_CART_SESSION] = 0;

                return(Redirect("/hoan-thanh"));
            }
            catch (Exception)
            {
                return(Redirect("/loi"));
            }
        }
Exemplo n.º 3
0
        public ActionResult Details(int id)
        {
            var ls = new ChiTietDatHangDao().GetByCatagory(id);

            return(View(ls));
        }