private void PopulateListBox() { List <Member> memList = MemberDB.ListOfMembers(); foreach (Member M in memList) { lstMembers.Items.Add(M); } }
private void btnDelete_Click(object sender, EventArgs e) { if (lstMembers.SelectedIndex < 0) { MessageBox.Show("Choose a member to delete!"); return; } Member ToDelete = lstMembers.SelectedItem as Member; if (MemberDB.Delete(ToDelete)) { MessageBox.Show("Member has been deleted!"); lstMembers.Items.Clear(); PopulateListBox(); } }
private void btnRegister_Click(object sender, EventArgs e) { var mem = new Member(); mem.FirstName = txtFName.Text; mem.LastName = txtLName.Text; mem.FavoriteAnimal = txtFaveAnimal.Text; mem.BirthDate = dtpDate.Value; if (MemberDB.Add(mem)) { MessageBox.Show("Member added!"); } else { MessageBox.Show("Uh oh, something went wrong!" + "\nPlease try again."); } }
private void btnUpdate_Click(object sender, EventArgs e) { currMem.FirstName = txtFName.Text; currMem.LastName = txtLName.Text; currMem.BirthDate = dtpDate.Value; if (MemberDB.Update(currMem)) { MessageBox.Show("Member updated!"); this.Close(); } else { MessageBox.Show("Something went wrong..." + "\nPlease check your info."); return; } }