/// <summary> /// Search button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bttnSearch_Click_1(object sender, EventArgs e) { string name = txtBoxSearch.Text; MembershipForm frmMemb = new MembershipForm("Edit Searched Member"); Membership member = new Membership(); int index = listBoxMembers.SelectedIndex; if (string.IsNullOrEmpty(name)) { MessageBox.Show("Enter the full name of a current customer", "Error", MessageBoxButtons.OK); } else { if (listBoxMembers.Items.Count > 0) { if (membMngr.SearchMember(name) != null && name.Equals(membMngr.SearchMember(name).MemberData.CompleteName)) { frmMemb.MemberData = membMngr.SearchMember(name).MemberData; frmMemb.ShowDialog(); txtBoxSearch.Text = string.Empty; } else { MessageBox.Show("Member not found", "Error", MessageBoxButtons.OK); } } else if (listBoxMembers.Items.Count == 0) { MessageBox.Show("You have no members!", "Error", MessageBoxButtons.OK); } } HideMenus(); }
/// <summary> /// Button for adding member /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bttnAdd_Click_1(object sender, EventArgs e) { MembershipForm frmMemb = new MembershipForm("Add New Member"); if (frmMemb.ShowDialog() == DialogResult.OK) { membMngr.AddMember(frmMemb.MemberData); UpdateGUI(); } HideMenus(); }
/// <summary> /// Button for editing member /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bttnEdit_Click_1(object sender, EventArgs e) { MembershipForm frmMemb = new MembershipForm("Edit Member"); int index = listBoxMembers.SelectedIndex; if (listBoxMembers.SelectedItems.Count != 1) { MessageBox.Show("Please select a member from the list to edit", "Error", MessageBoxButtons.OK); return; } if (index >= 0) { frmMemb.MemberData = membMngr.GetMember(index).MemberData; frmMemb.ShowDialog(); membMngr.ChangeMember(frmMemb.MemberData, index); UpdateGUI(); } HideMenus(); }