private void RefreshcbBuses() { CitiRepository cityRep = new CitiRepository(); RefreshBindingSourse(); dtpDepartureDate.MinDate = DateTime.Now; dtpArrivalDate.MinDate = DateTime.Now; dtpFinalDateFlight.MinDate = DateTime.Now; cbCityStart.DisplayMember = "CityName"; cbCityStart.ValueMember = "CityId"; cbCityStart.DataSource = cityRep.GetAll(); cbCityEnd.DisplayMember = "CityName"; cbCityEnd.ValueMember = "CityId"; cbCityEnd.DataSource = cityRep.GetAll(); BusRepository busRep = new BusRepository(); FlightRepository flightRep = new FlightRepository(); var busybus = flightRep.GetAll().Select(p => p.BusId).ToList(); int count = 0; var tempBuses = busRep.GetAll(); while (count < busybus.Count) { tempBuses = tempBuses.Where(p => p.BusId != busybus[count]).ToList(); count++; } cbBuses.DisplayMember = "BusName"; cbBuses.ValueMember = "BusId"; cbBuses.DataSource = tempBuses; }
private void Tickets_Load(object sender, EventArgs e) { BusinessFlightsRepository bfr = new BusinessFlightsRepository(); var MaxDate = bfr.GetAll(DateTime.Now.Date).Max(p => p.DepartureDate); RefreshBindingSourse(); cbCityStart.DataSource = Citir.GetAll().Select(p => p.CityName).ToList(); cbCityEnd.DataSource = Citir.GetAll().Select(p => p.CityName).ToList(); cbDiscount.DisplayMember = "DiscountName"; cbDiscount.ValueMember = "DiscountId"; cbDiscount.DataSource = Discountr.GetAll(); dtpDepartureDate.MinDate = DateTime.Now; dtpDepartureDate.MaxDate = MaxDate; }