Example #1
0
        public List <chitietdoanhthu> thongkedoanhthu(int idtour)
        {
            var doandulichs            = db.Find(c => c.idtour == idtour);
            List <chitietdoanhthu> cts = new List <chitietdoanhthu>();

            foreach (doandulich ct in doandulichs)
            {
                chitietdoanhthu ctdt = new chitietdoanhthu();
                ctdt.tendoan = ct.tendoan;
                ctdt.tentour = ct.tour.tentour;
                if (db1.GetQuery().Any(c => c.tungay <= ct.ngaykhoihanh && c.denngay >= ct.ngaykhoihanh && c.idtour == idtour))
                {
                    ctdt.gia = (decimal)db1.GetQuery().OrderByDescending(c => c.id).FirstOrDefault(c => c.tungay <= ct.ngaykhoihanh && c.denngay >= ct.ngaykhoihanh && c.idtour == idtour).gia;
                }
                else
                {
                    ctdt.gia = 0;
                }
                ctdt.soluongkhach = db2.Find(c => c.iddoandulich == ct.id).Count();
                ctdt.tong         = ctdt.gia * ctdt.soluongkhach;
                ctdt.tongchiphi   = tkcpbus.tongchiphi(ct.id);
                ctdt.doanhthu     = ctdt.tong - ctdt.tongchiphi;
            }
            return(cts);
        }