Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            PhoneForm phoneForm = new PhoneForm();

            Application.Run(phoneForm);
        }