private void rating_Click(object sender, EventArgs e) { DataBaseAccess database = new DataBaseAccess(); database.StartConnection(); // if already added a rating then change it if (database.UserRatedAsset((int)_curUserData.GetUserID(), _userAsset.GetID())) { int ratingId = -1; List <Classes.UserRating> ratingsOfAsset = database.GetRatingsOfAsset(_userAsset.GetID()); // get the rating id of the previous rating for (int i = 0; i < ratingsOfAsset.Count; i++) { if (ratingsOfAsset[i].ReviewerID == _curUserData.GetUserID()) { ratingId = ratingsOfAsset[i].ID; break; } } if (ratingId != -1) { database.ChangeRatingStars(ratingId, starRating._rating); } } // if not rated yet then add rating else { database.AddRating((int)_curUserData.GetUserID(), _userAsset.GetID(), starRating._rating, ""); } updateOverallRating(sender, e); database.CloseConnection(); }