示例#1
0
        protected void GVAlbum_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = GVAlbum.Rows[index];

            int id = Convert.ToInt32(row.Cells[0].Text);

            var db = new AlbumDB();

            if (e.CommandName == "Excluir")
            {
                db.Delete(id);
                LoadGrid();
            }
            else if (e.CommandName == "Editar")
            {
                Album album = db.SelectById(id);

                TxtNomeAlbum.Text  = album.Nome;
                TxtLancamento.Text = album.Lancamento;
                TxtGravadora.Text  = album.Gravadora;
                DdlArtista.Text    = album.Artista;
                IdH.Value          = album.Id.ToString();
            }
        }
示例#2
0
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            Album album = getData();
            var   db    = new AlbumDB();

            if ((IdH.Value == "0") || (IdH.Value == ""))
            {
                if (db.Insert(album))
                {
                    LblMsg.Text = "Registro inserido!";
                    LoadGrid();
                }
                else
                {
                    LblMsg.Text = "Erro ao inserir registro";
                }
            }
            else
            {
                if (db.Update(album, int.Parse(IdH.Value)))
                {
                    LblMsg.Text = "Registro atualizado!";
                }
                else
                {
                    LblMsg.Text = "Erro ao atualizar registro";
                }
            }

            LoadGrid();
        }
示例#3
0
        public Song getSongFromTitle(string title)
        {
            var songs = AlbumDB.GetSongs();
            var song  = songs.Values.FirstOrDefault((list) => list.title == title);

            return(song);
        }
示例#4
0
        // 3. ************* EDIT NAME DETAILS ******************
        // GET: Name/Edit/3

        public IActionResult Edit(int album_id)
        {
            Album objTest = new Album();

            objTest = AlbumDB.GetAlbum(album_id);
            return(View(objTest));
        }
示例#5
0
        public Song getSong(int key)
        {
            var songs = AlbumDB.GetSongs();

            if (key + 1 > songs.Count || key - 1 < 1)
            {
                return(songs[1]);
            }
            return(songs[key]);
        }
示例#6
0
        public Song getNextSong(int key)
        {
            var songs = AlbumDB.GetSongs();

            if (key + 1 > songs.Count)
            {
                return(songs[1]);
            }
            return(songs[key + 1]);
        }
示例#7
0
        public Song getPrevSong(int key)
        {
            var songs = AlbumDB.GetSongs();

            if (key - 1 < 1)
            {
                return(songs[songs.Count]);
            }
            return(songs[key - 1]);
        }
示例#8
0
 public IActionResult Delete(int album_id, Album objTemp)
 {
     try
     {
         bool deleteFlag = AlbumDB.DeleteAlbum(objTemp);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
示例#9
0
        public IActionResult Edit(int album_id, Album objTemp)
        {
            try
            {
                bool updateFlag = AlbumDB.UpdateAlbum(objTemp);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
示例#10
0
 // public AlbumController()
 // {
 //
 /// }
 public IActionResult Index()
 {
     // 1. *************RETRIEVE ALL NAMES DETAILS ******************
     // GET: Names
     try
     {
         List <Album> albumList = new List <Album>();
         albumList = AlbumDB.GetAlbums();
         ModelState.Clear();
         return(View(albumList));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
示例#11
0
        private void updateButton_Click(object sender, RoutedEventArgs e)
        {
            IList <Artist> allArtists = ArtistRepository.GetArtists();
            IList <Genre>  allGenres  = GenreRepository.GetGenres();

            Album updatedAlbum = new Album();

            updatedAlbum.AlbumArtUrl = albumArtUrlTextBox.Text;
            updatedAlbum.AlbumId     = Int32.Parse(albumIdTextBox.Text);
            //need ArtistId
            //need GenreId
            string  bla = albumPriceTextBox.Text.Replace('.', ',');
            decimal d   = decimal.Parse(bla);

            updatedAlbum.Price = Convert.ToDecimal(d);
            updatedAlbum.Title = albumTitleTextBox.Text;

            foreach (Artist a in allArtists)
            {
                var currentArtist = (Artist)artistComboBox.SelectedItem;
                if (a.ArtistId == currentArtist.ArtistId)
                {
                    updatedAlbum.ArtistId = currentArtist.ArtistId;
                }
            }
            foreach (Genre g in allGenres)
            {
                var currentGenre = (Genre)genreComboBox.SelectedItem;
                if (g.GenreId == currentGenre.GenreId)
                {
                    updatedAlbum.GenreId = currentGenre.GenreId;
                }
            }
            bool succeeded = AlbumDB.UpdateAlbum(updatedAlbum);

            if (succeeded)
            {
                MessageBox.Show("Done.");
            }
            else
            {
                MessageBox.Show("Failed.");
            }
        }
示例#12
0
 public IActionResult Create(Album objModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (AlbumDB.AddAlbum(objModel))
             {
                 ViewBag.Message = "Album has been successfully added.";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch (Exception)
     {
         return(View());
     }
 }
示例#13
0
 public IActionResult ShowData()
 {
     // 1. *************RETRIEVE ALL NAMES DETAILS ******************
     // GET: Names
     try
     {
         List <Album> albumList = new List <Album>();
         //Name tmp1 = new Name() { ID = 1, FirstName = "Dan", LastName = "Test" };
         //Name tmp2 = new Name() { ID = 2, FirstName = "Tom", LastName = "Brady" };
         //myList.Add(tmp1);
         //myList.Add(tmp2);
         albumList = AlbumDB.GetAlbums();
         ModelState.Clear();
         return(View(albumList));
     }
     catch (Exception ex)
     {
         return(View());
         //throw;
     }
 }
示例#14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (valid())
            {
                bool flag;
                ProductAddOrEdit.AlbumID     = int.Parse(txtId.Text);
                ProductAddOrEdit.AlbumName   = txtName.Text;
                ProductAddOrEdit.ReleaseYear = int.Parse(txtYear.Text);
                ProductAddOrEdit.Quantity    = int.Parse(txtQuantity.Text);
                ProductAddOrEdit.Status      = int.Parse(txtStatus.Text);
                AlbumDB proData = new AlbumDB();

                if (addorEdit == true)
                {
                    flag = proData.AddNewProduct(ProductAddOrEdit);
                }
                else
                {
                    txtId.Enabled = false;
                    flag          = proData.UpdateProduct(ProductAddOrEdit);
                }
                if (flag == true)
                {
                    MessageBox.Show("Save Success!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Save Fail!");
                }
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AlbumSqlCe"/> class.
 /// </summary>
 public AlbumSqlCe()
 {
     albumDb          = new AlbumDB();
     albumDb.DbClient = new SqlCeClient();
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AlbumSql"/> class.
 /// </summary>
 public AlbumSql()
 {
     albumDb = new AlbumDB();
     albumDb.DbClient = new SqlServerClient();
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AlbumSqlCe"/> class.
 /// </summary>
 public AlbumSqlCe()
 {
     albumDb = new AlbumDB();
     albumDb.DbClient = new SqlCeClient();
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AlbumSql"/> class.
 /// </summary>
 public AlbumSql()
 {
     albumDb          = new AlbumDB();
     albumDb.DbClient = new SqlServerClient();
 }