public static void Add(CarColor c) { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand command = new SqlCommand("INSERT INTO colors (name) VALUES(@name)", con)) { command.Parameters.AddWithValue("@name", c.Name); command.ExecuteNonQuery(); } } }
public static void Update(CarColor c) { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand command = new SqlCommand("UPDATE colors SET name = @name WHERE id = @id", con)) { command.Parameters.AddWithValue("@id", c.Id); command.Parameters.AddWithValue("@name", c.Name); command.ExecuteNonQuery(); } } }
public Car(int id, string registrationNumber, Model model, int year, string engineNumber, string frameNumber, CarColor color, string engineVolume, string description, string carOwnerName, string contactNumber) { this.Id = id; this.RegistrationNumber = registrationNumber; this.Model = model; this.Year = year; this.EngineNumber = engineNumber; this.FrameNumber = frameNumber; this.Description = description; this.Color = color; this.EngineVolume = engineVolume; this.Description = description; this.CarOwnerName = carOwnerName; this.ContactNumber = contactNumber; }