public List<Bookings> getBookings(Customer cust) { List<Bookings> bookingList = new List<Bookings>(); try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand cmd = new SQLiteCommand("select * from bookings natural join accommodations where cust_id = " + cust.Custi_id, connection); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { String acc_name = reader.GetString(reader.GetOrdinal("acc_name")); int book_id = reader.GetInt32(reader.GetOrdinal("book_id")); int acc_id = reader.GetInt32(reader.GetOrdinal("acc_id")); int room_id = reader.GetInt32(reader.GetOrdinal("room_id")); int room_number = reader.GetInt32(reader.GetOrdinal("room_number")); String start_date = reader.GetString(reader.GetOrdinal("start_date")); String end_date = reader.GetString(reader.GetOrdinal("end_date")); Bookings b = new Bookings(cust,acc_name, book_id, acc_id, room_id, room_number, start_date, end_date); bookingList.Add(b); } } connection.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return bookingList; }
public void deleteBooking(Bookings b) { try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); string myInsertQuery = "DELETE FROM bookings where book_id="+b.Book_id; command.CommandText = myInsertQuery; command.ExecuteNonQuery(); connection.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log( b.C.Custi_id, 7); ////////////needs ids } catch(Exception){ } }