Пример #1
0
        private void btnAgregarEditorial_Click(object sender, EventArgs e)
        {
            if (btnAgregarEditorial.Text == "Agregar")
            {
                using (contexto db = new contexto())
                {
                    EDITORIAL nuevaEditorial = new EDITORIAL();
                    nuevaEditorial.descEditorial = txtEditorial.Text;

                    db.EDITORIALs.Add(nuevaEditorial);
                    db.SaveChanges();
                    cargarTablaEditoriales();
                }
            }
            else
            {
                if (idEditorial != 0)
                {
                    using (contexto db = new contexto())
                    {
                        EDITORIAL editorialMod = db.EDITORIALs.Find(idEditorial);
                        editorialMod.descEditorial = txtEditorial.Text;

                        db.Entry(editorialMod).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        cargarTablaEditoriales();
                    }
                }
            }
        }
Пример #2
0
        private void btnEliminarEditorial_Click(object sender, EventArgs e)
        {
            if (idEditorial != 0)
            {
                using (contexto db = new contexto())
                {
                    EDITORIAL editorialDel = db.EDITORIALs.Find(idEditorial);

                    db.EDITORIALs.Remove(editorialDel);
                    db.SaveChanges();

                    cargarTablaEditoriales();
                }
            }
        }