Beispiel #1
0
        /// <summary>
        /// Show the window for creating a new contact
        /// </summary>
        private void newContactToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ContactForm form = new ContactForm();

            while (true)
            {
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    // Attempt to add
                    contactsList.AddContact(form.Contact);

                    // Dislay all contacts
                    RefreshContactsList();
                    return;
                }
                catch (Exception ex)
                {
                    // If there's an error, then re-do
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        private void OnContactAdd(object sender, EventArgs e)
        {
            //Display UI
            var form = new ContactForm();

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    OnSafeAdd(form);
                    break;
                } catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;
            BindList();
        }
Beispiel #3
0
        private void OnContactEdit(object sender, EventArgs e)
        {
            var form = new ContactForm();

            var contact = GetSelectedContact();

            if (contact == null)
            {
                return;
            }

            //Game to edit
            form.Contact = contact;

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    //UpdateGame(game, form.Game);
                    _contact.Update(contact.Id, form.Contact);
                    break;
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #4
0
        //Edit EventHandler
        private void OnContactEdit(object sender, EventArgs e)
        {
            var form    = new ContactForm();
            var contact = GetSelectedContact();

            if (contact == null)
            {
                return;
            }

            form.CurrentContact = contact;
            form.Text           = "Edit Contact";

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    _contacts.Update(contact.Id, form.CurrentContact);
                    break;
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #5
0
        /// <summary>
        /// opens the ContactForm asking for user input
        /// </summary>
        private void OnContactCreate(object sender, EventArgs e)
        {
            // display UI
            var form = new ContactForm();

            // modal
            while (true)
            {
                //Modal
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    //Anything in here that raises an exception will
                    //be sent to the catch block
                    OnSafeAdd(form);
                    break;
                }
                catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
        private void OnContactsAdd(object sender, EventArgs e)
        {
            // display UI
            var form = new ContactForm();

            form.Text = "New Contact";

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                // add new contact
                try
                {
                    _contacts.Add(form.Contact);
                    break;
                } catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Name must be unique.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            BindContactList();
        }
Beispiel #7
0
        private void OnContactAdd(object sender, EventArgs e)
        {
            var form = new ContactForm();

            while (true)
            {
                //Modal
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Add
                try
                {
                    OnSafeAdd(form);
                    break;
                } catch (InvalidOperationException)
                {
                    MessageBox.Show(this, "Error.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex)
                {
                    //Recover from errors
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
Beispiel #8
0
        private void OnContactsAdd_Click(object sender, EventArgs e)
        {
            var form = new ContactForm();

            form.ShowDialog();

            BindList();
        }
Beispiel #9
0
        private void EditContact(ContactForm contact)
        {
            var form = new ContactForm();

            form.Contact = contact.Contact;

            if (contact.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
        }
Beispiel #10
0
        private void OnContactAdd(object sender, EventArgs e)
        {
            var form = new ContactForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _database.Add(form.Contact);
            RefreshContacts();
        }
Beispiel #11
0
        private void OnNewContact(object sender, EventArgs e)
        {
            ContactForm cf = new ContactForm();

            cf.ShowDialog(this);

            if (cf.Contact != null)
            {
                _contactDB.Add(cf.Contact);
            }

            RefreshList();
        }
Beispiel #12
0
        private void EditContact()
        {
            ContactItem contactItem = GetSelectedContact();

            if (contactItem == null)
            {
                return;
            }
            ContactForm cf = new ContactForm();

            cf.Contact = contactItem;

            cf.ShowDialog(this);

            RefreshList();
        }
Beispiel #13
0
        private void OnaddContact_Click(object sender, EventArgs e)
        {
            var form = new ContactForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }
            if (_database.ExistingContact(form.Contact))
            {
                MessageBox.Show(this, "Contact already exists", "Duplicate Contact", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            else
            {
                _database.Add(form.Contact);
                RefreshContacts();
            };
        }
Beispiel #14
0
        private void EditContact()
        {
            var item = GetSelectedContact();

            if (item == null)
            {
                return;
            }

            var form = new ContactForm();

            //form.Text = "Edit Contact";
            form.Contact = item;
            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _database.Edit(item.Name, form.Contact);
            RefreshContacts();
        }
        private void OnContactAdd(object sender, EventArgs e)
        {
            var form = new ContactForm();

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                _contactDatabase.Add(form.Contact);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshContacts();
        }
        private void OnContactsEdit(object sender, EventArgs e)
        {
            // display UI
            var form = new ContactForm();

            // change from title
            form.Text = "Edit Contact";

            // get selected contact, if any
            var contact = _listContacts.SelectedItem as Contact;

            if (contact == null)
            {
                return;
            }

            form.Contact = contact;

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    _contacts.Update(contact.Id, form.Contact);
                    break;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Name must be unique.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            BindContactList();
        }
Beispiel #17
0
        //on Contact add Event Handler
        private void OnContactAdd(object sender, EventArgs e)
        {
            var form = new ContactForm();

            while (true)
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                try
                {
                    _contacts.Add(form.CurrentContact);
                    break;
                } catch (Exception ex)
                {
                    DisplayError(ex);
                };
            }
            ;

            BindList();
        }
        private void OnEdit(object sender, EventArgs e)
        {
            var item = GetSelectedContact();

            if (item == null)
            {
                return;
            }

            var form = new ContactForm
            {
                Text    = "Edit Contact",
                Contact = item
            };

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _contactDatabase.Edit(item.Name, form.Contact);
            RefreshContacts();
        }
Beispiel #19
0
        private void EditContact()
        {
            //Get selected contact, if any
            var item = GetSelectedContact();

            if (item == null)
            {
                return;
            }

            //Show form with selected contact
            var form = new ContactForm();

            form.Contact = item;
            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            //Update database and refresh
            _database.Edit(item.Name, form.Contact);
            RefreshContacts();
        }
Beispiel #20
0
        /// <summary>
        /// Edit a contact
        /// </summary>
        private void editContactToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = contactsListBox.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            string   oldName = contactsListBox.SelectedItem.ToString();
            IContact contact = contactsList.FindContact(oldName);

            ContactForm form = new ContactForm(contact);

            while (true)
            {
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    // Attempt to update
                    contactsList.UpdateContact(oldName, form.Contact);

                    // Dislay all contacts
                    RefreshContactsList();
                    return;
                }
                catch (Exception ex)
                {
                    // If there's an error, then re-do
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }