예제 #1
0
        public async Task <IActionResult> Create([Bind("MaSp,TenSp,DonTinh,DonGia")] SanPham sanPham)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sanPham);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sanPham));
        }
        public async Task <IActionResult> Create([Bind("MaNv,HoTenNv,GioiTinh,NgaySinh,DiaChi,DienThoai")] Nhanvien nhanvien)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nhanvien);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nhanvien));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("MaKh,HoTenKh,DiachiKh,DienThoai")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                _context.Add(khachHang);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(khachHang));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("MaHd,MaKh,MaNv,NgayLapHd,NganNhanHang")] HoaDon hoaDon)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hoaDon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaKh"] = new SelectList(_context.KhachHang, "MaKh", "MaKh", hoaDon.MaKh);
            ViewData["MaNv"] = new SelectList(_context.Nhanvien, "MaNv", "MaNv", hoaDon.MaNv);
            return(View(hoaDon));
        }
        public async Task <IActionResult> Create([Bind("MaHd,MaSp,SoLuong,IdchitietHd")] ChiTietHd chiTietHd)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chiTietHd);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaHd"] = new SelectList(_context.HoaDon, "MaHd", "MaKh", chiTietHd.MaHd);
            ViewData["MaSp"] = new SelectList(_context.SanPham, "MaSp", "MaSp", chiTietHd.MaSp);
            return(View(chiTietHd));
        }