コード例 #1
0
        public bool ThemChiTietPhieuThue(List <eThongTinPhieuThue> listTtPT, int idPhieuThue)
        {
            foreach (eThongTinPhieuThue item in listTtPT)
            {
                ChiTietPhieuThue ctpt = new ChiTietPhieuThue();
                ctpt.IdChiTietPhieuThue = LayIdChiTietPhieuThueLonNhat() + 1;
                ctpt.IdDia              = item.IdDia;
                ctpt.NgayTraDiaDuKien   = item.NgayTraDiaDuKien;
                ctpt.PhiThue            = item.PhiThue;
                ctpt.NgayTraDiaThucTe   = null;
                ctpt.PhiTre             = item.PhiTreHan;
                ctpt.TrangThaiNoPhiTre  = false;
                ctpt.TrangThaiTraPhiTre = false;
                ctpt.IdPhieuThue        = idPhieuThue;

                db.ChiTietPhieuThues.InsertOnSubmit(ctpt);
                db.SubmitChanges();

                Dia    dia = new Dia();
                TieuDe td  = new TieuDe();
                dia = db.Dias.Where(a => a.IdDia == item.IdDia).SingleOrDefault();
                td  = db.TieuDes.SingleOrDefault(p => p.IdTieuDe == dia.IdTieuDe);

                dia.TrangThaiThue  = "duocthue";
                td.SoLuongDiaCoSan = td.SoLuongDiaCoSan - 1;
                db.SubmitChanges();
            }
            return(true);
        }
コード例 #2
0
        public bool XoaMotKhoanPhiTre(int idChiTiet)
        {
            ChiTietPhieuThue ct = db.ChiTietPhieuThues.SingleOrDefault(p => p.IdChiTietPhieuThue == idChiTiet);

            if (ct == null)
            {
                return(false);
            }
            ct.TrangThaiNoPhiTre = false;
            db.SubmitChanges();
            return(true);
        }
コード例 #3
0
        public bool XacNhanTraDia(eChiTietPhieuThue ectpt)
        {
            ChiTietPhieuThue ctpt = new ChiTietPhieuThue();

            ctpt = db.ChiTietPhieuThues.Where(a => a.IdChiTietPhieuThue == ectpt.IdChiTietPhieuThue).SingleOrDefault();
            if (ctpt != null)
            {
                ctpt.NgayTraDiaThucTe   = ectpt.NgayTraDiaThucTe;
                ctpt.TrangThaiNoPhiTre  = ectpt.TrangThaiNoPhiTre;
                ctpt.TrangThaiTraPhiTre = ectpt.TrangThaiTraPhiTre;

                db.SubmitChanges();
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public List <ChiTietPhieuThue> DanhSachNoPhiTre(string idKhachHang)
        {
            int trangthai = 0;
            List <ChiTietPhieuThue> list = new List <ChiTietPhieuThue>();

            var listtam = (from a in db.KhachHangs
                           join b in db.PhieuThues on a.IdKhachHang equals b.IdKhachHang
                           join c in db.ChiTietPhieuThues on b.IdPhieuThue equals c.IdPhieuThue
                           join d in db.Dias on c.IdDia equals d.IdDia
                           join e in db.TieuDes on d.IdTieuDe equals e.IdTieuDe
                           join f in db.DanhMucs on e.IdDanhMuc equals f.IdDanhMuc
                           where a.IdKhachHang == idKhachHang && c.TrangThaiNoPhiTre == true && c.TrangThaiTraPhiTre == false && c.NgayTraDiaThucTe != null
                           select new
            {
                c.IdChiTietPhieuThue,
                b.NgayTao,
                c.NgayTraDiaDuKien,
                c.NgayTraDiaThucTe,
                d.IdDia,
                f.TenDanhMuc,
                e.TenTieuDe,
                f.PhiTreHan
            });

            foreach (var item in listtam)
            {
                foreach (var itemDB in db.ChiTietPhieuThues)
                {
                    if (item.IdChiTietPhieuThue == itemDB.IdChiTietPhieuThue)
                    {
                        ChiTietPhieuThue ct = new ChiTietPhieuThue();
                        ct = (ChiTietPhieuThue)itemDB;
                        list.Add(ct);
                        trangthai++;
                    }
                }
            }

            if (trangthai == 0)
            {
                return(null);
            }
            return(list);
        }