コード例 #1
0
    /// <summary>
    /// this is the effect of pressing the 'add rating' button.
    /// it adds the ddl rating as a reference to the song that is being updated
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddRatingButton_Click(object sender, EventArgs e)
    {
        int songID = int.Parse(EditingSongID.Text);
        RatingToSongController rtos = new RatingToSongController();
        int ratingID = int.Parse(RatingToAddDDL.SelectedValue);

        if (songID != -1)
        {
            try
            {
                if (songID == -1)
                {
                    Message.Text = "Song not yet created; pleas create the song before adding Ratings(s)";
                }
                else if (ratingID == 0)
                {
                    Message.Text = "No Rating has been selected; please select a Rating to add";
                }
                else if (rtos.CheckRefExists(songID, ratingID))
                {
                    Message.Text = "Rating has already been added; please select a different Rating to add";
                }
                else
                {
                    rtos.CreateReference(songID, ratingID);
                    LoadEditData();
                    Message.Text = "The Rating '" + RatingToAddDDL.SelectedItem.ToString() + "' has been sucessfuly added";

                    //reset the value to 'select...'
                    RatingToAddDDL.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Message.Text = GetInerException(ex).Message;
            }
        }
        else
        {
            Message.Text = "Song not yet created; pleas create the song before adding Rating(s)";
        }
    }