Ejemplo n.º 1
0
        private void ContactDelete_button_Click(object sender, EventArgs e)
        {
            Book b = (Book)Books_ListBox.SelectedItem;

            if (b == null)
            {
                return;
            }

            int index = Contacts_ListBox.SelectedIndex;

            if (index < 0 || index >= b.getContacts().Count())
            {
                return;
            }
            Contact c = b.getContacts()[index];

            b.getContacts().RemoveAt(index);
            Contacts_ListBox.DataSource = null;
            Contacts_ListBox.DataSource = b.getContacts();
            if (index >= b.getContacts().Count())
            {
                index -= 1;
            }
            Contacts_ListBox.SelectedIndex = index;
            toDeleteContacts.Add(c);
            update(true);
        }
Ejemplo n.º 2
0
        private void Books_ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Book b = (Book)Books_ListBox.SelectedItem;

            if (b == null)
            {
                return;
            }
            selectedBook = b;
            if (b.getContacts().Count() == 0)
            {
                selectedContact = null;
            }
            else
            {
                selectedContact = b.getContacts()[0];
                Contacts_ListBox.SelectedItem = selectedContact;
            }
            Books_ListBox.SelectedItem  = b;
            Contacts_ListBox.DataSource = b.getContacts();
        }
Ejemplo n.º 3
0
        public Contact getContactById(int id)
        {
            Book b = (Book)Books_ListBox.SelectedItem;

            foreach (Contact c in b.getContacts())
            {
                if (c.id == id)
                {
                    return(c);
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
 public void refreshContacts()
 {
     cm = (CurrencyManager)BindingContext[selectedBook.getContacts()];
     cm.Refresh();
 }