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 } }
public TripScreen(int type) { InitializeComponent(); cdList = new ObservableCollection <ChuyenDi>(); switch (type) { case 0: Type = 0; foreach (var trip in cdDao.GetAllChuyenDi()) { cdList.Add(trip); } break; case 1: Type = 1; foreach (var trip in cdDao.GetCurrentTrip()) { cdList.Add(trip); } break; case 2: Type = 2; foreach (var trip in cdDao.GetPassedTrip()) { cdList.Add(trip); } break; default: Type = 0; foreach (var trip in cdDao.GetAllChuyenDi()) { cdList.Add(trip); } break; } this.tripVM = new TripViewModel(cdList); this.DataContext = tripVM; TripListView.ItemsSource = tripVM.TripList; }
public NewTripScreen(int type) { InitializeComponent(); this.type = type; extraExpense = new ObservableCollection <MucChi>(); lbCostList.ItemsSource = extraExpense; milestones = new ObservableCollection <CacMocLoTrinh>(); lbMilestones.ItemsSource = milestones; members = new ObservableCollection <ThanhVien>(); thanhVien_TienThu = new ObservableCollection <ThanhVien_TienThu>(); lbMembers.ItemsSource = thanhVien_TienThu; images = new ObservableCollection <HinhAnhChuyenDi>(); imagesTemp = new ObservableCollection <HinhAnhChuyenDi>(); lbImages.ItemsSource = imagesTemp; trip_memberList = new ObservableCollection <CHUYENDI_THANHVIEN>(); maChuyenDi = (chuyenDiDAOImpl.GetAllChuyenDi().Count() + 1).ToString(); }