public IQueryable <Location> ddlLocation_GetData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from location in db.Locations orderby location.City ascending select location;

            return(query);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("../Login.aspx");
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["Id"] == null)
                {
                    Response.Redirect("~/Pages/ListRoute.aspx");
                }
                int id = int.Parse(Request.QueryString["Id"]);

                using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
                {
                    var route = db.Routes.Find(id);

                    txtID.Text = route.Route_ID.ToString();
                    ddlOriginAirport.SelectedValue      = route.Origin_Airport.ToString();
                    ddlDestinationAirport.SelectedValue = route.Destination_Airport.ToString();
                    txtDistance.Text = route.Distance.ToString();
                    ViewState["Id"]  = route.Route_ID;
                }
            }
        }
예제 #3
0
        public IQueryable <TravelClass> GetTravelClasss()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from travelclass in db.TravelClasses orderby travelclass.Travel_Class_ID select travelclass;

            return(query);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("../Login.aspx");
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["Id"] == null)
                {
                    Response.Redirect("~/Pages/ListPassenger.aspx");
                }
                int id = int.Parse(Request.QueryString["Id"]);

                using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
                {
                    var passenger = db.Passengers.Find(id);

                    txtName.Text            = passenger.FullName;
                    txtAge.Text             = passenger.Age.ToString();
                    ddlGender.SelectedValue = passenger.Gender.ToString();
                    txtEmail.Text           = passenger.Email;
                    txtStreet.Text          = passenger.Street;
                    txtCity.Text            = passenger.Location_City;
                    ViewState["Id"]         = id;
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string fullName = txtName.Text;
            int    age      = int.Parse(txtAge.Text);
            bool   gender   = bool.Parse(ddlGender.SelectedValue);
            int    tel      = int.Parse(txtTel.Text);
            string email    = txtEmail.Text;
            string street   = txtStreet.Text;
            string city     = txtCity.Text;

            using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
            {
                var passenger = new Passenger()
                {
                    FullName      = fullName,
                    Gender        = gender,
                    Tel           = tel,
                    Age           = age,
                    Email         = email,
                    Location_City = city,
                    Street        = street
                };
                db.Passengers.Add(passenger);
                db.SaveChanges();
                Response.Redirect("~/Pages/ListPassenger.aspx");
            }
        }
예제 #6
0
        public IQueryable <Location> GetLocation()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from location in db.Locations orderby location.City select location;

            return(query);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("../Login.aspx");
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["Id"] == null)
                {
                    Response.Redirect("~/Pages/ListAirport.aspx");
                }
                int id = int.Parse(Request.QueryString["Id"]);

                using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
                {
                    var airport = db.Airports.Find(id);

                    txtID.Text   = airport.Airport_ID.ToString();
                    txtName.Text = airport.Airport_Name.ToString();
                    ddlLocation.SelectedValue = airport.Location_City;
                    ViewState["Id"]           = airport.Airport_ID;
                }
            }
        }
예제 #8
0
 public static User GetCurrentUser(String userName)
 {
     using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
     {
         return(db.Users.Find(userName));
     }
 }
예제 #9
0
        private List <Flight> ListFlightArrival(String arrivalTime, String original, String destination)
        {
            List <int>    originalAp    = LoadAirport(original);
            List <int>    destinationAp = LoadAirport(destination);
            List <int>    routes        = LoadRoad(originalAp, destinationAp);
            List <Flight> flights;

            using (var db = new AirlineTicketBookingDBContext())
            {
                if (arrivalTime.Length != 0)
                {
                    DateTime depart = Convert.ToDateTime(arrivalTime);
                    var      query  = from d in db.Flights
                                      where routes.Contains((int)d.Route_ID) &&
                                      depart == ((DateTime)d.Arrival_DateTime).Date
                                      select d;
                    flights = query.ToList();
                }
                else
                {
                    var query = from d in db.Flights where routes.Contains((int)d.Route_ID) select d;
                    flights = query.ToList();
                }
            }

            return(flights);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int    id       = int.Parse(ViewState["Id"].ToString());
            string fullName = txtName.Text;
            int    age      = int.Parse(txtAge.Text);
            bool   gender   = bool.Parse(ddlGender.SelectedValue);
            int    tel      = int.Parse(txtTel.Text);
            string email    = txtEmail.Text;
            string street   = txtStreet.Text;
            string city     = txtCity.Text;

            using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
            {
                var passenger = db.Passengers.Find(id);
                if (passenger != null)
                {
                    passenger.FullName      = fullName;
                    passenger.Age           = age;
                    passenger.Email         = email;
                    passenger.Gender        = gender;
                    passenger.Tel           = tel;
                    passenger.Street        = street;
                    passenger.Location_City = city;
                    db.SaveChanges();
                }
                Response.Redirect("~/Pages/ListPassenger.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("../Login.aspx");
            }
            if (!IsPostBack)
            {
                String   id          = Request.QueryString["Id"];
                String[] param       = id.Split(',');
                int      airplane_ID = int.Parse(param[0]);
                int      seat_No     = int.Parse(param[1]);

                using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
                {
                    var airplaneSeat = db.AirplaneSeats.Find(airplane_ID, seat_No);

                    txtAirplaneID.Text = airplaneSeat.Airplane_ID.ToString();
                    txtSeatNo.Text     = airplaneSeat.Seat_No.ToString();
                    DisplayTravelClasses(airplaneSeat.Travel_Class_ID);

                    ViewState["Id"] = id;
                }
            }
        }
예제 #12
0
        public IQueryable <Airplane> GetAirplanes()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from airplane in db.Airplanes orderby airplane.Airplane_ID select airplane;

            return(query);
        }
