protected void Add_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string albumtitle = EditTitle.Text;
                int    albumyear  = int.Parse(EditReleaseYear.Text);
                string albumlabel = EditReleaseLabel.Text == "" ?
                                    null : EditReleaseLabel.Text;
                int albumartist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album theAlbum = new Album();
                theAlbum.Title        = albumtitle;
                theAlbum.ArtistId     = albumartist;
                theAlbum.ReleaseYear  = albumyear;
                theAlbum.ReleaseLabel = albumlabel;

                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int albumid            = sysmgr.Album_Add(theAlbum);
                    EditAlbumID.Text       = albumid.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind(); //Re-execute the ODS for the Album List
                    }
                }, "Successful", "Album added");
            }
        }
Exemplo n.º 2
0
        protected void Add_Click(object sender, EventArgs e)
        {
            //Check validation and additional validation within the code behind.
            //Load up the entity
            if (Page.IsValid)
            {
                string albumtitle  = EditTitle.Text;
                int    albumyear   = int.Parse(EditReleaseYear.Text);
                string albumlabel  = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                int    albumartist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album theAlbum = new Album();
                //brings in values to the webpage
                theAlbum.Title        = albumtitle;
                theAlbum.ArtistId     = albumartist;
                theAlbum.ReleaseYear  = albumyear;
                theAlbum.ReleaseLabel = albumlabel;

                messageUserControl.TryRun(() => {
                    AlbumController sysmgr = new AlbumController();
                    int albumid            = sysmgr.Album_Add(theAlbum);
                    EditAlbumID.Text       = albumid.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind(); //re-executes the ods for the album list
                    }
                }, "Successful", "Album added");
            }
        }
Exemplo n.º 3
0
 protected void Add_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         //the validation that exists within the event is probably validation that
         //   a) is not possible on the form
         //   b) required for specific events only
         //   c) for some reason, it was decided to the validation in code-behind
         if (int.Parse(EditReleaseYear.Text) >= 1950 &&
             int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
         {
             MessageUserControl.TryRun(() =>
             {
                 Album item               = new Album();
                 item.Title               = EditTitle.Text;
                 item.ReleaseYear         = int.Parse(EditReleaseYear.Text);
                 item.ReleaseLabel        = string.IsNullOrEmpty(EditReleaseLabel.Text) ? null : EditReleaseLabel.Text;
                 item.ArtistId            = int.Parse(EditAlbumArtistList.SelectedValue);
                 AlbumController sysmgr   = new AlbumController();
                 int newalbumid           = sysmgr.Album_Add(item);
                 EditAlbumID.Text         = newalbumid.ToString();
                 ArtistList.SelectedValue = item.ArtistId.ToString();
                 AlbumList.DataBind();
             });
         }
         else
         {
             MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
         }
     }
 }
Exemplo n.º 4
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string title  = EditTitle.Text;
                int    year   = int.Parse(EditReleaseYear.Text);
                string label  = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                int    artist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album newAlbum = new Album();
                newAlbum.ArtistId     = artist;
                newAlbum.Title        = title;
                newAlbum.ReleaseYear  = year;
                newAlbum.ReleaseLabel = label;

                MessageUserControl.TryRun(() =>
                {
                    AlbumController controller = new AlbumController();
                    int albumID      = controller.Album_Add(newAlbum);
                    EditAlbumID.Text = albumID.ToString(); //redoes ODS controls
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind();
                    }
                }, "Sucessful!", "Album added to file.");
            }
        }
Exemplo n.º 5
0
 protected void Add_Click(object sender, EventArgs e)
 {
     if (int.Parse(EditReleaseYear.Text) >= 1950 &&
         int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
     {
         MessageUserControl.TryRun(() =>
         {
             Album item               = new Album();
             item.Title               = EditTitle.Text;
             item.ReleaseYear         = int.Parse(EditReleaseYear.Text);
             item.ReleaseLabel        = string.IsNullOrEmpty(EditReleaseLabel.Text) ? null : EditReleaseLabel.Text;
             item.ArtistId            = int.Parse(EditAlbumArtistList.SelectedValue);
             AlbumController sysmgr   = new AlbumController();
             int newalbumid           = sysmgr.Album_Add(item);
             EditAlbumID.Text         = newalbumid.ToString();
             ArtistList.SelectedValue = item.ArtistId.ToString();
             AlbumList.DataBind();
         });
     }
     else
     {
         MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
     }
 }