Exemplo n.º 1
0
        public async Task <ActionResult> Dathang(FormCollection collection)
        {
            PhieuGiaoHang  pgh = new PhieuGiaoHang();
            NVPhuTrach     nv  = (NVPhuTrach)Session["Taikhoan"];
            List <Giohang> gh  = Laygiohang();

            pgh.SOPG         = pgh.SOPG;
            pgh.NgayLapPhieu = DateTime.Now;
            pgh.TrangThai    = pgh.TrangThai;

            //Thêm chi tiết đơn hàng
            foreach (var item in gh)
            {
                CTPhieuGH ctdh = new CTPhieuGH();
                ctdh.SOPG        = pgh.SOPG;
                ctdh.MSMH        = item.iMSMH;
                ctdh.SoLuongGiao = item.iSoLuong;
                db.PhieuGiaoHangs.Add(pgh);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            await db.SaveChangesAsync();

            Session["Giohang"] = null;
            return(RedirectToAction("Xacnhandonhang", "Giohang"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Dathang(FormCollection collection)
        {
            DonDatHang     pgh = new DonDatHang();
            KhachHang      kh  = (KhachHang)Session["Taikhoan"];
            List <Giohang> gh  = Laygiohang();

            pgh.SoHD       = pgh.SoHD;
            pgh.MSKH       = kh.MSKH;
            pgh.NgayDH     = DateTime.Now;
            pgh.TenNgNhan  = kh.TenKH;
            pgh.DiaChiNhan = kh.DiaChi;
            pgh.SDTNhan    = kh.SDT;

            //Thêm chi tiết đơn hàng
            foreach (var item in gh)
            {
                CTDatHang ctdh = new CTDatHang();
                ctdh.SoHD    = pgh.SoHD;
                ctdh.MSMH    = item.iMSMH;
                ctdh.SoLuong = item.iSoLuong;
                ctdh.DonGia  = item.dDonGia;
                data.DonDatHangs.Add(pgh);
                await data.SaveChangesAsync();

                return(RedirectToAction("Xacnhandonhang"));
            }
            await data.SaveChangesAsync();

            Session["Giohang"] = null;
            return(RedirectToAction("Xacnhandonhang", "Giohang"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "MSLH,TenLoaiHang,HinhAnh")] LoaiHang loaiHang)
        {
            if (ModelState.IsValid)
            {
                db.LoaiHangs.Add(loaiHang);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(loaiHang));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Create([Bind(Include = "MSNV,HoTen,Phai,NamSinh,DiaChi,SDT,TaiKhoan,MatKhau")] NVPhuTrach nVPhuTrach)
        {
            if (ModelState.IsValid)
            {
                db.NVPhuTraches.Add(nVPhuTrach);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(nVPhuTrach));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Create([Bind(Include = "MSMH,MSLH,TenHang,SoLuong,TrangThai,DonGia,HinhAnh,NgayCapNhat")] MatHang matHang)
        {
            ViewBag.MSLH = new SelectList(db.LoaiHangs, "MSLH", "TenLoaiHang", matHang.MSLH);
            if (ModelState.IsValid)
            {
                db.MatHangs.Add(matHang);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(matHang));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Create([Bind(Include = "MSCH,TenCH,MSLH,DiaChi,NvPhuTrach,SDT")] CuaHang cuaHang)
        {
            if (ModelState.IsValid)
            {
                db.CuaHangs.Add(cuaHang);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.MSLH       = new SelectList(db.LoaiHangs, "MSLH", "TenLoaiHang", cuaHang.MSLH);
            ViewBag.NvPhuTrach = new SelectList(db.NVPhuTraches, "MSNV", "HoTen", cuaHang.NvPhuTrach);
            return(View(cuaHang));
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Create([Bind(Include = "SOPG,MSMH,SoLuongGiao,DonGia,ThanhTien")] CTPhieuGH cTPhieuGH)
        {
            if (ModelState.IsValid)
            {
                db.CTPhieuGHs.Add(cTPhieuGH);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.MSMH = new SelectList(db.MatHangs, "MSMH", "TenHang", cTPhieuGH.MSMH);
            ViewBag.SOPG = new SelectList(db.PhieuGiaoHangs, "SOPG", "TrangThai", cTPhieuGH.SOPG);
            return(View(cTPhieuGH));
        }
Exemplo n.º 8
0
 public async Task <ActionResult> MH_Them(MatHang mh, HttpPostedFileBase fileupload)
 {
     ViewBag.MSLH = new SelectList(db.LoaiHangs, "MSLH", "TenLoaiHang", mh.MSLH);
     if (fileupload == null)
     {
         ViewBag.ThongBao = "Vui lòng chọn ảnh";
         return(View());
     }
     else
     {
         if (ModelState.IsValid)
         {
             var fileName = Path.GetFileName(fileupload.FileName);
             var path     = Path.Combine(Server.MapPath("~/HinhAnh/HinhAnh(MatHang)"), fileName);
             if (System.IO.File.Exists(path))
             {
                 ViewBag.ThongBao = "Hình ảnh đã tồn tại";
             }
             else
             {
                 fileupload.SaveAs(path);
             }
             mh.HinhAnh = fileName;
             db.MatHangs.Add(mh);
             await db.SaveChangesAsync();
         }
         return(RedirectToAction("MatHang"));
     }
 }