Пример #1
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(EditAlbumID.Text))
     {
         MessageUserControl.ShowInfo("Updating", "Search for an exsiting album before updating");
     }
     else if (int.Parse(EditReleaseYear.Text) >= 1950 &&
              int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
     {
         MessageUserControl.TryRun(() =>
         {
             Album item             = new Album();
             item.AlbumId           = int.Parse(EditAlbumID.Text);
             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 rowsaffected       = sysmgr.Album_Update(item);
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 ArtistList.SelectedValue = item.ArtistId.ToString();
                 AlbumList.DataBind();
             }
         }, "Update", "Action successful");
     }
     else
     {
         MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
     }
 }
Пример #2
0
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string editID  = EditAlbumID.Text;
                int    albumID = 0;
                if (string.IsNullOrEmpty(editID))
                {
                    MessageUserControl.ShowInfo("Error", "Must have album to edit.");
                }
                else if (!int.TryParse(editID, out albumID))
                {
                    MessageUserControl.ShowInfo("Error", "Invalid album ID");
                }
                else
                {
                    string title       = EditTitle.Text;
                    int    year        = int.Parse(EditReleaseYear.Text);
                    string label       = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                    int    artist      = int.Parse(EditAlbumArtistList.SelectedValue);
                    int    editAlbumID = int.Parse(EditAlbumID.Text);

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

                    MessageUserControl.TryRun(() =>
                    {
                        AlbumController controller = new AlbumController();
                        int rows = controller.Album_Update(newAlbum);

                        if (rows > 0)
                        {
                            AlbumList.DataBind();
                        }
                        else
                        {
                            throw new Exception("No album found. Try again.");
                        }
                    }, "Sucessful!", "Album updated.");
                }
            }
        }
Пример #3
0
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int    editalbumid = 0;
                string albumid     = EditAlbumID.Text;
                if (string.IsNullOrEmpty(albumid))
                {
                    MessageUserControl.ShowInfo("Attention", "Look up the album before editing");
                }
                else if (int.TryParse(albumid, out editalbumid))
                {
                    MessageUserControl.ShowInfo("Attention", "Current Album ID is Invalid, Look Again!");
                }
                else
                {
                    //string albumtitle =
                    //int albumyear =
                    //string albumlabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                    //int albumartist = int.Parse(EditAlbumArtistList.SelectedValue);

                    Album theAlbum = new Album();
                    theAlbum.AlbumId      = editalbumid;
                    theAlbum.Title        = EditTitle.Text;
                    theAlbum.ArtistId     = int.Parse(EditAlbumArtistList.SelectedValue);
                    theAlbum.ReleaseYear  = int.Parse(EditReleaseYear.Text);
                    theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;

                    MessageUserControl.TryRun(() =>
                    {
                        AlbumController sysmgr = new AlbumController();
                        int rowsaffected       = sysmgr.Album_Update(theAlbum);
                        EditAlbumID.Text       = albumid.ToString();
                        if (rowsaffected > 0)
                        {
                            AlbumList.DataBind();
                        }
                        else
                        {
                            throw new Exception("Album was not found. Look up again");
                        }
                    }, "Successful", "Album Updated");
                }
            }
        }
Пример #4
0
 protected void Update_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 (string.IsNullOrEmpty(EditAlbumID.Text))
         {
             MessageUserControl.ShowInfo("Updating", "Search for an exsiting album before updating");
         }
         else if (int.Parse(EditReleaseYear.Text) >= 1950 &&
                  int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
         {
             MessageUserControl.TryRun(() =>
             {
                 Album item             = new Album();
                 item.AlbumId           = int.Parse(EditAlbumID.Text);
                 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 rowsaffected       = sysmgr.Album_Update(item);
                 if (rowsaffected == 0)
                 {
                     throw new Exception("Album no longer on file. Refresh your search.");
                 }
                 else
                 {
                     ArtistList.SelectedValue = item.ArtistId.ToString();
                     AlbumList.DataBind();
                 }
             }, "Update", "Action successful");
         }
         else
         {
             MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
         }
     }
 }
