Exemplo n.º 1
0
    /// <summary>
    /// this is the effect of pressing the 'add artist' button.
    /// it adds the ddl artist as a reference to the song that is being updated
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddArtistButton_Click(object sender, EventArgs e)
    {
        int songID = int.Parse(EditingSongID.Text);
        ArtistToSongController atos = new ArtistToSongController();
        int artistID = int.Parse(ArtistToAddDDL.SelectedValue);

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

                    //reset the value to 'select...'
                    ArtistToAddDDL.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Message.Text = GetInerException(ex).Message;
            }
        }
        else
        {
            Message.Text = "Song not yet created; pleas create the song before adding Artist(s)";
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// this is for removing and viewing genres of the song that is currently being edited
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditingArtists_GridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            e.Handled = true;
            int   index = Convert.ToInt32(e.CommandArgument);
            Label artistIDController    = (Label)EditingArtists_GridView.Rows[index].FindControl("EditingArtistID");
            Label artistNameController  = (Label)EditingArtists_GridView.Rows[index].FindControl("EditingArtist");
            ArtistToSongController atos = new ArtistToSongController();
            try
            {
                atos.RemoveReference(int.Parse(EditingSongID.Text), int.Parse(artistIDController.Text));
                LoadEditData();

                Message.Text = "The Artist '" + artistNameController.Text + "' has been sucessfuly removed";
            }
            catch (Exception ex)
            {
                Message.Text = GetInerException(ex).ToString();
            }
        }
    }
Exemplo n.º 3
0
    private void LoadEditData()
    {
        ArtistToSongController atos = new ArtistToSongController();
        FiletypeController     fc   = new FiletypeController();
        GenreToSongController  gtos = new GenreToSongController();
        RatingToSongController rtos = new RatingToSongController();
        SongController         sc   = new SongController();

        try
        {
            //reset the ddl so that its on the first one which is 'Select...'
            //manualy adding all the rows so that Select... is the first one and Editing FiletypeDDL doesn't get stacking data
            DataTable t = new DataTable();
            t.Columns.Add("FiletypeID");
            t.Columns.Add("Filetype");
            t.Rows.Add(new string[] { "0", "Select..." });
            foreach (DataRow dr in fc.GetFiletypes().Rows)
            {
                t.Rows.Add(new string[] { dr.Field <int>("FiletypeID").ToString(), dr.Field <string>("Filetype") });
            }

            EditingFiletypeDDL.DataSource     = t;
            EditingFiletypeDDL.DataTextField  = "Filetype";
            EditingFiletypeDDL.DataValueField = "FiletypeID";
            EditingFiletypeDDL.DataBind();

            //no song selected
            if (EditingSongID.Text == "-1")
            {
                //clear the song information
                EditingSongName.Text = "";

                //make sure its on 'select'
                EditingFiletypeDDL.SelectedIndex = 0;

                //make sure that all of the editing gridviews show emty if there aren't any
                EditingArtists_GridView.DataBind();
                EditingRatings_GridView.DataBind();
                EditingGenres_GridView.DataBind();

                //determine which button will be used on the edit/add tab
                Update_SongNameAndFiletype.Visible = false;
                Create_NewSong.Visible             = true;
            }
            //a song is being edited
            else
            {
                int       songid = int.Parse(EditingSongID.Text);
                DataTable songT  = sc.fetchSong(songid);
                EditingSongName.Text = songT.Rows[0].Field <string>("SongName");
                //make sure its on the right value
                EditingFiletypeDDL.SelectedValue = songT.Rows[0].Field <int>("FiletypeID").ToString();

                #region Load and Bind Artists
                DataTable artistT = atos.GetArtistToSongInfo(songid);
                EditingArtists_GridView.DataSource = artistT;
                EditingArtists_GridView.DataBind();
                #endregion

                #region Load and Bind Ratings
                DataTable ratingT = rtos.GetRatingToSongInfo(songid);
                EditingRatings_GridView.DataSource = ratingT;
                EditingRatings_GridView.DataBind();
                #endregion

                #region Load and Bind Genres

                DataTable genreT = gtos.GetGenreToSongInfo(songid);
                EditingGenres_GridView.DataSource = genreT;
                EditingGenres_GridView.DataBind();
                #endregion

                //set the update button to being visable, and turn the add/create button invisable
                Update_SongNameAndFiletype.Visible = true;
                Create_NewSong.Visible             = false;
            }
            EditingFiletypeDDL.DataBind();
        }
        catch (Exception ex)
        {
            Message.Text = GetInerException(ex).ToString();
        }
    }