예제 #13
0
        public IQueryable <Airport> ddlAirport_GetData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from airport in db.Airports select airport;

            return(query);
        }
예제 #14
0
 protected void LogIn(object sender, EventArgs e)
 {
     if (IsValid)
     {
         String userName = txtUserName.Text;
         String password = txtPassword.Text;
         using (AirlineTicketBookingDBContext db = new AirlineTicketBookingDBContext())
         {
             Admin user = db.Admins.Find(userName);
             if (user == null)
             {
                 lblError.Text = "Username does not exist";
             }
             else if (user.password != password)
             {
                 lblError.Text = "Incorrect password";
             }
             else
             {
                 Session["admin"] = userName;
                 Response.Redirect("Default.aspx");
             }
         }
     }
 }
예제 #15
0
        public IQueryable <Route> GetRoutes()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from route in db.Routes orderby route.Route_ID select route;

            return(query);
        }
예제 #16
0
        public IQueryable <Producer> GetProducers()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from producer in db.Producers orderby producer.Producer_ID select producer;

            return(query);
        }
예제 #17
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from user in db.Users select user;

            grvUser.DataSource = query.ToList();
            grvUser.DataBind();
        }
예제 #18
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from producer in db.Producers select producer;

            grdProducers.DataSource = query.ToList();
            grdProducers.DataBind();
        }
예제 #19
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from airport in db.Airports orderby airport.Airport_ID select airport;

            grvAirports.DataSource = query.ToList();
            grvAirports.DataBind();
        }
예제 #20
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from d in db.Payments select d;

            grvBooking.DataSource = query.ToList();
            grvBooking.DataBind();
        }
예제 #21
0
 protected double getBlance()
 {
     using (var db = new AirlineTicketBookingDBContext())
     {
         User user = db.Users.Find(Session["username"]);
         return((double)user.Wallet);
     }
 }
예제 #22
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from ticket in db.Tickets orderby ticket.Ticket_ID ascending select ticket;

            grdTickets.DataSource = query.ToList();
            grdTickets.DataBind();
        }
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from passenger in db.Passengers orderby passenger.PassengerID ascending select passenger;

            grvPassenger.DataSource = query.ToList();
            grvPassenger.DataBind();
        }
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from travelclass in db.TravelClasses orderby travelclass.Travel_Class_ID ascending select travelclass;

            grdTravelClasses.DataSource = query.ToList();
            grdTravelClasses.DataBind();
        }
예제 #25
0
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from flight in db.Flights orderby flight.Flight_No ascending select flight;

            grdFlights.DataSource = query.ToList();
            grdFlights.DataBind();
        }
        public void DisplayData()
        {
            var db    = new AirlineTicketBookingDBContext();
            var query = from airplane in db.Airplanes orderby airplane.Airplane_ID ascending select airplane;

            grdAirplanes.DataSource = query.ToList();
            grdAirplanes.DataBind();
        }
예제 #27
0
        protected void checkExist(object source, ServerValidateEventArgs args)
        {
            string stringID = args.Value;
            int    id       = int.Parse(stringID);
            var    db       = new AirlineTicketBookingDBContext();
            var    airport  = db.Airports.Find(id);

            args.IsValid = (airport == null);
        }
 public void DisplayAirplanes(int?airplane_ID)
 {
     using (var db = new AirlineTicketBookingDBContext())
     {
         var airplanes = (from airplane in db.Airplanes select airplane).ToList();
         drpAirplane.DataSource = airplanes;
         drpAirplane.DataBind();
     }
     drpAirplane.SelectedValue = airplane_ID.ToString();
 }
 public void DisplayRoutes(int?route_ID)
 {
     using (var db = new AirlineTicketBookingDBContext())
     {
         var routes = (from route in db.Routes select route).ToList();
         drpRoute.DataSource = routes;
         drpRoute.DataBind();
     }
     drpRoute.SelectedValue = route_ID.ToString();
 }
예제 #30
0
 public void DisplaySeats(int?airplane_ID)
 {
     drpSeatNo.Items.Clear();
     using (var db = new AirlineTicketBookingDBContext())
     {
         var seats = (from seat in db.AirplaneSeats where seat.Airplane_ID == airplane_ID orderby seat.Seat_No select seat).ToList();
         drpSeatNo.DataSource = seats;
         drpSeatNo.DataBind();
     }
 }