/// <summary> /// write each member from the list to the file /// </summary> /// <param name="members"></pn aram> public static void GetMemberships(MembershipList members) { // create the object for the input stream for a text file StreamReader inText = new StreamReader(file); try { // if the directory doesn't exist, create it if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } catch { } try { // read the data from the file and store it in the ArrayList string row; while (inText.Peek() != -1 || (row = inText.ReadLine()) != null) { row = inText.ReadLine(); string[] columns = row.Split('|'); Member member = new Member(columns[0], columns[1], columns[2]); members.Add(member); } } catch { } finally { inText.Close(); } }
private void AddButton_Click(object sender, EventArgs e) { AddMForm AddMember = new AddMForm(); Member member = AddMember.GetNewMember(); if (member != null) { members += member; } }
private void DeleteButton_Click(object sender, EventArgs e) { int MemberNum = ListBoxLabel.SelectedIndex; if (MemberNum != -1) { Member member = members[MemberNum]; string message = "Are you sure you want to delete " + member.firstName + " " + member.lastName + "?"; DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo); if (button == DialogResult.Yes) { members -= member; } } }
private void HandleChange(MembershipList members) { members.Save(); FillMemberListBox(); }