Beispiel #1
0
        //
        // GET: /Admin/CTHOADON/
        public ActionResult Index()
        {
            var dm = new CTDONHANGFunction.CTDonHangFunction().CTDONHANGs
                     .Where(p => p.ID_CTDH != null);

            return(PartialView(dm));
        }
Beispiel #2
0
 public ActionResult Edit(int id, CTDONHANG model)
 {
     try
     {
         model.ID_CTDH = id;
         var result = new CTDONHANGFunction.CTDonHangFunction().Update(model);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        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"));
        }
Beispiel #4
0
        public ActionResult Edit(int id)
        {
            var model = new CTDONHANGFunction.CTDonHangFunction().FindEntity(id);

            return(View(model));
        }