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> /// Updates the Album table by the primary key, if the Album is dirty then an update will occur /// </summary> /// <param name="album">a populated album</param> /// <returns>update count</returns> public int Update(Album album) { return(albumDb.Update(album, "Album_Update")); }
/// <summary> /// Updates the Album table by the primary key, if the Album is dirty then an update will occur /// </summary> /// <param name="album">a populated album</param> /// <returns>update count</returns> public int Update(Album album) { const string sql = "Update Album SET Name = @Name, Description = @Description, UserId = @UserId Where AlbumID = @AlbumID"; return(albumDb.Update(album, sql)); }