Exemplo n.º 1
0
        private void cbCityStart_SelectedIndexChanged(object sender, EventArgs e)
        {
            bBuyTicket.Enabled     = false;
            bReserveTicket.Enabled = false;
            cbSeats.DataSource     = null;

            BusinessFlightsRepository bfr = new BusinessFlightsRepository();
            var MaxDate = bfr.GetAll(DateTime.Now.Date).Where(p => p.CityStart == Convert.ToString(cbCityStart.SelectedValue)).Max(p => p.DepartureDate);
            var MinDate = bfr.GetAll(DateTime.Now.Date).Where(p => p.CityStart == Convert.ToString(cbCityStart.SelectedValue)).Min(p => p.DepartureDate);

            dtpDepartureDate.MinDate = MinDate;
            dtpDepartureDate.MaxDate = MaxDate;
            dtpDepartureDate.Value   = dtpDepartureDate.MinDate;

            cbCityEnd.DataSource = bfr.GetAll().Where(p => p.CityStart == Convert.ToString(cbCityStart.SelectedValue)).Select(p => p.CityEnd).Distinct().ToList();
            if (Convert.ToString(cbCityStart.SelectedValue) == "")
            {
                cbCityEnd.DataSource = bfr.GetAll().Select(p => p.CityEnd).Distinct().ToList();
            }

            RefreshBindingSourse(cbCityStart.SelectedValue, cbCityEnd.SelectedValue, dtpDepartureDate.Value.Date);
            if (binSourceBusStation.Count == 0)
            {
                cbSeats.DataSource = null;
            }
        }
Exemplo n.º 2
0
        private void MetodClearOldDataBase() // Метод для очистки Базы данных от старых рейсов и проданных билетов
        {
            BusinessFlightsRepository bfr = new BusinessFlightsRepository();
            BusinessTicketsRepository btr = new BusinessTicketsRepository();
            BusinessTickets           tic = new BusinessTickets();
            BusinessFlights           fli = new BusinessFlights();
            DateTime NowDate = DateTime.Now.Date;
            int      flag    = 0;

            while (btr.GetAll(NowDate).Count() > 0)
            {
                tic = btr.GetAll(NowDate).First();
                btr.Delete(tic);
                flag = 1;
            }

            while (bfr.GetAll().Where(p => p.ArrivalDate < NowDate).ToList().Count > 0)
            {
                fli = bfr.GetAll().Where(p => p.DepartureDate < NowDate).First();
                bfr.Delete(fli);
                flag = 1;
            }

            if (flag == 1)
            {
                MessageBox.Show("Old Tickets and Flights Deleted");
            }
        }
Exemplo n.º 3
0
        public Tickets()
        {
            BusinessFlightsRepository bfr = new BusinessFlightsRepository();

            InitializeComponent();

            cbCityStart.DataSource = bfr.GetAll().Select(p => p.CityStart).Distinct().ToList();
            cbCityEnd.DataSource   = bfr.GetAll().Select(p => p.CityEnd).Distinct().ToList();
        }
