/* Load all the address book entries from the save file. */ private void LoadEntriesFromSaveFile() { StreamReader streamReader = new StreamReader(SAVE_FILE_PATH); string line = ""; while ((line = streamReader.ReadLine()) != null) { AddressBookEntry entry = new AddressBookEntry(line); entries.Add(entry); } streamReader.Close(); }
/* Save an address book entry with the given information. */ private void SparaAdress(string namn, string gatuadress, string postnummer, string postort, string telefon, string epost) { if (entryBeingEdited != null) { entries.Remove(entryBeingEdited); entryBeingEdited = null; } AddressBookEntry entry = new AddressBookEntry(namn, gatuadress, postnummer, postort, telefon, epost); entries.Add(entry); SaveEntriesToSaveFile(); PopulateListBox(); ClearInformationTextBoxes(); }
private void buttonEdit_Click(object sender, EventArgs e) { string selected = (string)listBoxEntries.SelectedItem; if (selected == null) { return; } // Don't allow editing if no entry is selected. entryBeingEdited = FindEntryByString(selected); textBoxNamn.Text = entryBeingEdited.Namn; textBoxGatuadress.Text = entryBeingEdited.Gatuadress; textBoxPostnummer.Text = entryBeingEdited.Postnummer; textBoxPostort.Text = entryBeingEdited.Postort; textBoxTelefon.Text = entryBeingEdited.Telefon; textBoxEpost.Text = entryBeingEdited.Epost; }
private void buttonNew_Click(object sender, EventArgs e) { entryBeingEdited = null; ClearInformationTextBoxes(); }