Example #1
0
        public CreateGroupForm(ContactGroup group)
        {
            InitializeComponent();
            Group = group;

            IfGroupMembers = null;
            if (Group != null)
            {
                // adjust the controls
                groupNameTextBox.Text = Group.Name;
                saveGroupButton.Text  = "Update Group";

                // configure which of the user's contacts are in this specific group
                IfGroupMembers = ContactAndGroupHandler.CheckContactGroupMembers(group, ContactsUserControl.Instance.ContactList);

                deleteGroupButton.Visible = true;
            }
            else
            {
                // adjust the controls
                groupNameTextBox.Text = "";
                saveGroupButton.Text  = "Save Group";

                deleteGroupButton.Visible = false;
            }

            // fill contactsCheckedListBox with the user's contacts
            FillContactsListBox();
        }
Example #2
0
        private void deleteGroupButton_Click(object sender, EventArgs e)
        {
            if (Group != null)
            {
                // try to delete group
                int rowsAffected = ContactAndGroupHandler.DeleteGroup(Group);
                if (rowsAffected == 1)
                {
                    // deletion successful, remove the specified group from the user's group list
                    ContactsUserControl.Instance.GroupList.Remove(Group);

                    // inform the user
                    DialogResult dialogResult = MessageBox.Show("  Your group \"" + Group.Name + "\" deleted successfully!");
                    if (dialogResult == DialogResult.OK)
                    {
                        // update the group's tab page
                        ContactsUserControl.Instance.UpdateTabControl();
                        this.Close();
                    }
                }
                else
                {
                    // something was wrong with the group creation, inform the user
                    MessageBox.Show("  Something went wrong with the group deletion. Please try again.\n");
                }
            }
        }
Example #3
0
        private void CreateNewContactGroup(string groupName)
        {
            // get the contacts that were checked
            int[] memberIds = GetCheckedContactsIds();

            // try to create a new group
            ContactGroup newGroup = ContactAndGroupHandler.CreateNewGroup(groupName, memberIds);

            if (newGroup.Id != -1)
            {
                // if the group creation was successful, then add the group to the user's group list
                ContactsUserControl.Instance.GroupList.Add(newGroup);

                // display a feedback dialog
                DialogResult dialogResult = MessageBox.Show("  Your new group \"" + groupName + "\" created successfully!");
                if (dialogResult == DialogResult.OK)
                {
                    // update the groups tab page
                    ContactsUserControl.Instance.UpdateTabControl();
                    this.Close();
                }
            }
            else
            {
                // something was wrong with the group creation, inform the user
                MessageBox.Show("  Something went wrong with the group creation. Please try again.\n");
            }
        }
        private void searchContactsButton_Click(object sender, EventArgs e)
        {
            // get the search string
            string searchString = searchContactsTextBox.Text;

            // fill the tab/listview with the matching user accounts
            ContactAndGroupHandler.FillContactSearchResults(contactsSearchResultsListView, searchString);

            // set focus on the search results tab
            contactsTabControl.SelectedTab = contactsTabControl.TabPages["searchContactsResultTabPage"];
        }
 public void UpdateTabControl()
 {
     if (UI.StartPage.account != null)
     {
         // update the tab that is selected
         if (contactsTabControl.SelectedTab == contactsTabControl.TabPages["contactsTabPage"])
         {
             ContactAndGroupHandler.FillContacts(contactsListView, ContactList);
         }
         else if (contactsTabControl.SelectedTab == contactsTabControl.TabPages["groupTabPage"])
         {
             ContactAndGroupHandler.FillGroups(groupListView, GroupList);
         }
     }
 }
Example #6
0
        private void UpdateGroup(string groupName)
        {
            // get the group's members before the update
            Dictionary <int, bool> groupMembersBefore = IfGroupMembers;

            Dictionary <int, bool> groupMembersAfter = new Dictionary <int, bool>();

            // get the contacts that were checked
            List <int> checkedContacts = GetCheckedContactsIds().ToList <int>();

            foreach (User contact in ContactsUserControl.Instance.ContactList)
            {
                // configure the checked contacts after the update
                if (checkedContacts.Contains(contact.Id))
                {
                    groupMembersAfter[contact.Id] = true;
                }
                else
                {
                    groupMembersAfter[contact.Id] = false;
                }
            }

            // try to update the group
            int exitCode = ContactAndGroupHandler.UpdateGroup(Group, groupName, groupMembersBefore, groupMembersAfter);

            if (exitCode == -1)
            {
                // something was wrong with the name update
                MessageBox.Show("  Something went wrong with the group's name update. Please try again.\n");
            }
            else if (exitCode == ContactsUserControl.Instance.ContactList.Count)
            {
                // if all the contacts updated correctly
                DialogResult dialogResult = MessageBox.Show("  Your group \"" + groupName + "\" updated successfully!");
                if (dialogResult == DialogResult.OK)
                {
                    // update the groups tab page
                    ContactsUserControl.Instance.UpdateTabControl();
                    this.Close();
                }
            }
        }