public List <Destination> GetDestinations() { List <Destination> destinationList = new List <Destination>(); using (SqlConnection connection = new SqlConnection(WebServiceDBReader.GetConnectionString())) { connection.Open(); using (SqlCommand command = new SqlCommand("SELECT * FROM Destination", connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Destination newDestination = new Destination(); newDestination.destinationNbr = reader.GetValue(0).ToString(); newDestination.city = reader.GetValue(1).ToString(); newDestination.country = reader.GetValue(2).ToString(); newDestination.hotel = reader.GetValue(3).ToString(); destinationList.Add(newDestination); } } } } return(destinationList); }
public List <Customer> GetCustomers() { List <Customer> customerList = new List <Customer>(); using (SqlConnection connection = new SqlConnection(WebServiceDBReader.GetConnectionString())) { connection.Open(); using (SqlCommand command = new SqlCommand("SELECT customerNbr AS [Cust. No] , name AS Name, address AS Address, ssn AS SSN FROM Customer", connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Customer newCustomer = new Customer(); newCustomer.idNbr = reader.GetValue(0).ToString(); newCustomer.name = reader.GetValue(1).ToString(); newCustomer.address = reader.GetValue(2).ToString(); newCustomer.ssn = reader.GetValue(3).ToString(); customerList.Add(newCustomer); } } } } return(customerList); }
public List <Booking> GetBookings() { List <Booking> bookingList = new List <Booking>(); using (SqlConnection connection = new SqlConnection(WebServiceDBReader.GetConnectionString())) { connection.Open(); using (SqlCommand command = new SqlCommand("SELECT * FROM Booking", connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Booking newBooking = new Booking(); newBooking.customerNbr = reader.GetValue(0).ToString(); newBooking.destinationNbr = reader.GetValue(1).ToString(); newBooking.dateOut = reader.GetValue(2).ToString(); newBooking.dateHome = reader.GetValue(3).ToString(); newBooking.bookingNbr = reader.GetValue(4).ToString(); bookingList.Add(newBooking); } } } } return(bookingList); }
public DataTable GetCollection(string query) { using (SqlConnection sqlCon = new SqlConnection(WebServiceDBReader.GetConnectionString())) { SqlDataAdapter sqlData = new SqlDataAdapter(query, sqlCon); DataTable dtbl = new DataTable(); sqlData.Fill(dtbl); return(dtbl); } }