示例#1
0
        public static ReservationFinie Create(ReservationFinie reserv)
        {
            using (SqlConnection connection = Database.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(CREATE, connection);
                command.Parameters.AddWithValue("@dateReservation", reserv.DateReservation);
                command.Parameters.AddWithValue("@dateLivraison", reserv.DateLivraison);
                command.Parameters.AddWithValue("@prixAchat", reserv.PrixAchat);
                command.Parameters.AddWithValue("@etat", reserv.Etat);
                command.Parameters.AddWithValue(@"idMembre", reserv.IdMembre);
                command.Parameters.AddWithValue(@"idJeuVideo", reserv.IdJeuxVideo);

                reserv.IdReservation = (int)command.ExecuteScalar();
            }
            return(reserv);
        }
示例#2
0
        public static ReservationFinie Get(int id)
        {
            ReservationFinie reserv = null;

            using (SqlConnection connection = Database.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(GET, connection);
                command.Parameters.AddWithValue("@id", id);
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    reserv = new ReservationFinie(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDecimal(3), reader.GetString(4), reader.GetInt32(5), reader.GetInt32(6));
                }
            }
            return(reserv);
        }
示例#3
0
        public static bool Update(ReservationFinie reserv)
        {
            bool aEteModifie = false;

            using (SqlConnection connection = Database.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(UPDATE, connection);
                command.Parameters.AddWithValue("@idReservation", reserv.IdReservation);
                command.Parameters.AddWithValue("@dateReservation", reserv.DateReservation);
                command.Parameters.AddWithValue("@dateLivraison", reserv.DateLivraison);
                command.Parameters.AddWithValue("@prixAchat", reserv.PrixAchat);
                command.Parameters.AddWithValue("@etat", reserv.Etat);

                aEteModifie = command.ExecuteNonQuery() != 0;
            }
            return(aEteModifie);
        }