示例#1
0
        public async Task <IActionResult> Edit(string id, [Bind("MsPT,NgayThu,SoTien")] Phieuthu phieuthu)
        {
            if (id != phieuthu.MsPT)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phieuthu);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhieuthuExists(phieuthu.MsPT))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phieuthu));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("MsPT,NgayThu,SoTien")] Phieuthu phieuthu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phieuthu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phieuthu));
        }
示例#3
0
        public async Task <IActionResult> CreateKHPT([Bind("MsKH,MsPT,NgayThu,SoTien")] KhachhangPhieuthu KHPT)
        {
            if (ModelState.IsValid)
            {
                Phieuthu phieuthu = new Phieuthu();
                phieuthu.MsPT    = KHPT.MsPT;
                phieuthu.NgayThu = KHPT.NgayThu;
                phieuthu.SoTien  = KHPT.SoTien;
                var khachhang = await _context.KhachHang
                                .FirstOrDefaultAsync(m => m.MsKH == KHPT.MsKH);

                if (khachhang == null)
                {
                    return(NotFound());
                }
                phieuthu.Khachhang = khachhang;
                _context.Add(phieuthu);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("Details", new RouteValueDictionary(new { controller = "KhachHang", action = "Details", id = KHPT.MsKH })));
        }