private void btnActualizar_Click(object sender, EventArgs e) { try { if (txtMateria.Text == "") { MessageBox.Show("Para actualizar, primero seleccione \nuna materia en específica.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { using (notasEstudiantesEntities bd = new notasEstudiantesEntities()) { String id = dtvMateria.CurrentRow.Cells[0].Value.ToString(); int idC = int.Parse(id); subject = bd.materia.Where(VerificarId => VerificarId.idMateria == idC).First(); subject.nombreMateria = txtMateria.Text; bd.Entry(subject).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); } dtvMateria.Rows.Clear(); CargarDatos(); LimpiarDatos(); this.btnRegistrar.Enabled = true; //this.btnActualizar.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Error al Actualizar: \n\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnActualizar_Click(object sender, EventArgs e) { try { if (txtIdEstudiante.Text == "" || txtIdMateria.Text == "" || txtNota.Text == "") { MessageBox.Show("Para actualizar, primero seleccione \nun id en específico.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { using (notasEstudiantesEntities bd = new notasEstudiantesEntities()) { String id = dtvNotas.CurrentRow.Cells[0].Value.ToString(); int idC = int.Parse(id); grade = bd.notas.Where(VerificarId => VerificarId.idNotas == idC).First(); grade.idEstudiante = int.Parse(txtIdEstudiante.Text); grade.idMateria = int.Parse(txtIdMateria.Text); grade.nota = double.Parse(txtNota.Text); bd.Entry(grade).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); } dtvNotas.Rows.Clear(); CargarDatos(); LimpiarDatos(); } } catch (Exception ex) { MessageBox.Show("Error al Actualizar: \n\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { String Id = dtvNota.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); n = db.notas.Where(VerificarID => VerificarID.id_notas == IdC).First(); n.id_estudiante = Convert.ToInt32(txtEstudiante.Text); n.id_materia = Convert.ToInt32(txtMateria.Text); n.notas1 = Convert.ToInt32(txtNota.Text); db.Entry(n).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } CargarDatos(); }
private void button2_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { String id = dtvMat.CurrentRow.Cells[1].Value.ToString(); int idC = int.Parse(id); mate = db.materia.Where(VerificarID => VerificarID.id_materia == idC).First(); mate.nombre_materia = txtNombreMat.Text; db.Entry(mate).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } CargarDatos(); }
private void btnEditar_Click(object sender, EventArgs e) { materia M = new materia(); using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Id = dvgMaterias.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); M = db.materias.Where(VerificarId => VerificarId.id_materia == IdC).First(); M.nombre_materia = txtMateria.Text; db.Entry(M).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } cargardatos(); limpiardatos(); }
private void btnActualizar_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Notas = dtvNotas.CurrentRow.Cells[0].Value.ToString(); int Idc = int.Parse(Notas); nots = db.notas.Where(verificarId => verificarId.id_notas == Idc).First(); nots.notas1 = double.Parse(txtNota.Text); db.Entry(nots).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } dtvNotas.Rows.Clear(); limpiar(); CargarDatos(); }
private void button1_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { String id = dtvAct.CurrentRow.Cells[0].Value.ToString(); int idC = int.Parse(id); estud = db.estudiante.Where(VerificarID => VerificarID.id_estudiante == idC).First(); estud.nombre_estudiante = txtEstudiante.Text; estud.apellido = txtApellido.Text; estud.usuario = txtUsuario.Text; estud.contraseña = txtContraseña.Text; db.Entry(estud).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } CargarDatos(); }
private void btnActualizar_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Id = dtvMateria.CurrentRow.Cells[0].Value.ToString(); int Idc = int.Parse(Id); mat = db.materia.Where(verificarId => verificarId.id_materia == Idc).First(); mat.nombre_materia = txtNombreMateria.Text; db.Entry(mat).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } dtvMateria.Rows.Clear(); limpiar(); CargarDatos(); }
private void btnEditar_Click(object sender, EventArgs e) { nota note = new nota(); using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Id = dvgNotas.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); note = db.notas.Where(VerificarId => VerificarId.id_notas == IdC).First(); note.id_estudiante = Convert.ToInt32(txtIdA.Text); note.id_materia = Convert.ToInt32(txtIdM.Text); note.nota1 = Convert.ToInt32(txtNota.Text); db.Entry(note).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } cargardatos(); limpiardatos(); }
private void btnActualizar_Click(object sender, EventArgs e) { using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Id = dtvEstudiantes.CurrentRow.Cells[0].Value.ToString(); int Idc = int.Parse(Id); est = db.estudiante.Where(verificarId => verificarId.id_estudiante == Idc).First(); est.nombre_estudiante = txtNombreEstudiante.Text; est.apellido = txtApellido.Text; est.contraseña = txtContraseña.Text; est.usuario = txtUsuario.Text; db.Entry(est).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } dtvEstudiantes.Rows.Clear(); limpiar(); CargarDatos(); }
private void btnEditar_Click(object sender, EventArgs e) { estudiante Student = new estudiante(); using (notasEstudiantesEntities db = new notasEstudiantesEntities()) { string Id = dvgEstudiantes.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); Student = db.estudiantes.Where(VerificarId => VerificarId.id_estudiante == IdC).First(); Student.nombre_estudiante = txtNombre.Text; Student.apellido = txtApellido.Text; Student.usuario = txtUsuario.Text; Student.contrasena = txtPass.Text; db.Entry(Student).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } cargardatos(); limpiardatos(); }