public static void loadContacts(ListView listView, ContactGroup cg) { loadContacts(listView, cg, ""); }
private void btnAdd_Click(object sender, EventArgs e) { if (cmbGroup.SelectedIndex == -1) { label1.ForeColor = Color.Red; cmbGroup.Focus(); return; } ContactGroup cg = cmbGroup.SelectedItem as ContactGroup; if (txtName.Text.Trim().Length == 0) { label2.ForeColor = Color.Red; txtName.Focus(); return; } String name = txtName.Text.Trim(); long number = 0; if (txtNumber.Text.Trim().Length == 0 || !long.TryParse(txtNumber.Text.Trim(), out number)) { label3.ForeColor = Color.Red; txtNumber.Focus(); return; } Contact contact = new Contact(); contact.Name = name; contact.Number = number; contact.Number = 0; if (Func.ContactExists(contact, cg, false)) { bool flag = true; if (EditMode) { if (txtName.Text.Equals(txtName.Tag.ToString())) { flag = false; } } if (flag) { label2.ForeColor = Color.Red; label2.Text = "Name : (Already exists!!)"; //label3.Text = "Mobile Number : (Already exists!!)"; txtName.Focus(); return; } } contact.Name = ""; contact.Number = number; if (Func.ContactExists(contact, cg, false)) { if (Func.ContactExists(contact, cg, false)) { bool flag = true; if (EditMode) { if (txtNumber.Text.Equals(txtNumber.Tag.ToString())) { flag = false; } } if (flag) { label3.ForeColor = Color.Red; //label2.Text = "Name : (Already exists!!)"; label3.Text = "Mobile Number : (Already exists!!)"; txtNumber.Focus(); return; } } } contact.Name = name; contact.Number = number; if (EditMode) { Contact oldContact = new Contact(); oldContact.Name = txtName.Tag.ToString(); oldContact.Number = (long)txtNumber.Tag; if (Func.UpdateContactToGroup(oldContact, contact, cg)) { DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show(this, "Known contact or contact group isn't exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (Func.AddContactToGroup(contact, cg)) { txtName.Text = txtNumber.Text = ""; txtName.Focus(); } else { MessageBox.Show(this, "Group not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Func.loadGroups(cmbGroup); } } }
private void btnCopy_Click(object sender, EventArgs e) { contactGroup = cmbGroups.SelectedItem as ContactGroup; DialogResult = DialogResult.OK; Close(); }
public void setContactGroup(ContactGroup cg) { cmbGroup.SelectedItem = cg; }
private void btnCancel_Click(object sender, EventArgs e) { contactGroup = null; DialogResult = DialogResult.Cancel; Close(); }