Esempio n. 1
0
        private void cmdDeleteNumber_Click(object sender, EventArgs e)
        {
            var selectedID = int.Parse(DgvPhones.SelectedRows[0].Cells[3].Value.ToString());

            using (var context = new ContactBoockContext())
            {
                ContactTelephoneNumber NumberToDelete = (ContactTelephoneNumber)(from data in context.ContactTelephoneNumbers
                                                                                 where data.ContactTelephoneNumberID == selectedID
                                                                                 select data).First();
                context.ContactTelephoneNumbers.Remove(NumberToDelete);
                context.SaveChanges();
                contactsDataGridView_SelectionChanged(null, null);
                isEnableAdress(false);
            }
        }
Esempio n. 2
0
        private void cmdSaveAdress_Click(object sender, EventArgs e)
        {
            using (var context = new ContactBoockContext())
            {
                var selectedID = int.Parse(contactsDataGridView.SelectedRows[0].Cells[0].Value.ToString());
                if (selectedID > 0)
                {
                    var selectedAdress = context.ContactAdresses.Where(data => data.ContactID == selectedID).Select(data => data.Adress).ToList();

                    ContactAdress ContactToAdd = new ContactAdress();
                    ContactToAdd.ContactID    = selectedID;
                    ContactToAdd.Adress       = txtAdress.Text;
                    ContactToAdd.AdressTypeID = (int)cbTypeOfAdress.SelectedValue;
                    context.ContactAdresses.Add(ContactToAdd);
                    context.SaveChanges();
                    contactsDataGridView_SelectionChanged(null, null);
                    isEnableAdress(false);
                }
            }
        }
Esempio n. 3
0
        private void cmdSaveNumber_Click(object sender, EventArgs e)
        {
            using (var context = new ContactBoockContext())
            {
                var selectedID = int.Parse(contactsDataGridView.SelectedRows[0].Cells[0].Value.ToString());
                if (selectedID > 0)
                {
                    var SelectNumber = context.ContactAdresses.Where(data => data.ContactID == selectedID).Select(data => data.Adress).ToList();

                    ContactTelephoneNumber PhoneNumberToAdd = new ContactTelephoneNumber();
                    PhoneNumberToAdd.ContactID       = selectedID;
                    PhoneNumberToAdd.TelefonNumber   = txtPhoneNumber.Text;
                    PhoneNumberToAdd.TelephoneTypeID = (int)cbTypeOfPhones.SelectedValue;
                    context.ContactTelephoneNumbers.Add(PhoneNumberToAdd);
                    context.SaveChanges();
                    contactsDataGridView_SelectionChanged(null, null);
                    isEnableNumber(false);
                }
            }
        }