Ejemplo n.º 1
0
        public void DeleteContact(ContactDTO wc)
        {
            db = new addressbookEntities();
            Contact contact = db.Contacts.Find(wc.Id);

            db.Contacts.Remove(contact);
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        public void UpdateContact(ContactDTO wc)
        {
            db = new addressbookEntities();
            Contact contact = (from x in db.Contacts where x.Id == wc.Id select x).First();

            contact.FullName    = wc.FullName;
            contact.BirthDate   = wc.BirthDate;
            contact.Description = wc.Description;
            contact.email       = wc.email;
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void InsertContact(ContactDTO wc)
        {
            Contact contact = new Contact();

            contact.FullName    = wc.FullName;
            contact.BirthDate   = wc.BirthDate;
            contact.Description = wc.Description;
            contact.email       = wc.email;
            db = new addressbookEntities();
            db.Contacts.Add(contact);
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ContactInfo  ci     = new ContactInfo();
            DialogResult result = ci.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            Contact contact = new Contact();

            contact.FullName    = ci.txtFullName.Text;
            contact.BirthDate   = ci.dateTimePicker1.Value;
            contact.Description = ci.txtDescription.Text;
            contact.email       = ci.txtEmail.Text;

            db.Contacts.Add(contact);
            db.SaveChanges();

            MessageBox.Show("New Contact Added!");
        }