public TripDetailScreen(int type, string maChuyenDi) { ObservableCollection <MucChi> mc = new ObservableCollection <MucChi>(); MucChiDAOlmpl mcDao = new MucChiDAOlmpl(); InitializeComponent(); this.type = type; this.maChuyenDi = maChuyenDi; tripDetailVM = new TripDetailVM(maChuyenDi); this.DataContext = tripDetailVM; PlaceListView.ItemsSource = tripDetailVM.loTrinhList; ImageListView.ItemsSource = tripDetailVM.hinhAnhList; ThanhVienListView.ItemsSource = tripDetailVM.thanhVienList; TongKetListView.ItemsSource = tripDetailVM.tongKet.ThanhVienTraLai; foreach (MucChi m in tripDetailVM.mucChiList) { PieSeries ps = new PieSeries() { Title = m.NDChi, Values = new ChartValues <int> { m.SoTien }, DataLabels = true }; myChart.Series.Add(ps); } myChart.FontSize = 12; myChart.Foreground = new SolidColorBrush(Colors.DimGray); }
public TripDetailVM(string maChuyenDi) { ChuyenDiDAOImpl cdDao = new ChuyenDiDAOImpl(); chuyenDi = cdDao.getChuyenDiById(maChuyenDi); MucChiDAOlmpl mcDao = new MucChiDAOlmpl(); mucChiList = mcDao.GetMucChiByTripId(maChuyenDi); hinhAnhList = new ObservableCollection <HinhAnhChuyenDi>(); hinhAnhList.Add(new HinhAnhChuyenDi() { HinhAnh = chuyenDi.AnhBia }); HinhAnhChuyenDiDAOlmpl haDao = new HinhAnhChuyenDiDAOlmpl(); List <HinhAnhChuyenDi> haList = haDao.GetAllHinhAnhChuyenDi(); tongKet = new TongKet(); int sum = 0; foreach (var mc in mucChiList) { sum += mc.SoTien; } tongKet.Tong = sum; foreach (var ha in haList) { if (ha.MaChuyenDi == maChuyenDi) { hinhAnhList.Add(ha); } } thanhVienList = new ObservableCollection <ThanhVien>(); ChuyenDiThanhVienDAOImpl tvDao = new ChuyenDiThanhVienDAOImpl(); List <CHUYENDI_THANHVIEN> cdtvList = tvDao.GetCHUYENDI_THANHVIENList(); tvThamGiaList = new List <CHUYENDI_THANHVIEN>(); ThanhVienDAOlmpl memDao = new ThanhVienDAOlmpl(); foreach (var tv in cdtvList) { if (tv.MaChuyenDi == maChuyenDi) { tvThamGiaList.Add(tv); ThanhVien tmp = memDao.GetMemberById(tv.MaThanhVien); thanhVienList.Add(tmp); } } int count = 0; foreach (var tv in thanhVienList) { count++; } tongKet.TrungBinh = tongKet.Tong / count; //Tien tra lai cua cac thanh vien ThanhVienDAOlmpl thanhVienDao = new ThanhVienDAOlmpl(); foreach (var tvtg in tvThamGiaList) { ThanhVien tmp = thanhVienDao.GetMemberById(tvtg.MaThanhVien); ThanhVien_TraLai tvtl = new ThanhVien_TraLai(); tvtl.TenThanhVien = tmp.TenThanhVien; tvtl.SoTien = tvtg.TienThu - tongKet.TrungBinh; tongKet.ThanhVienTraLai.Add(tvtl); } loTrinhList = new ObservableCollection <CacMocLoTrinh>(); CacMocLoTrinhDAOlmpl ltDao = new CacMocLoTrinhDAOlmpl(); List <CacMocLoTrinh> ltList = ltDao.GetAllCacMocLoTrinh(); foreach (var lt in ltList) { if (lt.MaChuyenDi == maChuyenDi) { loTrinhList.Add(lt); } } }