private void btnNew_Click(object sender, EventArgs e) { // Try to add a new phone number to the list try { PhoneForm frm = new PhoneForm("", ""); if (frm.ShowDialog() == DialogResult.OK) { app.NewPhone(frm.NewPhone); this.lstNames.Items.Add(frm.NewPhone); this.lstNames.SelectedIndex = 0; change = true; app.Modified(); phones = app.getList(); } } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mnuInsert_Click(object sender, EventArgs e) { // Try to add a new phone number to the list try { PhoneForm frm = new PhoneForm("", ""); if (frm.ShowDialog() == DialogResult.OK) { app.NewPhone(frm.NewPhone); this.lstNames.Items.Add(frm.NewPhone); this.lstNames.SelectedIndex = 0; } } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } change = true; app.Modified(); //Enabling buttons mnuSave.Enabled = true; mnuEdit.Enabled = true; mnuRemove.Enabled = true; }
public void EditPhone(Phone ph) { using (PhoneForm EditForm = new PhoneForm(ph.Name, ph.PhoneNumber)) { EditForm.Text = "Edit Phone Information"; EditForm.Enabled = true; if (EditForm.ShowDialog() == DialogResult.OK) { string name; string phonenumber; name = EditForm.NewPhone.Name; phonenumber = EditForm.NewPhone.PhoneNumber; Phone ph2 = new Phone(name, phonenumber); foreach (Phone update in phoneList) { if (update.Equals(ph)) { update.Name = ph2.Name; update.PhoneNumber = ph2.PhoneNumber; } } } } }
public static void Main(string[] args) { PhoneForm phoneForm = new PhoneForm(); Application.Run(phoneForm); }