示例#1
0
        // Ham xoa loai san pham


        public ActionResult Xoa(int id)
        {
            LoaiSanPhamContext loaiSanPhamContext = new LoaiSanPhamContext();

            loaiSanPhamContext.DeleteLoaiSanPham(id);
            return(RedirectToAction("Danhsach"));
        }
示例#2
0
        public ActionResult Sua_Get(int id)
        {
            LoaiSanPhamContext loaiSanPhamContext = new LoaiSanPhamContext();
            LoaiSanPham        loaisanpham        = loaiSanPhamContext.LoaiSanPham.Single(lsp => lsp.MaLoaiSP == id);

            return(View(loaisanpham));
        }
示例#3
0
        public ActionResult DanhSach()
        {
            LoaiSanPhamContext loaisanphamContext = new LoaiSanPhamContext();
            List <LoaiSanPham> loaiSanPham        = loaisanphamContext.LoaiSanPham.ToList();

            //LoaiSanPham loaiSanPham = loaisanphamContext.LoaiSanPham.Single(lsp => lsp.MaLoaiSanPham == MaLoaiSanPham);
            return(View(loaiSanPham));
        }
示例#4
0
        public ActionResult Sua_Post(int id)
        {
            LoaiSanPhamContext loaiSanPhamContext = new LoaiSanPhamContext();
            LoaiSanPham        loaisanpham        = loaiSanPhamContext.LoaiSanPham.Single(x => x.MaLoaiSP == id);

            UpdateModel(loaisanpham, new string[] { "TenLoaiSP", "PhanTramLoiNhuan", "MaDVT" });
            if (ModelState.IsValid)
            {
                loaiSanPhamContext.SaveLoaiSanPham(loaisanpham);
                return(RedirectToAction("Danhsach"));
            }
            return(View(loaisanpham));
        }
示例#5
0
        public ActionResult Tao_Post(LoaiSanPham loaisanpham)
        {
            //LoaiSanPham loaisanpham = new LoaiSanPham();
            //loaisanpham.TenLoaiSP = formCollection["TenLoaiSP"];
            //loaisanpham.PhanTramLoiNhuan = Int32.Parse(formCollection["PhanTramLoiNhuan"]);
            //loaisanpham.MaDVT = Int32.Parse(formCollection["MaDVT"]);

            if (ModelState.IsValid)
            {
                LoaiSanPhamContext loaiSanPhamContext = new LoaiSanPhamContext();
                loaiSanPhamContext.AddLoaiSanPham(loaisanpham);
                RedirectToAction("Danhsach");
            }
            return(View());
        }