public void FindAllDestinations() { //re-set the connection DB = new clsDataConnection(); //var to store the index Int32 Index = 0; //var to store the Destination number of the current record Int32 DestinationID; //var to flag that user was found Boolean DestinationFound; //execute the stored procedure DB.Execute("sproc_tblDestination_SelectAll"); //get the count of records mCount = DB.Count; //while there are still records to process while (Index < DB.Count) { //create an instance of the destination class clsDestination NewDestination = new clsDestination(); //get the destination number from the database DestinationID = Convert.ToInt32(DB.DataTable.Rows[Index]["DestinationID"]); //find the user by invoking the find method DestinationFound = NewDestination.Find(DestinationID); if (DestinationFound == true) { //add the user to the list mDestinationList.Add(NewDestination); } //increment the index Index++; } }
void PopulateArray(clsDataConnection DB) { //populates the array list based on the data table in the parameter DB //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //get the count of records RecordCount = DB.Count; //clear the private array list mDestinationList = new List <clsDestination>(); //While there are record are records to process while (Index < RecordCount) { //create a blank Destination clsDestination AnDestination = new clsDestination(); //read in the fields from the current record AnDestination.DestinationID = Convert.ToInt32(DB.DataTable.Rows[0]["DestinationID"]); //private Int32 PickupTime; AnDestination.PickupTime = Convert.ToDateTime(DB.DataTable.Rows[0]["PickupTime"]); //private Int32 EndPointHouseNo; AnDestination.EndPointHouseNo = Convert.ToString(DB.DataTable.Rows[0]["EndPointHouseNo"]); //private string EndPointPostCode; AnDestination.EndPointPostCode = Convert.ToString(DB.DataTable.Rows[0]["EndPointPostCode"]); //private string EndPointStreet; AnDestination.EndPointStreet = Convert.ToString(DB.DataTable.Rows[0]["EndPointStreet"]); //private string EndPointTown; AnDestination.EndPointTown = Convert.ToString(DB.DataTable.Rows[0]["EndPointTown"]); //private string DropoffTime; AnDestination.DropoffTime = Convert.ToDateTime(DB.DataTable.Rows[0]["DropoffTime"]); //add the record to the private data member mDestinationList.Add(AnDestination); //point at the next record Index++; } }