Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var model = new DONHANGFunction.DonHangFunction().FindEntity(id);

            ViewBag.CTHD = new CTDONHANGFunction.CTDonHangFunction().CTDONHANGs.Where(x => x.ID_DH == id);
            return(View(model));
        }
Ejemplo n.º 2
0
        //
        // GET: /Admin/DONHANG/
        public ActionResult Index()
        {
            var dh = new DONHANGFunction.DonHangFunction().DONHANGs
                     .Where(p => p.ID_DH != null).OrderBy(x => x.trangthai);

            return(PartialView(dh));
        }
Ejemplo n.º 3
0
        public ActionResult SoDonHang()
        {
            var dh = new DONHANGFunction.DonHangFunction().DONHANGs
                     .Where(p => p.trangthai == null).OrderBy(x => x.trangthai).ToList();

            ViewBag.SoDH = dh.Count();
            return(PartialView(dh));
        }
Ejemplo n.º 4
0
        public ActionResult CTDonHangUser(int id)
        {
            var model = new DONHANGFunction.DonHangFunction().FindEntity(id);

            ViewBag.CTHD = new CTDONHANGFunction.CTDonHangFunction().CTDONHANGs.Where(x => x.ID_DH == id);
            return(View(model));
            //var model = new SANPHAMFunction().ChiTietDonHangDangNhap();
            //var query = model.OrderByDescending(p => p.ID_DH);
            //return View(query.ToList());
        }
Ejemplo n.º 5
0
        public ActionResult Delete(int id, DONHANG model)
        {
            try
            {
                model.ID_DH = id;
                var result = new DONHANGFunction.DonHangFunction().Delete(model);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 6
0
 public ActionResult Edit(int id, DONHANG model)
 {
     try
     {
         model.ID_DH = id;
         var result = new DONHANGFunction.DonHangFunction().Update(model);
         //if (result == null)
         //{
         //    return View();
         //}
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 7
0
        public ActionResult InHoaDon(int id)
        {
            var dathang = new DONHANGFunction.DonHangFunction().tblCTDonHang(id);

            return(View(dathang));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(int id)
        {
            var model = new DONHANGFunction.DonHangFunction().FindEntity(id);

            return(View(model));
        }
        public ActionResult Payment(string name, string mobileadd, string diachiadd, string dateout)
        {
            // A
            var order = new DONHANG();

            order.ngaylap        = DateTime.Now;
            order.hotenkh        = name;
            order.diachigiaohang = diachiadd;
            order.phone          = mobileadd;
            DateTime?date = null;
            DateTime temp;

            if (DateTime.TryParse(dateout, out temp))
            {
                if (temp != null)
                {
                    date = temp;
                }
            }

            if (date != null)
            {
                order.ngaynhanhang = date.Value;
            }

            // B

            //nếu login
            if (SessionPersister.UserName != null)
            {
                order.ngaynhanhang = DateTime.Now;
                order.ID_TK        = SessionPersister.UserName.ID_TK;

                var account = new TAIKHOANFunction.TaiKhoanFunction().FindEntity(order.ID_TK.Value);
                order.hotenkh        = account.tentk;
                order.diachigiaohang = account.diachi;
                order.phone          = account.phone;
            }
            try
            {
                var id = new DONHANGFunction.DonHangFunction().Insert(order);

                var cart      = (Cart)Session["CartSession"];
                var detailDao = new CTDONHANGFunction.CTDonHangFunction();
                foreach (var item in cart.Lines)
                {
                    var orderDetail = new CTDONHANG();
                    orderDetail.ID_SP   = item.Sanpham.ID_SP;
                    orderDetail.ID_DH   = id;
                    orderDetail.soluong = item.Quantity;
                    orderDetail.dongia  = (item.Sanpham.giabd * item.Quantity);
                    detailDao.Insert(orderDetail);
                }

                Session["CartSession"] = null;
            }
            catch (Exception ex)
            {
                //ghi log
                return(RedirectToAction("Loi")); // action Loi ở đâu?
            }

            return(RedirectToAction("MuaHangThanhCong", "Cart"));
        }