public static ReservationEnCours Create(ReservationEnCours reservationEnCours) { using (SqlConnection connection = Database.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(CREATE, connection); command.Parameters.AddWithValue("@dateReservation", reservationEnCours.DateReservation); command.Parameters.AddWithValue("@dateLivraison", reservationEnCours.DateLivraison); command.Parameters.AddWithValue("@prixAchat", reservationEnCours.PrixAchat); command.Parameters.AddWithValue("@etat", reservationEnCours.Etat); command.Parameters.AddWithValue("@idMembre", reservationEnCours.IdMembre); command.Parameters.AddWithValue("@idJeuVideo", reservationEnCours.IdJeuxVideo); reservationEnCours.IdReservation = (int)command.ExecuteScalar(); } return(reservationEnCours); }
public static ReservationEnCours Get(int id) { ReservationEnCours reserv = null; using (SqlConnection connection = Database.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(GET, connection); command.Parameters.AddWithValue("@idReservation", id); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { reserv = new ReservationEnCours(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDecimal(3), reader.GetString(4), reader.GetInt32(5), reader.GetInt32(6)); } } return(reserv); }
public static bool Update(ReservationEnCours reservationEnCours) { bool aEteModifie = false; using (SqlConnection connection = Database.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(UPDATE, connection); command.Parameters.AddWithValue("@idReservation", reservationEnCours.IdReservation); command.Parameters.AddWithValue("@dateReservation", reservationEnCours.DateReservation); command.Parameters.AddWithValue("@dateLivraison", reservationEnCours.DateLivraison); command.Parameters.AddWithValue("@prixAchat", reservationEnCours.PrixAchat); command.Parameters.AddWithValue("@etat", reservationEnCours.Etat); aEteModifie = command.ExecuteNonQuery() != 0; } return(aEteModifie); }