Exemplo n.º 1
0
        public ActionResult DatHang(FormCollection collection)
        {
            tblTran        ddh = new tblTran();
            tblUser        kh  = (tblUser)Session["Taikhoan"];
            List <Giohang> lgh = Laygiohang();

            ddh.user_id = kh.usersID;
            ddh.created = DateTime.Now;
            var ngaygiao = String.Format("{0:MM/dd/yyyy}", collection["Ngaygiao"]);

            ddh.delivery_date = DateTime.Parse(ngaygiao);
            ddh.amount        = Decimal.Parse(collection["tien"]);
            ddh.payment       = " ";
            ddh.payment_info  = " ";
            ddh.note          = collection["Ghichu"].ToString();
            ddh.security      = " ";
            ddh.status        = " ";
            data.tblTrans.InsertOnSubmit(ddh);
            data.SubmitChanges();

            foreach (var item in lgh)
            {
                tblOrder cthd = new tblOrder();
                cthd.Trans_id   = ddh.id;
                cthd.product_id = item.MaSP;
                cthd.number     = item.SoLuong;
                cthd.amount     = (decimal)item.DonGia;
                cthd.status     = " ";
                data.tblOrders.InsertOnSubmit(cthd);
            }
            data.SubmitChanges();
            Session["GioHang"] = null;
            return(RedirectToAction("XacnhanDH", "GioHang"));
        }
Exemplo n.º 2
0
        public ActionResult XNLuuT(int id, FormCollection col)
        {
            tblTran tr = data.tblTrans.SingleOrDefault(n => n.id == id);

            if (ModelState.IsValid)
            {
                UpdateModel(tr);
                data.SubmitChanges();
            }
            return(RedirectToAction("Trans"));
        }
Exemplo n.º 3
0
        public ActionResult EditTrans(int id)
        {
            tblTran tr = data.tblTrans.SingleOrDefault(n => n.id == id);

            if (tr == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(tr));
        }
Exemplo n.º 4
0
        public ActionResult XNXoaT(int id)
        {
            tblTran tr = data.tblTrans.SingleOrDefault(n => n.id == id);

            if (tr == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.tblTrans.DeleteOnSubmit(tr);

            data.SubmitChanges();
            return(RedirectToAction("Trans"));
        }