예제 #1
0
        /// <summary>
        /// Gets the flight information from the database and returns a list of LFight objects
        /// </summary>
        /// <returns></returns>
        public List <clsFlight> GetFlights()
        {
            try
            {
                DataSet   ds;
                clsFlight FlightOne;

                string sSQL;
                int    iCount = 0;

                // Get the Flight information from the database.
                sSQL = "Select * FROM Flight";
                ds   = db.ExecuteSQLStatement(sSQL, ref iCount);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    FlightOne               = new clsFlight();
                    FlightOne.FlightID      = ((int)ds.Tables[0].Rows[i][0]);
                    FlightOne.Flight_Number = ds.Tables[0].Rows[i][1].ToString();
                    FlightOne.Aircraft_Type = ds.Tables[0].Rows[i][2].ToString();
                    Flights.Add(FlightOne);
                }// End For

                return(Flights);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "-" + MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
            }
        }
        /// <summary>
        /// Fills the flights
        /// </summary>
        public void FillFlights()
        {
            try
            {
                var iFlightRet         = 0;
                var flightDataset      = clsData.ExecuteSQLStatement("SELECT * FROM flight", ref iFlightRet);
                var table              = flightDataset.Tables[0];
                var columns            = table.Columns;
                var flightIDColumn     = columns["Flight_ID"];
                var flightNumberColumn = columns["Flight_Number"];
                var aircraftTypeColumn = columns["Aircraft_Type"];

                var flightsQuery =
                    from DataRow row in table.Rows
                    select new Flight
                {
                    FlightID     = (int)row[flightIDColumn],
                    FlightNumber = row[flightNumberColumn] as string,
                    AircraftType = row[aircraftTypeColumn] as string
                };

                FlightList = new ObservableCollection <Flight>(flightsQuery);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// Gets flights from database
        /// </summary>
        /// <returns></returns>
        public List <Flight> GetAllFlights()
        {
            List <Flight> flights = new List <Flight>();

            try
            {
                DataSet ds  = new DataSet();
                int     num = 0;

                ds = data.ExecuteSQLStatement(sql.GetFlight(), ref num);

                for (int i = 0; i < num; ++i)
                {
                    Flight flight = new Flight();
                    flight.FlightID   = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString());
                    flight.FlightNum  = Convert.ToInt32(ds.Tables[0].Rows[i][1].ToString());
                    flight.FlightName = ds.Tables[0].Rows[i][2].ToString();
                    flights.Add(flight);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }

            return(flights);
        }
예제 #4
0
        /// <summary>
        /// This will return a list of Passengers based on flightID
        /// </summary>
        /// <param name="selection">This is the flightID</param>
        /// <returns></returns>
        public static List <Passenger> getPassengers(string selection)
        {
            try
            {
                int              iRet    = 0;                                                                     // Temp ref integer, unused but required
                DataSet          ds      = _data.ExecuteSQLStatement(clsAirlineSQL.getInfo(selection), ref iRet); // The DataSet of all the flights
                List <Passenger> flights = new List <Passenger>();                                                // The list of flights to be returned

                foreach (DataRow row in ds.Tables[0].Rows)                                                        // Each row (each individual invoice) in the Invoices table
                {
                    var passenger = new Passenger()
                    {
                        passengerId    = row[0].ToString(),
                        passengerfName = row[1].ToString(),
                        passengerlName = row[2].ToString(),
                        passengerSeat  = row[3].ToString()
                    };

                    flights.Add(passenger);
                }
                return(flights);
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText("C:\\Error.txt", Environment.NewLine + "HandleError Exception: " + ex.Message);
                return(new List <Passenger>());
            }
        }
예제 #5
0
        /// <summary>
        /// This will get all of the flights intialized in the class
        /// </summary>
        public static void getAllFlights()
        {
            try
            {
                int iRet = 0;                                                           // Temp ref integer, unused but required
                totalFlights = iRet;
                ds           = _data.ExecuteSQLStatement(clsAirlineSQL.sSQL, ref iRet); // The DataSet of all the flights
                List <Flight> flights = new List <Flight>();                            // The list of flights to be returned

                foreach (DataRow row in ds.Tables[0].Rows)                              // Each row (each individual invoice) in the Invoices table
                {
                    //Flight_ID, Flight_Number, Aircraft_Type
                    var flight = new Flight() // Temp invoice object to be added to the list
                    {
                        FlightId     = row[0].ToString(),
                        FlightNum    = row[1].ToString(),
                        airCraftType = row[2].ToString()
                    };

                    flights.Add(flight);
                }
                return;
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText("C:\\Error.txt", Environment.NewLine + "HandleError Exception: " + ex.Message);
                return;
            }
        }
예제 #6
0
        /// <summary>
        /// This will delete the passenger
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                int     i  = 0;
                DataSet ds = _data.ExecuteSQLStatement(clsAirlineSQL.selectPassengerID(fName, lName), ref i); // The DataSet of all the flights

                foreach (DataRow row in ds.Tables[0].Rows)                                                    // Each row (each individual invoice) in the Invoices table
                {
                    passengerId = int.Parse(row[0].ToString());
                }

                //Delete the passenger flight info
                _data.ExecuteNonQuery(clsAirlineSQL.deletePassengerIDFromFlightLink(passengerId));
                //Delete the passenger
                _data.ExecuteNonQuery(clsAirlineSQL.deletePassengerIDPassengerTable(passengerId));
                fName = "";
                lName = "";
                this.Close();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

                DataSet ds = new DataSet();
                //Should probably not have SQL statements behind the UI
                string sSQL = "SELECT Flight_ID, Flight_Number, Aircraft_Type FROM FLIGHT";
                int    iRet = 0;
                clsData = new clsDataAccess();

                //This should probably be in a new class.  Would be nice if this new class
                //returned a list of Flight objects that was then bound to the combo box
                //Also should show the flight number and aircraft type together
                ds = clsData.ExecuteSQLStatement(sSQL, ref iRet);

                for (int i = 0; i < iRet; i++)
                {
                    cbChooseFlight.Items.Add(ds.Tables[0].Rows[i][0]);
                }
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
예제 #8
0
        public int getPassengerID()
        {
            clsData = new clsDataAccess();
            int iRet = 0;

            sSQL = sqlStatements.queryOutPassengerID(sPassgenerFirstName, sPassgenerLastName);
            ds   = clsData.ExecuteSQLStatement(sSQL, ref iRet);

            return((int)ds.Tables[0].Rows[0][0]);
        }
        private void cbChooseFlight_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                string selection = cbChooseFlight.SelectedItem.ToString();
                cbChoosePassenger.IsEnabled  = true;
                gPassengerCommands.IsEnabled = true;
                DataSet ds   = new DataSet();
                int     iRet = 0;

                if (selection == "1")
                {
                    CanvasA380.Visibility = Visibility.Hidden;
                    Canvas767.Visibility  = Visibility.Visible;
                }
                else
                {
                    Canvas767.Visibility  = Visibility.Hidden;
                    CanvasA380.Visibility = Visibility.Visible;
                }

                //I think this should be in a new class to hold SQL statments
                string sSQL = "SELECT Passenger.Passenger_ID, First_Name, Last_Name, FPL.Seat_Number " +
                              "FROM Passenger, Flight_Passenger_Link FPL " +
                              "WHERE Passenger.Passenger_ID = FPL.Passenger_ID AND " +
                              "Flight_ID = " + cbChooseFlight.SelectedItem.ToString();//If the cbChooseFlight was bound to a list of Flights, the selected object would have the flight ID
                //Probably put in a new class
                ds = clsData.ExecuteSQLStatement(sSQL, ref iRet);

                cbChoosePassenger.Items.Clear();

                //Would be nice if code from another class executed the SQL above, added each passenger into a Passenger object, then into a list of Passengers to be returned and bound to the combo box
                for (int i = 0; i < iRet; i++)
                {
                    cbChoosePassenger.Items.Add(ds.Tables[0].Rows[i][1] + " " + ds.Tables[0].Rows[i][2]);
                }
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
        /// <summary>
        /// Retruns a list of passengers
        /// </summary>
        /// <param name="iFlight_ID"></param>
        /// <returns></returns>
        public List <clsPassengers> GetPassengers(int iFlight_ID)
        {
            try
            {
                //local variable that counts the number of rows returned from database
                int iNumRetValues = 0;

                //Our ExecuteSQLStatement returns a data set.
                //Reference a dataset called ds
                DataSet ds;

                //creates a list new instance of clsPassenger class
                List <clsPassengers> lstPassengers = new List <clsPassengers>();

                //SQL that gets the first and last name of every passenger on a specific flight
                string sSQL = "SELECT Passenger.Passenger_ID, First_Name, Last_Name, FPL.Seat_Number " +
                              "FROM Passenger, Flight_Passenger_Link FPL " +
                              "WHERE Passenger.Passenger_ID = FPL.Passenger_ID AND " +
                              "Flight_ID = " + iFlight_ID;

                //new instance of clsDataAccess creates an object called db
                db = new clsDataAccess();

                //ds holds our dataset retrieved from database
                ds = db.ExecuteSQLStatement(sSQL, ref iNumRetValues);

                //loop through the dataset ds and add the first name and last names to our list of passengers
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    lstPassengers.Add(new clsPassengers {
                        sFirstName = Convert.ToString(row["First_Name"]), sLastName = Convert.ToString(row["Last_Name"]), iSeat = Convert.ToInt32(row["Seat_Number"])
                    });
                }

                //returns our list of passengers
                return(lstPassengers);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #11
0
        public List <clsFlightsObject> listOfFlightMethod()
        {
            listOfFlights = new List <clsFlightsObject>();

            string sSQL = sqlStatements.returnFlightInfo();
            int    iRet = 0;

            clsData = new clsDataAccess();

            //This should probably be in a new class.  Would be nice if this new class
            //returned a list of Flight objects that was then bound to the combo box
            //Also should show the flight number and aircraft type together
            ds = clsData.ExecuteSQLStatement(sSQL, ref iRet);

            for (int i = 0; i < iRet; i++)
            {
                flight = new clsFlightsObject((int)ds.Tables[0].Rows[i][0], (string)ds.Tables[0].Rows[i][1], (string)ds.Tables[0].Rows[i][2]);
                listOfFlights.Add(flight);
            }
            return(listOfFlights);
        }
        //MainWindow wndMainWindow;

        #endregion

        #region Methods

        /// <summary>
        /// Returns a list of Flights
        /// </summary>
        /// <returns></returns>
        public List <clsFlights> GetFlights()
        {
            try
            {
                //local variable that counts the number of rows returned from database
                int iNumRetValues = 0;

                //Our ExecuteSQLStatement returns a data set.
                //Reference a dataset called ds
                DataSet ds;

                //Creates a new list instance of clsFlights class
                List <clsFlights> lstFlights = new List <clsFlights>();

                //SQL that gets all rows from table Flight
                string sSQL = "SELECT Flight_ID, Flight_Number, Aircraft_Type FROM FLIGHT";


                //new instance of clsDataAccess creates an object called db
                db = new clsDataAccess();

                //ds holds our dataset retrieved from database
                ds = db.ExecuteSQLStatement(sSQL, ref iNumRetValues);

                //loop through the dataset ds and add the Flight_Number and Aircraft_Type to our list of Flights
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    lstFlights.Add(new clsFlights {
                        iFlightNumber = Convert.ToInt32(row["Flight_Number"]), sFlightName = Convert.ToString(row["Aircraft_Type"])
                    });
                }

                //returns a list of Flights
                return(lstFlights);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #13
0
        public List <clsPassangerObject> passengerPull(ComboBox cbChooseFlight)
        {
            clsFlightsObject flightSeletedFlight = (clsFlightsObject)cbChooseFlight.SelectedItem;

            listofPassengers = new List <clsPassangerObject>();

            clsData = new clsDataAccess();
            int iRet = 0;


            string sSQL = sqlStatements.getPassengerforFlight(flightSeletedFlight.flightID);

            ds = clsData.ExecuteSQLStatement(sSQL, ref iRet);

            for (int i = 0; i < iRet; i++)
            {
                passanger = new clsPassangerObject((int)ds.Tables[0].Rows[i][0], (string)ds.Tables[0].Rows[i][1], (string)ds.Tables[0].Rows[i][2]);
                listofPassengers.Add(passanger);
            }

            return(listofPassengers);
        }