Beispiel #1
0
        private void PopulateListBox()
        {
            List <Member> memList = MemberDB.ListOfMembers();

            foreach (Member M in memList)
            {
                lstMembers.Items.Add(M);
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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;
            }
        }