예제 #1
0
        public void RefreshSeats()
        {
            DateTime dt = DateTime.Now.Date;

            cbSeats.DataSource = null;
            BusStationEntities conect = new BusStationEntities();

            flight = binSourceBusStation.Current as BusinessFlights;
            string BussName = flight.Bus;

            dt = flight.DepartureDate;
            int Busid = conect.Buses.Where(p => p.BusName == BussName).Select(p => p.BusId).First();


            var notSeats = conect.Tickets.Where(p => p.Flights.DepartureDate == dt && p.Flights.BusId == Busid).Select(p => p.SeatId).ToList();
            int count    = 0;

            cbSeats.ValueMember   = "SeatId";
            cbSeats.DisplayMember = "NumberSeat";
            var tempSeats = Seatsr.GetAll().Where(p => p.BusId == Busid).ToList();

            while (count < notSeats.Count)
            {
                tempSeats = tempSeats.Where(p => p.SeatId != notSeats[count]).ToList();
                count++;
            }
            cbSeats.DataSource = tempSeats;
        }
예제 #2
0
        public void RefreshSeats()
        {
            if (binSourceBusStation.Count != 0)
            {
                flight = binSourceBusStation.Current as BusinessFlights;
                if (flight.CityStart != null)
                {
                    DateTime dt = DateTime.Now.Date;
                    cbSeats.DataSource = null;
                    BusStationEntities        conect = new BusStationEntities();
                    BusRepository             busrep = new BusRepository();
                    BusinessTicketsRepository btr    = new BusinessTicketsRepository();
                    string BussName = flight.Bus;
                    dt = flight.DepartureDate;
                    int Busid    = busrep.GetAll().Where(p => p.BusName == BussName).Select(p => p.BusId).First();
                    var notSeats = conect.Tickets.Where(p => p.Flights.DepartureDate == dt && p.Flights.BusId == Busid).Select(p => p.SeatId).ToList();
                    int count    = 0;

                    cbSeats.ValueMember   = "SeatId";
                    cbSeats.DisplayMember = "NumberSeat";
                    var tempSeats = Seatsr.GetAll().Where(p => p.BusId == Busid).ToList();
                    while (count < notSeats.Count)
                    {
                        tempSeats = tempSeats.Where(p => p.SeatId != notSeats[count]).ToList();
                        count++;
                    }
                    cbSeats.DataSource = tempSeats;
                }
                else
                {
                    MessageBox.Show("Выберите рейс");
                }
            }
        }
예제 #3
0
        private void bRoleCreate_Click(object sender, EventArgs e)
        {
            FormCreateRole crRole = new FormCreateRole();

            crRole.UEForm = this;
            this.Visible  = false;
            if (crRole.ShowDialog() == DialogResult.OK)
            {
                BusStationEntities context = new BusStationEntities();
                Roles role = new Roles();
                role.RoleName = crRole.tbRoleName.Text;
                context.Roles.Add(role);
                context.SaveChanges();
                MessageBox.Show("Role Add");
                GetRoles();
            }
        }
예제 #4
0
        private void bBuyTicket_Click(object sender, EventArgs e)
        {
            BusStationEntities conect = new BusStationEntities();

            if (cbCityStart.Text != "" && cbCityEnd.Text != "" && cbSeats.Text != "")
            {
                DataBase.DataBaseBuses.Tickets ticket = new DataBase.DataBaseBuses.Tickets();
                ticket.ReleaseDate = DateTime.Now.Date;
                ticket.FlightId    = flight.FlightId;
                ticket.SeatId      = Convert.ToInt32(cbSeats.SelectedValue);
                ticket.DiscountId  = Convert.ToInt32(cbDiscount.SelectedValue);
                ticket.Sold        = true;
                conect.Tickets.Add(ticket);
                conect.SaveChanges();
                MessageBox.Show("Ticket Sold");
                RefreshSeats();
            }

            else
            {
                MessageBox.Show("Fill in all the fields");
            }
        }