Пример #1
0
        public ActionResult Payment(string shipName, string mobile, string address, string email)
        {
            var order = new HOADON();

            order.NgayHD    = DateTime.Now;
            order.DiaChi    = address;
            order.DienThoai = mobile;
            order.Hoten     = shipName;
            order.EMail     = email;

            try
            {
                var id = new HOADONF().Insert(order);

                var cart = (Cart)Session[CartSession];

                var     detailDao = new CHITIETHDF();
                decimal total     = 0;
                foreach (var item in cart.Lines)
                {
                    var orderDetail = new CHITIETHD();
                    orderDetail.MaSP    = item.Sanpham.MaSP;
                    orderDetail.MaHD    = id;
                    orderDetail.DonGia  = item.Sanpham.GiaSP;
                    orderDetail.SoLuong = item.Quantity;

                    detailDao.Insert(orderDetail);

                    total += (item.Sanpham.GiaSP.GetValueOrDefault(0) * item.Quantity);
                }
            }
            catch (Exception ex)
            {
                //ghi log
                return(RedirectToAction("/Loi"));
            }
            return(RedirectToAction("Index", "SanPham"));
        }
Пример #2
0
        public ActionResult Index(string name, string phone)
        {
            var order = new HoaDon();

            order.NgayGhiHD     = DateTime.Now;
            order.SoDienThoaiKH = phone;
            order.TenKH         = name;

            try
            {
                var id = new HOADONF().Insert(order);

                var cart = (Cart)Session["CartSession"];

                var detailDao = new CHITIETHDF();

                foreach (var item in cart.Lines)
                {
                    var orderDetail = new CTHD();
                    orderDetail.MaGT    = item.Goitap.MaGT.ToString().Trim();
                    orderDetail.MaHD    = id;
                    orderDetail.DonGia  = item.Goitap.GiaGT;
                    orderDetail.SoLuong = item.Quantity;

                    detailDao.Insert(orderDetail);
                }
            }
            catch (Exception ex)
            {
                //ghi log

                throw;
            }
            Session["CartSession"] = null;
            return(RedirectToAction("Index", "Package"));
        }