protected void PlayList_Buttons_Command(Object sender, System.Web.UI.WebControls.CommandEventArgs e)
        {
            var userNameIsValid = UserNameCheck();

            if (userNameIsValid == false)
            {
                MessageUserControl.ShowInfo("", "ERROR: (PlayList_Buttons) User Name is NOT VALID");
            }
            else
            {
                switch (e.CommandName)
                {
                case ("Existing"):
                    //how do we do error handling using MessageUserControl if the
                    //   code executing is NOT part of an ODS
                    //you could use Try/Catch (BUT WE WON'T)
                    //if you examine the source code of MessageUserControl, you will
                    //  find embedded within the code the Try/Catch
                    //the syntax:
                    //  MessageUserControl.TryRun( () => {coding block});
                    //  MessageUserControl.TryRun( () => {coding block},"success title","successmessage");
                    MessageUserControl.TryRun(() => {
                        PlayListController sysmgr     = new PlayListController();
                        List <UserPlayListTrack> info = sysmgr.ListExistingPlayList
                                                            (ExistingPlayListDDL.SelectedValue);
                        MyPlayList.DataSource = info;
                        MyPlayList.DataBind();
                    }, "", "SUCCESS: PlayList Retrieved");
                    break;

                case ("New"):
                    if (string.IsNullOrEmpty(NewPlayListName.Text))
                    {
                        MessageUserControl.ShowInfo("", "ERROR: Give a new PlayList name.");
                    }
                    else
                    {
                        MessageUserControl.TryRun(() => {
                            PlayListController sysmgr = new PlayListController();
                            int id = sysmgr.AddNewPLaylist(NewPlayListName.Text, TextBoxUserName.Text);
                            ExistingPlayListDDL.DataBind();
                            ExistingPlayListDDL.SelectedValue = id.ToString();
                            MyPlayList.DataSource             = null;
                            MyPlayList.DataBind();
                        }, "", "SUCCESS: New PlayList Added");
                    }
                    break;

                case ("Save"):
                    var playListItems = GetPlayListItemsFromGridView();
                    MessageUserControl.TryRun(() => {
                        PlayListController sysmgr = new PlayListController();
                        sysmgr.SavePlayList(ExistingPlayListDDL.SelectedValue.ToInt(), playListItems);
                    }, "", "SUCCESS: PlayList Saved");
                    break;
                }
            }
        }
コード例 #2
0
 protected void PlaylistDropDown_SelectedIndexChanged(object sender, EventArgs e)
 {
     //how do we do error handling using MessageUserControl if the
     //   code executing is NOT part of an ODS
     //you could use Try/Catch (BUT WE WON'T)
     //if you examine the source code of MessageUserControl, you will
     //  find embedded within the code the Try/Catch
     //the syntax:
     //  MessageUserControl.TryRun( () => {coding block});
     //  MessageUserControl.TryRun( () => {coding block},"success title","successmessage");
     MessageUserControl.TryRun(() => {
         PlayListController sysmgr     = new PlayListController();
         List <UserPlayListTrack> info = sysmgr.ListExistingPlayList
                                             (ExistingPlayListDDL.SelectedValue);
         MyPlayList.DataSource = info;
         MyPlayList.DataBind();
         ButtonSavePlayList.Text = "Save (Playlist # " + ExistingPlayListDDL.SelectedValue + ")";
     }, "", "SUCCESS: PlayList Retrieved");
     NewPlayListName.Visible = false;
 }