Пример #1
0
        public async Task HuyPhieuNhap(object editModel)
        {
            try
            {
                PhieuNhap editPhieuNhap = (PhieuNhap)editModel;
                editPhieuNhap.TrangThai = false;
                await _phieuNhapRepo.EditAsync(editPhieuNhap);

                var phieuNhapKho = dbContext.ChiTietPhieuNhapes.Where(x => x.SoPhieuNhap == editPhieuNhap.SoPhieuNhap);

                foreach (var i in phieuNhapKho)
                {
                    _hangHoaBus.CapNhapHangHoaVaoBaoCaoTonKhiHuyPhieuNhap(i.MaHangHoa, i.SoLuong, editPhieuNhap.NgayNhap.Month, editPhieuNhap.NgayNhap.Year);
                    _hangHoaBus.CapNhatHangHoaKhiXoaPhieuNhap(i.SoPhieuNhap, i.MaHangHoa, i.SoLuong, i.GiaNhap);
                }
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
        public async Task HuyPhieuNhapKho(object editModel)
        {
            try
            {
                PhieuNhap editPhieuNhapKho = (PhieuNhap)editModel;
                editPhieuNhapKho.TrangThai = false;
                await _phieuNhapKhoRepo.EditAsync(editPhieuNhapKho);

                var phieuNhapKho = dbContext.ChiTietPhieuNhaps.Where(x => x.SoPhieuNhap == editPhieuNhapKho.SoPhieuNhap);
                int thang        = dbContext.PhieuNhaps.SingleOrDefault(x => x.SoPhieuNhap == editPhieuNhapKho.SoPhieuNhap).NgayNhap.Month;
                int nam          = dbContext.PhieuNhaps.SingleOrDefault(x => x.SoPhieuNhap == editPhieuNhapKho.SoPhieuNhap).NgayNhap.Year;

                foreach (var i in phieuNhapKho)
                {
                    _hangHoaBus.CapNhatHangHoaKhiXoaPhieuNhap(i.SoPhieuNhap, i.MaHangHoa, i.SoLuong, i.GiaNhap);
                    _hangHoaBus.CapNhatHangHoaVaoBaoCaoTonKhoKhiXoaPhieuNhap(i.MaHangHoa, i.SoLuong, thang, nam);
                }
            }
            catch (Exception)
            {
            }
        }