Exemplo n.º 4
0
        private List <BusinessTickets> DeleteTicketsFlightsSeats(Buses bus, ref List <BusinessFlights> busFlights, ref List <Seats> listseats)
        {
            List <BusinessTickets>    busTickets    = new List <BusinessTickets>();
            BusinessTickets           obj           = new BusinessTickets();
            BusinessTicketsRepository busTickRep    = new BusinessTicketsRepository();
            BusinessFlights           objFlights    = new BusinessFlights();
            BusinessFlightsRepository busFlightsRep = new BusinessFlightsRepository();
            Seats           seats    = new Seats();
            SeatsRepository seatsrep = new SeatsRepository();

            int countTick   = busTickRep.GetAll(bus).ToList().Count;
            int countFlight = busFlightsRep.GetAll(bus).ToList().Count;
            int countSeat   = seatsrep.GetAll().Where(p => p.BusId == bus.BusId).Count();

            if (countTick > 0)
            {
                while (countTick-- > 0)
                {
                    obj = busTickRep.GetAll(bus).First();
                    busTickets.Add(obj);
                    busTickRep.Delete(obj);
                }

                while (countFlight-- > 0)
                {
                    objFlights = busFlightsRep.GetAll(bus).First();
                    busFlights.Add(objFlights);
                    busFlightsRep.Delete(objFlights);
                }
                flagdelete = 1;
            }

            else
            {
                while (countFlight-- > 0)
                {
                    objFlights = busFlightsRep.GetAll(bus).First();
                    busFlights.Add(objFlights);
                    busFlightsRep.Delete(objFlights);
                }
                flagdelete = 1;
            }

            while (countSeat-- > 0)
            {
                seats = seatsrep.GetAll().Where(p => p.BusId == bus.BusId).First();
                listseats.Add(seats);
                seatsrep.Delete(seats);
            }
            return(busTickets);
        }
Exemplo n.º 5
0
        private void RefreshBindingSourse(object CityStart, object CityEnd, object dt)
        {
            BusinessFlightsRepository bfr = new BusinessFlightsRepository();

            binSourceBusStation.DataSource            = bfr.GetAll(Convert.ToString(CityStart), Convert.ToString(CityEnd), Convert.ToDateTime(dt));
            dgvBusStation.DataSource                  = binSourceBusStation;
            dgvBusStation.Columns["FlightId"].Visible = false;
        }
Exemplo n.º 6
0
        private void RefreshBindingSourse()
        {
            BusinessFlightsRepository bfr = new BusinessFlightsRepository();

            binSourceBusStation.DataSource            = bfr.GetAll(DateTime.Now.Date);
            dgvBusStation.DataSource                  = binSourceBusStation;
            dgvBusStation.Columns["FlightId"].Visible = false;
        }
Exemplo n.º 7
0
        private void Tickets_Load(object sender, EventArgs e)
        {
            BusinessFlightsRepository bfr = new BusinessFlightsRepository();
            var MaxDate = bfr.GetAll(DateTime.Now.Date).Max(p => p.DepartureDate);

            cbDiscount.DisplayMember = "DiscountName";
            cbDiscount.ValueMember   = "DiscountId";
            cbDiscount.DataSource    = Discountr.GetAll();
            dtpDepartureDate.MaxDate = MaxDate;
            dtpDepartureDate.MinDate = DateTime.Now.Date;
        }
Exemplo n.º 8
0
        private List <BusinessTickets> DeleteTicketsANDFlights(Cities city, ref List <BusinessFlights> busFlights)
        {
            List <BusinessTickets>    busTickets    = new List <BusinessTickets>();
            BusinessTickets           obj           = new BusinessTickets();
            BusinessTicketsRepository busTickRep    = new BusinessTicketsRepository();
            BusinessFlights           objFlights    = new BusinessFlights();
            BusinessFlightsRepository busFlightsRep = new BusinessFlightsRepository();
            int countTick   = busTickRep.GetAll(city).ToList().Count;
            int countFlight = busFlightsRep.GetAll(city).ToList().Count;

            if (countTick > 0)
            {
                while (countTick-- > 0)
                {
                    obj = busTickRep.GetAll(city).First();
                    busTickets.Add(obj);
                    busTickRep.Delete(obj);
                }

                while (countFlight-- > 0)
                {
                    objFlights = busFlightsRep.GetAll(city).First();
                    busFlights.Add(objFlights);
                    busFlightsRep.Delete(objFlights);
                }
                flagdelete = 1;
            }
            else
            {
                while (countFlight-- > 0)
                {
                    objFlights = busFlightsRep.GetAll(city).First();
                    busFlights.Add(objFlights);
                    busFlightsRep.Delete(objFlights);
                }
                flagdelete = 1;
            }
            return(busTickets);
        }
Exemplo n.º 9
0
        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;
        }