Exemplo n.º 1
0
        private void loadUI()
        {
            String db            = "QLChuyenDi";
            String con           = $"Server=localhost; Database= master; Trusted_Connection=True;";
            bool   isHasDatabase = DatabaseHelper.isDatabaseExists(con, db);

            if (!isHasDatabase)
            {
                return;
            }

            ChuyenDiDAOImpl chuyenDiDAOImpl = new ChuyenDiDAOImpl();

            if (chuyenDiDAOImpl.GetAllChuyenDi().Count() > 0)
            {
                Random random = new Random();
                int    index  = random.Next(chuyenDiDAOImpl.GetAllChuyenDi().Count());

                ChuyenDi trip = chuyenDiDAOImpl.GetAllChuyenDi()[index];
                txtTripTittle.Text      = trip.TenChuyenDi;
                txtTripDescription.Text = trip.MoTa;

                HinhAnhChuyenDiDAOlmpl hinhAnhChuyenDiDAOlmpl = new HinhAnhChuyenDiDAOlmpl();
                HinhAnhChuyenDi        tripImage = hinhAnhChuyenDiDAOlmpl.getTripImageByTripCode(trip.MaChuyenDi);

                if (tripImage == null || tripImage.HinhAnh == null || tripImage.HinhAnh == "")
                {
                    Uri uri = new Uri("../Assets/Images/default_trip_image.jpg", UriKind.RelativeOrAbsolute);
                    imgTrip.Source = new BitmapImage(uri);
                }
                else
                {
                    Uri uri = new Uri(tripImage.HinhAnh, UriKind.RelativeOrAbsolute);
                    try
                    {
                        imgTrip.Source = new BitmapImage(uri);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else
            {
                //do nothing. use default screen in xml
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }