Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Validate(txtAlbumTitle.Text) && Validate(txtLength.Text) && Validate(txtYear.Text) && Validate(artistsComboBox.Text) && Validate(pictureBoxPhoto.ImageLocation))
            {
                album.AlbumTitle = txtAlbumTitle.Text;
                album.ArtistName = artistsComboBox.Text;
                album.Year       = Convert.ToInt32(txtYear.Text);
                album.Length     = Convert.ToInt32(txtLength.Text);
                album.Cover      = ConvertFileToByte(this.pictureBoxPhoto.ImageLocation);



                int tempNum;
                if (album.AlbumId == 0)
                {
                    tempNum = MusicLibraryOperation.createOperation(TYPE.ALBUM).Add(album);
                }
                else
                {
                    tempNum = MusicLibraryOperation.createOperation(TYPE.ALBUM).Update(album);
                }

                if (tempNum > 0)
                {
                    Message.show("Submitted successfully.", MESSAGE_TYPE.SUCCESS);
                }
                else
                {
                    Message.show("Submission Failed.", MESSAGE_TYPE.FAILURE);
                }
                Clear();
                PopulateDataGridView();
            }
        }
Ejemplo n.º 2
0
        private void btnsaveGenre_Click(object sender, EventArgs e)
        {
            genre.Type = txtType.Text.Trim();
            if (Validate(txtType.Text))
            {
                int tempNum;
                if (genre.GenreId == 0)
                {
                    tempNum = MusicLibraryOperation.createOperation(TYPE.GENRE).Add(genre);
                }
                else
                {
                    tempNum = MusicLibraryOperation.createOperation(TYPE.GENRE).Update(genre);
                }

                if (tempNum > 0)
                {
                    Message.show("Submitted successfully.", MESSAGE_TYPE.SUCCESS);
                }
                else
                {
                    Message.show("Submission Failed.", MESSAGE_TYPE.FAILURE);
                }
                Clear();
                PopulateGenreList();
            }
        }
Ejemplo n.º 3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren(ValidationConstraints.Enabled))
            {
                return;
            }

            artist.FirstName = textBoxFirstName.Text;
            artist.LastName  = textBoxLastName.Text;
            artist.Age       = Convert.ToInt32(textBoxAge.Text);

            int tempNum;

            if (artist.ArtistId == 0)
            {
                tempNum = MusicLibraryOperation.createOperation(TYPE.ARTIST).Add(artist);
            }
            else
            {
                tempNum = MusicLibraryOperation.createOperation(TYPE.ARTIST).Update(artist);
            }

            if (tempNum > 0)
            {
                Message.show("Submitted successfully.", MESSAGE_TYPE.SUCCESS);
            }
            else
            {
                Message.show("Submission Failed.", MESSAGE_TYPE.FAILURE);
            }
            Clear();
            PopulateDataGridView();
        }
Ejemplo n.º 4
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (Message.show("Are you sure you want to delete?", MESSAGE_TYPE.ADVISORY) == DialogResult.Yes)
     {
         int tempNum = MusicLibraryOperation.createOperation(TYPE.ALBUM).Delete(album);
         if (tempNum > 0)
         {
             Message.show("Deleted successfully.", MESSAGE_TYPE.SUCCESS);
         }
         else
         {
             Message.show("Failed to delete.", MESSAGE_TYPE.FAILURE);
         }
         PopulateDataGridView();
         Clear();
     }
 }
Ejemplo n.º 5
0
        private void genreDataGridView_DoubleClick(object sender, EventArgs e)
        {
            if (genreDataGridView.CurrentRow.Index != 1)
            {
                int tempNum = Convert.ToInt32(genreDataGridView.CurrentRow.Cells["GenreId"].Value);

                genre = (Genre)MusicLibraryOperation.createOperation(TYPE.GENRE).Get(tempNum);
                if (genre == null)
                {
                    Message.show("Could not find this information.", MESSAGE_TYPE.FAILURE);
                    return;
                }
                txtType.Text           = genre.Type;
                btnsaveGenre.Text      = "Update";
                btnDeleteGenre.Enabled = true;
            }
        }
Ejemplo n.º 6
0
 private void dataGridViewArtist_DoubleClick(object sender, EventArgs e)
 {
     if (dataGridViewArtist.CurrentRow.Index != -1)
     {
         int tempNum = Convert.ToInt32(dataGridViewArtist.CurrentRow.Cells["artistIdDataGridViewTextBoxColumn"].Value);
         artist = (Artist)MusicLibraryOperation.createOperation(TYPE.ARTIST).Get(tempNum);
         if (artist == null)
         {
             Message.show("Could not find this information.", MESSAGE_TYPE.FAILURE);
             return;
         }
         textBoxFirstName.Text = artist.FirstName;
         textBoxLastName.Text  = artist.LastName;
         textBoxAge.Text       = Convert.ToString(artist.Age);
         buttonSave.Text       = "Update";
         buttonDelete.Enabled  = true;
     }
 }
Ejemplo n.º 7
0
 private void dataGridView1_DoubleClick(object sender, EventArgs e)
 {
     if (dvgAlbum.CurrentRow.Index != -1)
     {
         int tempNum = Convert.ToInt32(dvgAlbum.CurrentRow.Cells["albumIdDataGridViewTextBoxColumn"].Value);
         album = (Album)MusicLibraryOperation.createOperation(TYPE.ALBUM).Get(tempNum);
         if (album == null)
         {
             Message.show("Could not find this information.", MESSAGE_TYPE.FAILURE);
             return;
         }
         txtAlbumTitle.Text   = album.AlbumTitle;
         artistsComboBox.Text = album.ArtistName;
         txtYear.Text         = Convert.ToString(album.Year);
         txtLength.Text       = Convert.ToString(album.Length);
         var img = new MemoryStream(album.Cover);
         pictureBoxPhoto.Image = Image.FromStream(img);
         btnSave.Text          = "Update";
         btnDelete.Enabled     = true;
     }
 }
Ejemplo n.º 8
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (!ValidateChildren(ValidationConstraints.Enabled))
            {
                return;
            }

            if (Message.show("Are you sure you want to delete?", MESSAGE_TYPE.ADVISORY) == DialogResult.Yes)
            {
                int tempNum = MusicLibraryOperation.createOperation(TYPE.ARTIST).Delete(artist);
                if (tempNum > 0)
                {
                    Message.show("Deleted successfully.", MESSAGE_TYPE.SUCCESS);
                }
                else
                {
                    Message.show("Failed to delete.", MESSAGE_TYPE.FAILURE);
                }
                PopulateDataGridView();
                Clear();
            }
        }