private void Refrescar() { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { var lst = from d in db.EMPLEADOS select d; dataGridView1.DataSource = lst.ToList(); } }
private void cargaDatos(int?id) { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { nEmpleados = db.EMPLEADOS.Find(id); textBoxNombreEmp.Text = nEmpleados.NOMBRE_EMPL; textBoxApellidoEmp.Text = nEmpleados.APELLIDO_EMPL; textBoxCedEmp.Text = nEmpleados.CEDULA_ALUMN; textBoxPassEmp.Text = nEmpleados.PASS_ALUMN; textBoxDirEmp.Text = nEmpleados.DIRECCION_EMPL; textBoxTelfEmp.Text = nEmpleados.TELEFONO_EMPL; textBoxTituloEmp.Text = nEmpleados.TITULO_EMPL; } }
private void buttonEliminar_Click(object sender, EventArgs e) { int?id = GetId(); if (id != null) { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { EMPLEADOS nEmpleados = db.EMPLEADOS.Find(id); db.EMPLEADOS.Remove(nEmpleados); db.SaveChanges(); } Refrescar(); } }
private void buttonGuardar_Click(object sender, EventArgs e) { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { if (id == null) { nEmpleados = new EMPLEADOS(); } else { nEmpleados.NOMBRE_EMPL = textBoxNombreEmp.Text; nEmpleados.APELLIDO_EMPL = textBoxApellidoEmp.Text; nEmpleados.CEDULA_ALUMN = textBoxCedEmp.Text; nEmpleados.PASS_ALUMN = textBoxPassEmp.Text; nEmpleados.DIRECCION_EMPL = textBoxDirEmp.Text; nEmpleados.TELEFONO_EMPL = textBoxTelfEmp.Text; nEmpleados.TITULO_EMPL = textBoxTituloEmp.Text; } System.Console.WriteLine(id); if (id == null) { db.EMPLEADOS.Add(nEmpleados); } else { db.Entry(nEmpleados).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); groupBoxDatosEmp.Hide(); Refrescar(); splitContainer1.Panel2.Show(); textBoxNombreEmp.Clear(); textBoxApellidoEmp.Clear(); textBoxCedEmp.Clear(); textBoxPassEmp.Clear(); textBoxDirEmp.Clear(); textBoxTelfEmp.Clear(); textBoxTituloEmp.Clear(); } }
private void buttonGuardar_Click(object sender, EventArgs e) { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { EMPLEADOS nEmpleados = new EMPLEADOS(); nEmpleados.NOMBRE_EMPL = textBoxNombreEmp.Text; nEmpleados.APELLIDO_EMPL = textBoxApellidoEmp.Text; nEmpleados.CEDULA_ALUMN = textBoxCedEmp.Text; nEmpleados.PASS_ALUMN = textBoxPassEmp.Text; nEmpleados.DIRECCION_EMPL = textBoxDirEmp.Text; nEmpleados.TELEFONO_EMPL = textBoxTelfEmp.Text; nEmpleados.TITULO_EMPL = textBoxTituloEmp.Text; db.EMPLEADOS.Add(nEmpleados); db.SaveChanges(); this.Close(); } }
private void buttonActualizar_Click(object sender, EventArgs e) { using (Sistema_CalificacionEntities2 db = new Sistema_CalificacionEntities2()) { nEmpleados.NOMBRE_EMPL = textBoxNombreEmp.Text; nEmpleados.APELLIDO_EMPL = textBoxApellidoEmp.Text; nEmpleados.CEDULA_ALUMN = textBoxCedEmp.Text; nEmpleados.PASS_ALUMN = textBoxPassEmp.Text; nEmpleados.DIRECCION_EMPL = textBoxDirEmp.Text; nEmpleados.TELEFONO_EMPL = textBoxTelfEmp.Text; nEmpleados.TITULO_EMPL = textBoxTituloEmp.Text; db.Entry(nEmpleados).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); groupBoxDatosEmp.Hide(); Refrescar(); splitContainer1.Panel2.Show(); } }