public static void DeleteClub(ClubModel clubs) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute($"DELETE FROM vereniging WHERE Id = @Id", clubs); } }
public static void UpdateClub(ClubModel clubs) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute($"UPDATE vereniging SET Naam = @Naam WHERE Id = @Id", clubs); } }
public static void SaveClub(ClubModel clubs) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute($"INSERT INTO vereniging (Naam) VALUES (@Naam)", clubs); } }
private void CreateNewClub() { ClubModel clubModel = new ClubModel(); clubModel.Naam = "Naam vereniging"; SqliteDataAccess.SaveClub(clubModel); SetClubList(); lstClub.Refresh(); GenFunction.SetLvEditAfterNew(lstClub); }
private void LstClub_AfterLabelEdit(object sender, LabelEditEventArgs e) { ListView lst = sender as ListView; if (lst.SelectedItems.Count == 0) { return; } if (e.Label == null) { return; } ListViewItem item = lst.SelectedItems[0]; ClubModel clubModel = new ClubModel(); clubModel.Id = Int32.Parse(item.Tag.ToString()); clubModel.Naam = e.Label.ToString(); SqliteDataAccess.UpdateClub(clubModel); SetClubList(); }
private void BtnDelete_Click(object sender, EventArgs e) { ListView lst = lstClub; int index = GenFunction.GetLvIndex(lst); if (index == -1) { return; } ListView lstMem = lstMember; if (lstMember.Items.Count > 0) { MessageBox.Show("Kan vereniging niet verwijderen\nVerwijder eerste de leden", "Vereniging - Leden", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var result = MessageBox.Show("Vereniging verwijderen?\nDit kan niet ongedaan gemaakt worden!", "Vereniging - Leden", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } // ListView lst = lstClub; // int index = GenFunction.GetLvIndex(lst); if (lst.SelectedItems.Count == 0) { return; } //#if DEBUG == false // var result = MessageBox.Show("Vereniging verwijderen?\nDit kan niet ongedaan gemaakt worden!", "Vereniging - Leden", // MessageBoxButtons.YesNo, // MessageBoxIcon.Question); // if(result == DialogResult.No) // { // return; // } //#endif ListViewItem item = lst.SelectedItems[0]; ClubModel clubModel = new ClubModel(); clubModel.Id = Int32.Parse(item.Tag.ToString()); clubModel.Naam = item.Text; SqliteDataAccess.DeleteClub(clubModel); lst.Items[GenFunction.GetLvIndex(lst)].Remove(); GenFunction.GetLvPervIndexAfterDelete(lst, index); // SetClubList(); // GenFunction.SetLvLastItem(lstClub); // int lastItem = lstClub.Items.Count - 1; // lstClub.Items[lastItem].Selected = true; // lstClub.Select(); // lstClub.EnsureVisible(lastItem); }