示例#1
0
        private void btnChangeEntry_Click(object sender, RoutedEventArgs e)
        {
            Entry entry = _selectedEntries[_current];

            EntryDialog entryDialog = new EntryDialog("Change")
            {
                NameTextBox            = { Text = entry.Name },
                addressTextBox         = { Text = entry.Address },
                contactTypeDropDownBox = { SelectedIndex = entry.ContactType },
                cszTextBox             = { Text = entry.CSZ },
                emailTextBox           = { Text = _selectedEmails[_curEmail].EmailAddress },
                phoneTextBox           = { Text = _selectedPhones[_currentPhoneNumber].PhoneNumber },
                phoneTypeDropDownBox   = { SelectedIndex = _selectedPhones[_currentPhoneNumber].PhoneType }
            };

            if (entryDialog.ShowDialog() == true)
            {
                entry.Name        = entryDialog.NameTextBox.Text;
                entry.Address     = entryDialog.addressTextBox.Text;
                entry.ContactType = entryDialog.contactTypeDropDownBox.SelectedIndex;
                entry.CSZ         = entryDialog.cszTextBox.Text;
                _selectedEmails[_curEmail].EmailAddress          = entryDialog.emailTextBox.Text;
                _selectedPhones[_currentPhoneNumber].PhoneNumber = entryDialog.phoneTextBox.Text;
                _selectedPhones[_currentPhoneNumber].PhoneType   = entryDialog.phoneTypeDropDownBox.SelectedIndex;

                DB.Entries.AddOrUpdate(entry);
                DB.Phones.AddOrUpdate(_selectedPhones[_currentPhoneNumber]);
                DB.Emails.AddOrUpdate(_selectedEmails[_curEmail]);

                DB.SaveChanges();

                Display();
            }
        }
示例#2
0
        private void btnAddEntry_Click(object sender, RoutedEventArgs e)
        {
            EntryDialog entryDialog = new EntryDialog("Add")
            {
                contactTypeDropDownBox = { SelectedIndex = 0 },
                phoneTypeDropDownBox   = { SelectedIndex = 0 }
            };

            if (entryDialog.ShowDialog() == true)
            {
                Entry entry = new Entry
                {
                    Name        = entryDialog.NameTextBox.Text,
                    Address     = entryDialog.addressTextBox.Text,
                    ContactType = entryDialog.contactTypeDropDownBox.SelectedIndex,
                    CSZ         = entryDialog.cszTextBox.Text,
                    Emails      = new List <Email>(new[] { new Email {
                                                               EmailAddress = entryDialog.emailTextBox.Text
                                                           } }),
                    Phones = new List <Phone>(new[] { new Phone {
                                                          PhoneNumber = entryDialog.phoneTextBox.Text, PhoneType = entryDialog.phoneTypeDropDownBox.SelectedIndex
                                                      } })
                };

                DB.Entries.Add(entry);

                DB.SaveChanges();

                _selectedEntries = CreateSelectedEntries();

                Display();
            }
        }
示例#3
0
        private void btnChangeEntry_Click(object sender, RoutedEventArgs e)
        {
            Entry entry = _selectedEntries[_current];
            
            EntryDialog entryDialog = new EntryDialog("Change")
            {
                NameTextBox = {Text = entry.Name},
                addressTextBox = {Text = entry.Address},
                contactTypeDropDownBox = {SelectedIndex = entry.ContactType},
                cszTextBox = {Text = entry.CSZ},
                emailTextBox = {Text = _selectedEmails[_curEmail].EmailAddress},
                phoneTextBox = {Text = _selectedPhones[_currentPhoneNumber].PhoneNumber},
                phoneTypeDropDownBox = {SelectedIndex = _selectedPhones[_currentPhoneNumber].PhoneType}
            };

            if (entryDialog.ShowDialog() == true)
            {
                entry.Name = entryDialog.NameTextBox.Text;
                entry.Address = entryDialog.addressTextBox.Text;
                entry.ContactType = entryDialog.contactTypeDropDownBox.SelectedIndex;
                entry.CSZ = entryDialog.cszTextBox.Text;
                _selectedEmails[_curEmail].EmailAddress = entryDialog.emailTextBox.Text;
                _selectedPhones[_currentPhoneNumber].PhoneNumber = entryDialog.phoneTextBox.Text;
                _selectedPhones[_currentPhoneNumber].PhoneType = entryDialog.phoneTypeDropDownBox.SelectedIndex;

                DB.Entries.AddOrUpdate(entry);
                DB.Phones.AddOrUpdate(_selectedPhones[_currentPhoneNumber]);
                DB.Emails.AddOrUpdate(_selectedEmails[_curEmail]);
                
                DB.SaveChanges();
                
                Display();
            }
        }
示例#4
0
        private void btnAddEntry_Click(object sender, RoutedEventArgs e)
        {
            EntryDialog entryDialog = new EntryDialog("Add")
            {
                contactTypeDropDownBox = {SelectedIndex = 0},
                phoneTypeDropDownBox = {SelectedIndex = 0}
            };

            if (entryDialog.ShowDialog() == true)
            {
                Entry entry = new Entry
                {
                    Name = entryDialog.NameTextBox.Text,
                    Address = entryDialog.addressTextBox.Text,
                    ContactType = entryDialog.contactTypeDropDownBox.SelectedIndex,
                    CSZ = entryDialog.cszTextBox.Text,
                    Emails = new List<Email>(new[] { new Email{ EmailAddress = entryDialog.emailTextBox.Text } }),
                    Phones = new List<Phone>(new[] { new Phone { PhoneNumber = entryDialog.phoneTextBox.Text, PhoneType = entryDialog.phoneTypeDropDownBox.SelectedIndex } })
                };

                DB.Entries.Add(entry);

                DB.SaveChanges();

                _selectedEntries = CreateSelectedEntries();

                Display();
            }
        }