コード例 #1
0
    /// <summary>
    /// this is for the 'create song' button and creates a new song.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Create_NewSong_Click(object sender, EventArgs e)
    {
        try
        {
            string name       = EditingSongName.Text;
            int    filetypeID = int.Parse(EditingFiletypeDDL.SelectedValue);

            if (string.IsNullOrEmpty(name.Trim()))
            {
                Message.Text += "plaes specify a name, song name is required. ";
            }
            if (filetypeID == 0)
            {
                Message.Text += "please select a filetype, a filetype is required. ";
            }

            //there has been no error so far, allow it to process the request
            if (String.IsNullOrEmpty(Message.Text.Trim()))
            {
                SongController sc    = new SongController();
                int            newID = sc.CreateSong(name, filetypeID);
                EditingSongID.Text = newID.ToString();
                LoadEditData();
                Message.Text = "'" + name + "' has been sucessfuly added as No " + newID;
            }
        }
        catch (Exception ex)
        {
            Message.Text = GetInerException(ex).Message;
        }
    }