Пример #5
0
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int    editalbumid = 0;
                string albumid     = EditAlbumID.Text;
                if (string.IsNullOrEmpty(albumid))
                {
                    MessageUserControl.ShowInfo("Uh-oh!", "Look up the album before editing. Duh.");
                }
                else if (!int.TryParse(albumid, out editalbumid))
                {
                    MessageUserControl.ShowInfo("Attencion!", "Current album id is invalid. Perform look up again.");
                }
                else
                {
                    //now put them inside an instance.
                    Album theAlbum = new Album();
                    theAlbum.AlbumId      = editalbumid;
                    theAlbum.Title        = EditTitle.Text;
                    theAlbum.ArtistId     = int.Parse(EditAlbumArtistList.SelectedValue);
                    theAlbum.ReleaseYear  = int.Parse(EditReleaseYear.Text);
                    theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;

                    MessageUserControl.TryRun(() =>
                    {
                        AlbumController sysmgr = new AlbumController();
                        int rowsaffected       = sysmgr.Album_Update(theAlbum);
                        EditAlbumID.Text       = albumid.ToString();
                        if (rowsaffected > 0)
                        {
                            AlbumList.DataBind(); // reexecute the ODS for my albumlist.
                        }
                        else
                        {
                            throw new Exception("Album was not found. Repeat look up and update again.");
                        }
                    }, "Successful", "Album Updated");
                }
            }
        }
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int    editablumid = 0;
                string albumid     = EditAlbumID.Text;
                if (string.IsNullOrEmpty(albumid))
                {
                    MessageUserControl.ShowInfo("Select the album before editing");
                }
                else if (!int.TryParse(albumid, out editablumid))
                {
                    MessageUserControl.ShowInfo("failed", "invalid album id");
                }
                else
                {
                    Album theAlbum = new Album();
                    theAlbum.AlbumId      = editablumid;
                    theAlbum.Title        = EditTitle.Text;
                    theAlbum.ArtistId     = int.Parse(EditAlbumArtistList.SelectedValue);
                    theAlbum.ReleaseYear  = int.Parse(EditReleaseYear.Text);
                    theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;

                    MessageUserControl.TryRun(() =>
                    {
                        AlbumController sysmgr = new AlbumController();
                        int rowsAffected       = sysmgr.Album_Update(theAlbum);
                        EditAlbumID.Text       = rowsAffected.ToString();
                        if (AlbumList.Rows.Count > 0)
                        {
                            AlbumList.DataBind();
                        }
                        else
                        {
                            throw new Exception("Album was not found. Repeat lookup and update again.");
                        }
                    }, "Successful", "Album Updated");
                }
            }
        }
Пример #7
0
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int    editalbumid = 0;
                string albumid     = EditAlbumID.Text;
                if (string.IsNullOrEmpty(albumid))
                {
                    messageUserControl.ShowInfo("Attention, Actung! Arrividarchi!", "Lookup the album before editing, please.");
                }
                else if (!int.TryParse(albumid, out editalbumid))
                {
                    throw new Exception("Current albumid is invalid. Perform lookup again, please.");
                }
                else
                {
                    Album theAlbum = new Album();
                    //brings in values to the webpage
                    theAlbum.AlbumId      = editalbumid;
                    theAlbum.Title        = EditTitle.Text;
                    theAlbum.ArtistId     = int.Parse(EditAlbumArtistList.SelectedValue);
                    theAlbum.ReleaseYear  = int.Parse(EditReleaseYear.Text);
                    theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;

                    messageUserControl.TryRun(() =>
                    {
                        AlbumController sysmgr = new AlbumController();
                        int rowsaffected       = sysmgr.Album_Update(theAlbum);
                        if (rowsaffected > 0)
                        {
                            AlbumList.DataBind(); //re-executes the ods for the album list
                        }
                        else
                        {
                            messageUserControl.ShowInfo("Hello, I am title", "Album was not found. Repeat lookup and update again.");
                        }
                    }, "Successful", "Album added");
                }
            }
        }
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string albumid     = EditAlbumID.Text;
                int    editalbumid = 0;
                if (string.IsNullOrEmpty(albumid))
                {
                    MessageUserControl.ShowInfo("Attention", "Lookup the album before editing, idiot");
                }
                else if (!int.TryParse(albumid, out editalbumid))
                {
                    MessageUserControl.ShowInfo("Attention", "Current AlbumID is invalid, idiot");
                }
                else
                {
                    Album theAlbum = new Album();
                    theAlbum.AlbumId      = editalbumid; //include pkey
                    theAlbum.Title        = EditTitle.Text;
                    theAlbum.ArtistId     = int.Parse(EditAlbumArtistList.SelectedValue);
                    theAlbum.ReleaseYear  = int.Parse(EditReleaseYear.Text);
                    theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;

                    MessageUserControl.TryRun(() =>
                    {
                        AlbumController sysmgr = new AlbumController();
                        int rowsaffected       = sysmgr.Album_Update(theAlbum);
                        if (rowsaffected > 0)
                        {
                            AlbumList.DataBind(); //Re-execute the ODS for the Album List
                        }
                        else
                        {
                            throw new Exception("Album was not found. Repeat lookup and update again.");
                        }
                    }, "Successful", "Album updated");
                }
            }
        }