Beispiel #1
0
        // GET: Admin/SanPham/Edit/5
        public ActionResult Edit(int id)
        {
            var rs = SanPhamBus.ChiTiet(id);
            List <CustomDropDownList> BiXoa = new List <CustomDropDownList>()
            {
                new CustomDropDownList {
                    Text = "Không Xóa", Value = 0
                },
                new CustomDropDownList {
                    Text = "Xóa", Value = 1
                }
            };
            List <CustomDropDownList> TinhTrang = new List <CustomDropDownList>()
            {
                new CustomDropDownList {
                    Text = "Còn Hàng", Value = 1
                },
                new CustomDropDownList {
                    Text = "Hết Hàng", Value = 0
                }
            };

            ViewBag.TinhTrang = new SelectList(TinhTrang, "Value", "Text");
            ViewBag.BiXoa     = new SelectList(BiXoa, "Value", "Text");
            ViewBag.MaHang    = new SelectList(HangBus.DanhSach(), "MaHang", "TenHang", rs.MaHang);
            ViewBag.MaLoai    = new SelectList(LoaiBus.DanhSach(), "MaLoai", "TenLoai", rs.MaLoai);
            return(View(rs));
        }
Beispiel #2
0
        //
        // GET: /Admin/AminProduct/Create
        public ActionResult Create()
        {
            ProductViewModels sp = new ProductViewModels();

            sp.dsLoai1 = LoaiBus.DanhSach();
            return(View(sp));
        }
Beispiel #3
0
        // GET: Admin/SanPham/Create
        public ActionResult Create()
        {
            List <CustomDropDownList> BiXoa = new List <CustomDropDownList>()
            {
                new CustomDropDownList {
                    Text = "Không Xóa", Value = 0
                },
                new CustomDropDownList {
                    Text = "Xóa", Value = 1
                }
            };
            List <CustomDropDownList> TinhTrang = new List <CustomDropDownList>()
            {
                new CustomDropDownList {
                    Text = "Còn Hàng", Value = 1
                },
                new CustomDropDownList {
                    Text = "Hết Hàng", Value = 0
                }
            };

            ViewBag.TinhTrang = new SelectList(TinhTrang, "Value", "Text");
            ViewBag.BiXoa     = new SelectList(BiXoa, "Value", "Text");
            ViewBag.MaHang    = new SelectList(HangBus.DanhSach(), "MaHang", "TenHang");
            ViewBag.MaLoai    = new SelectList(LoaiBus.DanhSach(), "MaLoai", "TenLoai");
            return(View());
        }
        // GET: SanPham/Details/5
        public ActionResult Details(int id)
        {
            var ChiTietSP      = SanPhamBus.ChiTiet(id);
            var ChiTietLoaiSP  = LoaiBus.ChiTietViewModel(ChiTietSP.MaLoai);
            var ChitTietHangSP = HangBus.ChiTietViewModel(ChiTietSP.MaLoai);

            return(View(new SanPhamViewModel()
            {
                LoaiSP = ChiTietLoaiSP, HangSP = ChitTietHangSP, SanPham = ChiTietSP
            }));
        }
Beispiel #5
0
 public ActionResult Edit(int id, LoaiSP LoaiSP)
 {
     try
     {
         // TODO: Add update logic here
         LoaiBus.Sua(LoaiSP);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #6
0
 public ActionResult Create(LoaiSP LoaiSP)
 {
     try
     {
         // TODO: Add insert logic here
         LoaiBus.Them(LoaiSP);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #7
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         LoaiBus.Xoa(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #8
0
 public ActionResult Delete(string id, Loai l)
 {
     try
     {
         // TODO: Add delete logic here
         LoaiBus.Xoa(id, l);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #9
0
        // GET: Admin/LoaiSP/Edit/5
        public ActionResult Edit(int id)
        {
            var rs = LoaiBus.ChiTiet(id);
            List <CustomDropDownList> BiXoa = new List <CustomDropDownList>()
            {
                new CustomDropDownList {
                    Text = "Không Xóa", Value = 0
                },
                new CustomDropDownList {
                    Text = "Xóa", Value = 1
                }
            };

            ViewBag.BiXoa = new SelectList(BiXoa, "Value", "Text");
            return(View(rs));
        }
Beispiel #10
0
        public ActionResult Create(ProductViewModels sp)
        {
            try
            {
                var validImageTypes = new string[]
                {
                    "image/gif",
                    "image/jpeg",
                    "image/pjpeg",
                    "image/png"
                };

                if (sp.ImageUpload == null || sp.ImageUpload.ContentLength == 0)
                {
                    ModelState.AddModelError("ImageUpload", "Chưa chọn hình");
                }
                else if (!validImageTypes.Contains(sp.ImageUpload.ContentType))
                {
                    ModelState.AddModelError("ImageUpload", "Làm ơn chọn file có định dạng hình GIF, JPG, PNG.");
                }

                if (ModelState.IsValid)
                {
                    if (sp.ImageUpload != null && sp.ImageUpload.ContentLength > 0)
                    {
                        var uploadDir = "~/image/product";
                        var imagePath = Path.Combine(Server.MapPath(uploadDir), sp.ImageUpload.FileName);
                        var imageUrl  = Path.Combine(uploadDir, sp.ImageUpload.FileName);
                        sp.ImageUpload.SaveAs(imagePath);
                        sp.Hinh = sp.ImageUpload.FileName;
                    }
                }
                sp.NgayDangSP = DateTime.Now;
                sp.LuotXem    = 0;
                ProductBus.Them(sp);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ProductViewModels spham = new ProductViewModels();
                spham.dsLoai1 = LoaiBus.DanhSach();
                return(View(spham));
            }
        }
Beispiel #11
0
        // GET: Admin/LoaiSP/Delete/5
        public ActionResult Delete(int id)
        {
            var rs = LoaiBus.ChiTiet(id);

            return(View(rs));
        }
Beispiel #12
0
        // GET: Admin/LoaiSP
        public ActionResult Index(int Page = 1)
        {
            var DsLoaiSP = LoaiBus.PageDanhSach(Page, 10);

            return(View(DsLoaiSP));
        }
Beispiel #13
0
 public ActionResult Restore(int id)
 {
     LoaiBus.KhoiPhuc(id);
     return(RedirectToAction("Deleted"));
 }
Beispiel #14
0
        public ActionResult Deleted(int Page = 1)
        {
            var rs = LoaiBus.PageDanhSachDaXoa(Page, 10);

            return(View(rs));
        }
Beispiel #15
0
 //
 // GET: /Loai/Delete/5
 public ActionResult Delete(string id)
 {
     return(View(LoaiBus.ChiTiet(id)));
 }
Beispiel #16
0
 //
 // GET: /Loai/
 public ActionResult Index()
 {
     return(View(LoaiBus.DanhSach()));
 }