コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AlbumDataAccess       albumDA = new AlbumDataAccess();
            MusicDataAccess.Album cur     = albumDA.FindAlbum(int.Parse(Request.QueryString["id"]));

            //fill in the fields, only if they aren't null
            if (cur.AlbumName != null)
            {
                txtAlbumName.Text = cur.AlbumName.ToString();
            }
            if (cur.ArtistName != null)
            {
                txtArtistName.Text = cur.ArtistName.ToString();
            }
            if (cur.Label != null)
            {
                txtLabel.Text = cur.Label.ToString();
            }
            if (cur.Genre != null)
            {
                ddlGenre.SelectedValue = cur.Genre.ToString();
            }
            if (cur.Year != null)
            {
                txtYear.Text = cur.Year.ToString();
            }
            if (cur.Artwork != null)
            {
                txtArtwork.Text = cur.Artwork.ToString();
            }
        }
    }
コード例 #2
0
    protected void BtnModify_Click(object sender, EventArgs e)
    {
        MusicDataAccess.Album updated = new MusicDataAccess.Album();
        updated.AlbumId    = int.Parse(Request.QueryString["id"]);
        updated.AlbumName  = txtAlbumName.Text;
        updated.ArtistName = txtArtistName.Text;
        updated.Label      = txtLabel.Text;
        updated.Genre      = ddlGenre.SelectedValue;
        updated.Year       = Convert.ToInt16(txtYear.Text);
        updated.Artwork    = txtArtwork.Text;

        AlbumDataAccess modify = new AlbumDataAccess();

        modify.Modify(updated);
        Response.Redirect("AlbumList.aspx");
    }
コード例 #3
0
    protected void FormSubmit(Object sender,
                              EventArgs e)
    {
        if (!requiredAlbum.IsValid)
        {
            EmptyAlbumName.Attributes["style"] = "display: block";
        }

        if (!requiredArtist.IsValid)
        {
            EmptyArtistName.Attributes["style"] = "display: block";
        }

        if (Page.IsValid)
        {
            FormSuccess.Attributes["style"] = "display: block";

            //add to DB
            MusicDataAccess.Album newAlbum = new MusicDataAccess.Album();
            newAlbum.AlbumName  = txtAlbumName.Text;
            newAlbum.ArtistName = txtArtistName.Text;
            newAlbum.Label      = txtLabel.Text;
            newAlbum.Genre      = ddlGenre.SelectedValue;
            newAlbum.Year       = Convert.ToInt16(txtYear.Text);
            //newAlbum.Image =

            AlbumDataAccess add = new AlbumDataAccess();

            add.Add(newAlbum);

            //add album and artist names to the session
            Session["AlbumName"]  = txtAlbumName.Text;
            Session["ArtistName"] = txtArtistName.Text;
            Response.Redirect("album-success.aspx");
        }
    }