예제 #1
0
        public ActionResult Create([Bind(Include = "MaSanPham,MaDMSP,MaKichCo,MaChatLieu,MaThuongHieu,TenSanPham,GiaSanPham,GiaChietKhau,SoLuong,LinkAnh,LinkListAnh,ThongTinSP,NgayCapNhat,SoLuongMua")] SanPham sanPham)
        {
            var    file      = Request.Files[0];
            string _FileName = null;

            if (file.ContentLength > 0)
            {
                _FileName = Path.GetFileName(file.FileName);
                string _path = Path.Combine(Server.MapPath("~/Content/images/"), _FileName);
                file.SaveAs(_path);
            }
            sanPham.LinkAnh = _FileName;

            SanPham Sp = new SanPham();

            Sp = db.SanPhams.SqlQuery("Select * from SanPham where MaSanPham = '" + sanPham.MaSanPham + "'").SingleOrDefault();
            if (Sp != null)
            {
                Sp.SoLuong++;
                db.Database.ExecuteSqlCommand("Update SanPham set SoLuong = " + Sp.SoLuong + "Where MaSanPham='" + sanPham.MaSanPham + "'");
                return(RedirectToAction("Index"));
            }
            if (ModelState.IsValid)
            {
                db.SanPhams.Add(sanPham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaChatLieu   = new SelectList(db.ChatLieux, "MaChatLieu", "TenChatLieu", sanPham.MaChatLieu);
            ViewBag.MaDMSP       = new SelectList(db.DanhMucSanPhams, "MaDMSP", "MaDanhMuc", sanPham.MaDMSP);
            ViewBag.MaKichCo     = new SelectList(db.KichCoes, "MaKichCo", "TenKichCo", sanPham.MaKichCo);
            ViewBag.MaThuongHieu = new SelectList(db.ThuongHieux, "MaThuongHieu", "TenThuongHieu", sanPham.MaThuongHieu);
            return(View(sanPham));
        }
예제 #2
0
        public ActionResult Payment(DonHang model)
        {
            model.ThoiGianTaoDonHang = DateTime.Now;
            try
            {
                db.DonHangs.Add(model);
                db.SaveChanges();
                var cart = (Cart)Session["CartSession"];
                foreach (var item in cart.Lines)
                {
                    ChiTietDonHang obj = new ChiTietDonHang();
                    obj.MaDonHang      = model.MaDonHang;
                    obj.MaSanPham      = item.SanPham.MaSanPham;
                    obj.SoLuongSanPham = item.Quantity;

                    db.ChiTietDonHangs.Add(obj);
                    db.SaveChanges();
                }
                cart.Clear();
                Session["CartSession"] = cart;
            }
            catch (Exception ex)
            {
                //ghi log
                return(RedirectToAction("/Loi"));
            }
            return(View("Complete"));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "MaDanhMuc,TenDanhMuc")] DanhMuc danhMuc)
        {
            if (ModelState.IsValid)
            {
                db.DanhMucs.Add(danhMuc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(danhMuc));
        }
        public ActionResult Create([Bind(Include = "MaTrangThai,TenTrangThai")] TrangThaiDonHang trangThaiDonHang)
        {
            if (ModelState.IsValid)
            {
                db.TrangThaiDonHangs.Add(trangThaiDonHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trangThaiDonHang));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "MaChatLieu,TenChatLieu")] ChatLieu chatLieu)
        {
            if (ModelState.IsValid)
            {
                db.ChatLieux.Add(chatLieu);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(chatLieu);
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "MaKichCo,TenKichCo")] KichCo kichCo)
        {
            if (ModelState.IsValid)
            {
                db.KichCoes.Add(kichCo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kichCo));
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "MaNhanVien,HoTen,TenDangNhap,MatKhau,NgayVaoLam")] NhanVien nhanVien)
        {
            if (ModelState.IsValid)
            {
                db.NhanViens.Add(nhanVien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhanVien));
        }
        public ActionResult Create([Bind(Include = "MaThuongHieu,TenThuongHieu,DiaChi,SoDienThoai")] ThuongHieu thuongHieu)
        {
            if (ModelState.IsValid)
            {
                db.ThuongHieux.Add(thuongHieu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(thuongHieu));
        }
        public ActionResult Create([Bind(Include = "ID,username,pass")] QuanTriVien quanTriVien)
        {
            if (ModelState.IsValid)
            {
                db.QuanTriViens.Add(quanTriVien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quanTriVien));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "MaKhachHang,HoTen,Email,DiaChi,SoDienThoai,TenDangNhap,MatKhau,NgaySinh,GioiTinh,ThoiGianDangKy")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                db.KhachHangs.Add(khachHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khachHang));
        }
예제 #11
0
        public ActionResult Create([Bind(Include = "MaDMSP,MaDanhMuc,TenDMSP")] DanhMucSanPham danhMucSanPham)
        {
            if (ModelState.IsValid)
            {
                db.DanhMucSanPhams.Add(danhMucSanPham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaDanhMuc = new SelectList(db.DanhMucs, "MaDanhMuc", "TenDanhMuc", danhMucSanPham.MaDanhMuc);
            return(View(danhMucSanPham));
        }
        public ActionResult Create([Bind(Include = "SoHieuDonHang,MaDonHang,MaSanPham,SoLuongSanPham,GiaSanPham,GhiChu")] ChiTietDonHang chiTietDonHang)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietDonHangs.Add(chiTietDonHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaDonHang = new SelectList(db.DonHangs, "MaDonHang", "MaNhanVien", chiTietDonHang.MaDonHang);
            ViewBag.MaSanPham = new SelectList(db.SanPhams, "MaSanPham", "MaDMSP", chiTietDonHang.MaSanPham);
            return(View(chiTietDonHang));
        }
예제 #13
0
        public ActionResult Create([Bind(Include = "MaDonHang,MaNhanVien,MaKhachHang,MaTrangThai,TongTien,ThoiGianTaoDonHang,ThoiGianThanhToan,ThoiGianGiaoHang,GhiChu")] DonHang donHang)
        {
            if (ModelState.IsValid)
            {
                db.DonHangs.Add(donHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKhachHang = new SelectList(db.KhachHangs, "MaKhachHang", "HoTen", donHang.MaKhachHang);
            ViewBag.MaNhanVien  = new SelectList(db.NhanViens, "MaNhanVien", "HoTen", donHang.MaNhanVien);
            ViewBag.MaTrangThai = new SelectList(db.TrangThaiDonHangs, "MaTrangThai", "TenTrangThai", donHang.MaTrangThai);
            return(View(donHang));
        }