示例#1
0
 protected void Remove_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
         {
             MessageUserControl.TryRun(() =>
             {
                 AlbumController sysmgr = new AlbumController();
                 int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                 EditAlbumID.Text       = albumid.ToString();
                 if (rowsaffected > 0)
                 {
                     AlbumList.DataBind();
                     EditAlbumID.Text = "";
                 }
                 else
                 {
                     throw new Exception("Album was not found. Remove again again");
                 }
             }, "Successful", "Album Removed");
         }
     }
 }
        protected void Remove_Click(object sender, EventArgs e)
        {
            int    editablumid = 0;
            string albumid     = EditAlbumID.Text;

            if (string.IsNullOrEmpty(albumid))
            {
                MessageUserControl.ShowInfo("Select the album before deleting");
            }
            else if (!int.TryParse(albumid, out editablumid))
            {
                MessageUserControl.ShowInfo("failed", "invalid album id");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsAffected       = sysmgr.Album_Delete(editablumid);
                    EditAlbumID.Text       = rowsAffected.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind();
                        ClearControls();
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and update again.");
                    }
                }, "Successful", "Album Removed");
            }
        }
示例#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");
         }
     }
 }
        protected void Remove_Click(object sender, EventArgs e)
        {
            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
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController controller = new AlbumController();
                    int rows = controller.Album_Delete(albumID);

                    if (rows > 0)
                    {
                        AlbumList.DataBind();
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        throw new Exception("No album found. Try again.");
                    }
                }, "Sucessful!", "Album deleted.");
            }
        }
示例#5
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");
     }
 }
示例#6
0
 protected void Remove_Click(object sender, EventArgs e)
 {
     //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("Removing", "Search for an exsiting album before removing");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             int rowsaffected       = sysmgr.Album_Delete(int.Parse(EditAlbumID.Text));
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 EditAlbumID.Text = "";
                 AlbumList.DataBind();
             }
         }, "Remove", "Action successful");
     }
 }
示例#7
0
 protected void Search_Click(object sender, EventArgs e)
 {
     AlbumID.Text             = "";
     AlbumTitle.Text          = "";
     AlbumReleaseYear.Text    = "";
     AlbumReleaseLabel.Text   = "";
     ArtistList.SelectedIndex = 0;
     if (string.IsNullOrEmpty(SearchArg.Text))
     {
         MessageUserControl1.ShowInfo("Enter an album title or part of the title.");
     }
     else
     {
         MessageUserControl1.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
             if (albumlist.Count == 0)
             {
                 MessageUserControl1.ShowInfo("Search Result", "No data for album title or partial title " + SearchArg.Text);
                 AlbumList.DataSource = null;
                 AlbumList.DataBind();
             }
             else
             {
                 MessageUserControl1.ShowInfo("Search Result", "Select the desired album for maintanence");
                 AlbumList.DataSource = albumlist;
                 AlbumList.DataBind();
             }
         });
     }
 }
示例#8
0
 protected void Remove_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(EditAlbumID.Text))
     {
         MessageUserControl.ShowInfo("Removing", "Search for an exsiting album before removing");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             int rowsaffected       = sysmgr.Album_Delete(int.Parse(EditAlbumID.Text));
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 EditAlbumID.Text = "";
                 AlbumList.DataBind();
                 ClearControls();
             }
         }, "Remove", "Action successful");
     }
 }
示例#9
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            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
            {
                messageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind(); //re-executes the ods for the album list
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        messageUserControl.ShowInfo("Hello, I am a title", "You monster!");
                    }
                }, "Successful", "Album removed, you monster!");
            }
        }
        protected void Remove_Click(object sender, EventArgs e)
        {
            // physical delete
            int    editalbumid = 0;
            string albumid     = EditAlbumID.Text;

            if (string.IsNullOrEmpty(albumid))                                                 // if there is no album selected to edit
            {
                MessageUserControl.ShowInfo("Attention", "Look up the album before deleting"); // "Title", "Message"
            }
            else if (!int.TryParse(albumid, out editalbumid))                                  // if albumid is not a number
            {
                MessageUserControl.ShowInfo("Attention", "Current albumid is invalid");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();

                    int rowsaffected = sysmgr.Album_Delete(editalbumid);

                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind();
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and remove again.");
                    }
                }, "Successful", "Album Physically Deleted");
            }
        }
        protected void Remove_Click(object sender, EventArgs e)
        {
            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
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind(); //Re-execute the ODS for the Album List
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and delete again.");
                    }
                }, "Successful", "Album deleted");
            }
        }
