Beispiel #1
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();
        }
 /// <summary>
 /// Inserts Album into the Albums Table
 /// </summary>
 /// <param name="album">A new populated album.</param>
 /// <returns>Insert Count</returns>
 public int Insert(Album album)
 {
     return(albumDb.Insert(album, "Album_Insert"));
 }
        /// <summary>
        /// Inserts Album into the Albums Table
        /// </summary>
        /// <param name="album">A new populated album.</param>
        /// <returns>Insert Count</returns>
        public int Insert(Album album)
        {
            const string sql = "INSERT INTO Album (Name, Description, UserId) VALUES (@Name, @Description, @UserId)";

            return(albumDb.Insert(album, sql));
        }