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); } }
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); }
public clsFlightLogic() { clsData = new clsDataAccess(); }