示例#12
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");
            }
        }
示例#13
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.");
            }
        }
示例#14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DB.setDBPath(Page.Server.MapPath("/App_Data/UserCenter.accdb"));//设置数据库路径

            if (!IsPostBack)
            {
                if (Session["UserName"] != null)
                {
                    OleDbConnection myconn = DB.createConnection();
                    myconn.Open();
                    string           selectStr = "select * from Album";
                    OleDbDataAdapter oda       = new OleDbDataAdapter(selectStr, myconn);
                    DataSet          ds        = new DataSet();
                    oda.Fill(ds);
                    AlbumList.DataSource = ds;
                    AlbumList.DataBind();

                    myconn.Close();
                }
                else
                {
                    AlbumLabel.Text    = "请先登录";
                    AlbumLabel.Visible = true;
                }
            }
        }
        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");
            }
        }
示例#16
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.");
                }
            }
        }
示例#17
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");
                }
            }
        }
    protected void Search_Click(object sender, EventArgs e)
    {
        //clear out the old album information on the Maintain tab
        Clear_Click(sender, e);

        if (string.IsNullOrEmpty(SearchArg.Text))
        {
            //(message string)
            MessageUserControl1.ShowInfo("Enter an album title or part of the title.");
        }
        else
        {
            //do a look of the data in the db via the controller
            //all actions that are external to the webpage should be done in a try/catch
            //   for friendly error handling
            //we will use MessageUserControl to handle the error messages for this semester
            MessageUserControl1.TryRun(() =>
            {
                //coding block I wish MessageUserControl to try and run checking for
                //any errors, catching the errors, and displaying said error(s) for me
                //in its error panel
                //what is leave for me to do: simply the logic for the event

                //standard lookup
                AlbumController sysmgr = new AlbumController();
                List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
                if (albumlist.Count == 0)
                {
                    //(title string, message string)
                    MessageUserControl1.ShowInfo("Search Result",
                                                 "No data for album title or partial tile " + SearchArg.Text);
                    AlbumList.DataSource = null;
                    AlbumList.DataBind();
                }
                else
                {
                    MessageUserControl1.ShowInfo("Search Result",
                                                 "Select the desired album for maintenance.");
                    AlbumList.DataSource = albumlist;
                    AlbumList.DataBind();
                }
            });
        }
    }
示例#19
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");
         }
     }
 }
示例#20
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 Search_Click(object sender, EventArgs e)
    {
        //Clear out the old album information on the maintain tab.
        Clear_Click(sender, e);
        if (string.IsNullOrEmpty(SearchArg.Text))
        {
            MessageUserControl1.ShowInfo("Please Enter an Album Title or part of the title");
        }
        else
        {
            //Lookup of the data in the database.We are the controller all actions all the external to the
            //web page should be done through a try catch. From a friendly error handling.
            //We will use the mesageusercotrol to handle error messages for this semester.
            MessageUserControl1.TryRun(() =>
            {
                //Coding block I wish message user control to try and run and check the checking for
                //any errors catching the errors and displaying set errors sfor me in its error panel.
                //What is left for me to do is simply the logicc for me to do the event.

                //This is a standard lookup
                AlbumController sysmgr = new AlbumController();
                List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
                if (albumlist.Count == 0)
                {
                    //Title String,message string
                    MessageUserControl.ShowInfo("Search Result",
                                                "No data for the album title or the partial title  " + SearchArg.Text);
                    AlbumList.DataSource = null;
                    AlbumList.DataBind();
                }
                else
                {
                    MessageUserControl.ShowInfo("Using Instructions",
                                                "Select the desired album for the maintenece.");
                    AlbumList.DataSource = albumlist;
                    AlbumList.DataBind();
                }
            }
                                       );
        }
    }
示例#22
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)
            {
                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");
                }
            }
        }
        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");
                }
            }
        }
示例#25
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");
     }
 }