Esempio n. 1
0
        private void dgContactsList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // get the selected items Id
                string mId = dgContactsList.Rows[e.RowIndex].Cells[(int)columns.Id].Value.ToString();

                // open the associated form based on the selected column
                if (e.ColumnIndex == (int)columns.HomeAddress)
                {
                    PhysicalAddress tHomeAddress = null;

                    foreach (KeyValuePair<string, PhysicalAddress> pair in dHomeAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tHomeAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tHomeAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.BusinessAddress)
                {
                    PhysicalAddress tBusinessAddress = null;

                    foreach (KeyValuePair<string, PhysicalAddress> pair in dBusinessAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tBusinessAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tBusinessAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.OtherAddress)
                {
                    PhysicalAddress tOtherAddress = null;

                    foreach (KeyValuePair<string, PhysicalAddress> pair in dOtherAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tOtherAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tOtherAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.BusinessPhone)
                {
                    List<string> lBusinessPhones = null;
                    foreach (KeyValuePair<string, List<string>> pair in dBusinessPhones)
                    {
                        if (pair.Key == mId)
                        {
                            lBusinessPhones = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lBusinessPhones);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.Categories)
                {
                    List<string> lCategories = null;
                    foreach (KeyValuePair<string, List<string>> pair in dCategories)
                    {
                        if (pair.Key == mId)
                        {
                            lCategories = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lCategories);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.HomePhone)
                {
                    List<string> lHomePhones = null;
                    foreach (KeyValuePair<string, List<string>> pair in dHomePhones)
                    {
                        if (pair.Key == mId)
                        {
                            lHomePhones = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lHomePhones);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.ImAddresses)
                {
                    List<string> lImAddress = null;
                    foreach (KeyValuePair<string, List<string>> pair in dImAddresses)
                    {
                        if (pair.Key == mId)
                        {
                            lImAddress = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lImAddress);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);                    
                }
                if (e.ColumnIndex == (int)columns.EmailAddress)
                {
                    List<string> lEmailAddresses = null;
                    foreach (KeyValuePair<string, List<string>> pair in dEmailAddresses)
                    {
                        if (pair.Key == mId)
                        {
                            lEmailAddresses = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lEmailAddresses);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
            }
            catch (NullReferenceException nre)
            {
                // likely a cell collection that is empty, just return
                applogger.Log(nre.Message);
            }
            catch (Exception ex)
            {
                applogger.Log(ex.Message);
            }
        }
        private void dgContactsList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // get the selected items Id
                string mId = dgContactsList.Rows[e.RowIndex].Cells[(int)columns.Id].Value.ToString();

                // open the associated form based on the selected column
                if (e.ColumnIndex == (int)columns.HomeAddress)
                {
                    PhysicalAddress tHomeAddress = null;

                    foreach (KeyValuePair <string, PhysicalAddress> pair in dHomeAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tHomeAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tHomeAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.BusinessAddress)
                {
                    PhysicalAddress tBusinessAddress = null;

                    foreach (KeyValuePair <string, PhysicalAddress> pair in dBusinessAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tBusinessAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tBusinessAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.OtherAddress)
                {
                    PhysicalAddress tOtherAddress = null;

                    foreach (KeyValuePair <string, PhysicalAddress> pair in dOtherAddress)
                    {
                        if (pair.Key == mId)
                        {
                            tOtherAddress = (PhysicalAddress)pair.Value;
                        }
                    }

                    PhysicalAddressForm mPhysicalAddress = new PhysicalAddressForm(tOtherAddress);
                    mPhysicalAddress.Owner = this;
                    mPhysicalAddress.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.BusinessPhone)
                {
                    List <string> lBusinessPhones = null;
                    foreach (KeyValuePair <string, List <string> > pair in dBusinessPhones)
                    {
                        if (pair.Key == mId)
                        {
                            lBusinessPhones = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lBusinessPhones);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.Categories)
                {
                    List <string> lCategories = null;
                    foreach (KeyValuePair <string, List <string> > pair in dCategories)
                    {
                        if (pair.Key == mId)
                        {
                            lCategories = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lCategories);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.HomePhone)
                {
                    List <string> lHomePhones = null;
                    foreach (KeyValuePair <string, List <string> > pair in dHomePhones)
                    {
                        if (pair.Key == mId)
                        {
                            lHomePhones = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lHomePhones);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.ImAddresses)
                {
                    List <string> lImAddress = null;
                    foreach (KeyValuePair <string, List <string> > pair in dImAddresses)
                    {
                        if (pair.Key == mId)
                        {
                            lImAddress = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lImAddress);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
                if (e.ColumnIndex == (int)columns.EmailAddress)
                {
                    List <string> lEmailAddresses = null;
                    foreach (KeyValuePair <string, List <string> > pair in dEmailAddresses)
                    {
                        if (pair.Key == mId)
                        {
                            lEmailAddresses = pair.Value;
                        }
                    }

                    CategoriesForm mCategories = new CategoriesForm(lEmailAddresses);
                    mCategories.Owner = this;
                    mCategories.ShowDialog(this);
                }
            }
            catch (NullReferenceException nre)
            {
                // likely a cell collection that is empty, just return
                applogger.Log(nre.Message);
            }
            catch (Exception ex)
            {
                applogger.Log(ex.Message);
            }
        }