private void DeletePerson() { if (CurrentPerson != null) { people.RemoveByPredicate((Person x) => { return(x == CurrentPerson); }); var conn = new SqlConnection("server = SMSK01DB09\\DEV; " + "Trusted_Connection=yes;" + "database=TrainingDatabase; "); try { conn.Open(); var cmd = new SqlCommand("TRUNCATE TABLE FirstTable", conn); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } foreach (Person p in people) { AddToServer(p); } } CurrentPerson = null; }
private void DeletePerson() { if (CurrentPerson != null) { int index = people.RemoveByPredicate((Person x) => { return(x == CurrentPerson); }); db.deleteByIndex(new PersonDataBase() { LastName = currPerson.LastName, DateOfBirth = currPerson.DateOfBirth, Height = currPerson.Height, }, index); } CurrentPerson = null; }