Esempio n. 1
0
        private Album albumParser(XmlNodeReader reader)
        {
            string name = reader.GetAttribute("name");
            Album a = new Album(name);

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "song")
                    {
                        Song s = new Song();
                        reader.Read();
                        reader.Read();
                        s.setName(reader.Value);
                        reader.Read();
                        reader.Read();
                        reader.Read();
                        s.setLength(reader.Value);

                        a.addSong(s);
                    }
                    if (reader.Name == "reviewer")
                    {
                        Review r = new Review(reader.GetAttribute("ref"));
                        reader.Read();
                        r.setReview(reader.Value);

                        a.addReview(r);
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                    if (reader.Name == "album")
                        break;
            }

            return a;
        }
Esempio n. 2
0
    protected void submit_Click(object sender, EventArgs e)
    {
        //Get all the data for songs
        int index = 0;
        foreach (GridViewRow row in songGridView.Rows)
        {
            if (index < selectedAlbum.getSongs().Length)
            {
                selectedAlbum.getSongs()[index].setName(((TextBox)row.Cells[0].Controls[1]).Text);
                selectedAlbum.getSongs()[index].setLength(((TextBox)row.Cells[1].Controls[1]).Text);
            }
            else
            {
                Song temp = new Song();
                temp.setName(((TextBox)row.Cells[0].Controls[1]).Text);
                temp.setLength(((TextBox)row.Cells[1].Controls[1]).Text);
                selectedAlbum.addSong(temp);
            }

            index++;
        }

        //Get all the data for the reviews
        index = 0;
        foreach (GridViewRow row in reviewsGridView.Rows)
        {
            if (index < selectedAlbum.getReviews().Length)
            {
                selectedAlbum.getReviews()[index].setReviewerId(reviewers[((DropDownList)row.Cells[0].Controls[1]).SelectedIndex].getId());
                selectedAlbum.getReviews()[index].setReview(((TextBox)row.Cells[1].Controls[1]).Text);
            }
            else
            {
                Review temp = new Review(((DropDownList)row.Cells[0].Controls[1]).SelectedValue);
                temp.setReview(((TextBox)row.Cells[1].Controls[1]).Text);
                selectedAlbum.addReview(temp);
            }

            index++;
        }

        //If band name is difference
        if (albumPageLabel.Text != selectedAlbum.getName())
        {
            //Change the name
            selectedAlbum.setName(albumPageLabel.Text);

            //Save
            save();

            //Reload the page
            Response.Redirect(String.Format("~/album.aspx?b={0}&a={1}", selectedBand.getName(), selectedAlbum.getName()));
        }

        save();
    }