diff --git a/PlanningCenter to OPS/Actions/DrawFormItems.cs b/PlanningCenter to OPS/Actions/DrawFormItems.cs index 4756f0d..6cba768 100644 --- a/PlanningCenter to OPS/Actions/DrawFormItems.cs +++ b/PlanningCenter to OPS/Actions/DrawFormItems.cs @@ -83,7 +83,7 @@ private void ComboBoxOnClose(object sender, EventArgs e) ToolTip.Hide(ComboBox); } - public void Render(Form f) + public void Render(Form f, Config config) { Label.Text = SongInfo.attributes.title; Label.TooltipText = "test"; @@ -100,7 +100,7 @@ public void Render(Form f) { ComboBox.Items.Add($"et {song.id} - {song.name}"); FoundSongs.Add($"et {song.id} - {song.name}", song); - SongTooltipInfo.Add($"et {song.id} - {song.name}", $"et{song.id}"); + SongTooltipInfo.Add($"et {song.id} - {song.name}", $"{config.et_abbreviation}{song.id}"); }; ComboBox.Items.Add("Planning center"); ComboBox.SelectedIndex = 0; diff --git a/PlanningCenter to OPS/Actions/ReadOpsDb.cs b/PlanningCenter to OPS/Actions/ReadOpsDb.cs index d53c179..c4f816a 100644 --- a/PlanningCenter to OPS/Actions/ReadOpsDb.cs +++ b/PlanningCenter to OPS/Actions/ReadOpsDb.cs @@ -14,18 +14,20 @@ internal class ReadOpsDb private static string SqlConnectionString = "Data Source=C:\\ProgramData\\Stichting Opwekking\\OPS 8\\songs.search.sqlite"; //private static string SqlConnectionString = "Data Source=C:\\Users\\zjobse\\Downloads\\songs.search.sqlite"; - public ReadOpsDb() + public ReadOpsDb(bool add_first_line = false) { using (var connection = new SqliteConnection(SqlConnectionString)) { connection.Open(); var command = connection.CreateCommand(); - command.CommandText = - @" - SELECT title - FROM song_index - "; + if (add_first_line) + { + command.CommandText = @"SELECT title, first_line FROM song_index"; + } else + { + command.CommandText = @"SELECT title FROM song_index"; + } IDictionary> song_lists = new Dictionary>(); using (var reader = command.ExecuteReader()) { @@ -42,7 +44,15 @@ FROM song_index song_lists.Add(last_item, new List()); } string song_name = string.Join(" ", unparsed_current_song.Skip(1).ToArray().SkipLast(last_item.Length)); - song_lists[last_item].Add(new Structs.Song(song_number, song_name)); + + if (add_first_line) { + string[] unparsed_first_line = reader.GetString(1).Split(' '); + string first_line = string.Join(" ", unparsed_first_line.Skip(1).ToArray().SkipLast(last_item.Length)); + song_lists[last_item].Add(new Structs.Song(song_number, song_name, first_line)); + } else + { + song_lists[last_item].Add(new Structs.Song(song_number, song_name, "")); + } } } this.books = song_lists; @@ -84,10 +94,12 @@ public void Export() IXLWorksheet worksheet = workbook.Worksheets.Add(entry.Key); worksheet.Cell(1, 1).Value = "Liednummer"; worksheet.Cell(1, 2).Value = "Titel"; + worksheet.Cell(1, 3).Value = "Eerste regel"; for (int i = 1; i < entry.Value.Count; i++) { worksheet.Cell(i + 1, 1).Value = entry.Value[i].id; worksheet.Cell(i + 1, 2).Value = entry.Value[i].name; + worksheet.Cell(i + 1, 3).Value = entry.Value[i].first_line; } } diff --git a/PlanningCenter to OPS/MainForm.cs b/PlanningCenter to OPS/MainForm.cs index 8e6f937..9a125bb 100644 --- a/PlanningCenter to OPS/MainForm.cs +++ b/PlanningCenter to OPS/MainForm.cs @@ -149,7 +149,7 @@ private void button1_Click(object sender, EventArgs e) private void ReadSongs_Click(object sender, EventArgs e) { - ReadOpsDb db_reader = new ReadOpsDb(); + ReadOpsDb db_reader = new ReadOpsDb(true); db_reader.Export(); } diff --git a/PlanningCenter to OPS/SelectSongs.cs b/PlanningCenter to OPS/SelectSongs.cs index 2528842..83b5869 100644 --- a/PlanningCenter to OPS/SelectSongs.cs +++ b/PlanningCenter to OPS/SelectSongs.cs @@ -69,7 +69,7 @@ private void SelectSongs_Load(object sender, EventArgs e) { song_element = new DrawFormItems(this.Config, x, "", ""); } - song_element.Render(this); + song_element.Render(this, this.Config); this.SongDropdowns.Add(song_element); } else { diff --git a/PlanningCenter to OPS/Structs/OpsSongs.cs b/PlanningCenter to OPS/Structs/OpsSongs.cs index eea2e47..2ed70d7 100644 --- a/PlanningCenter to OPS/Structs/OpsSongs.cs +++ b/PlanningCenter to OPS/Structs/OpsSongs.cs @@ -6,11 +6,13 @@ internal class Song { public int id { get; set; } public string name { get; set; } + public string first_line { get; set; } - public Song (int id, string name) + public Song (int id, string name, string first_line) { this.id = id; this.name = name; + this.first_line = first_line; } }