private void actualizarTabla() { using (ColegioEntities col = new ColegioEntities()) { IQueryable <Administradores> admin = from d in col.Administradores select d; List <Administradores> listado = admin.ToList(); dataGridView1.DataSource = listado; } }
private void button3_Click(object sender, EventArgs e) { //Actualizar var indice = dataGridView1.CurrentRow.Index; using (ColegioEntities col = new ColegioEntities()) { Actualizar ventanaActualizar = new Actualizar(indice, dataGridView1); ventanaActualizar.Show(); } }
private void button2_Click(object sender, EventArgs e) { using (ColegioEntities col = new ColegioEntities()) { IQueryable <Administradores> admin = from d in col.Administradores select d; List <Administradores> listado = admin.ToList(); dataGridView1.DataSource = listado; } }
private void button4_Click(object sender, EventArgs e) { var indice = dataGridView1.CurrentRow.Index; var id = int.Parse(dataGridView1.Rows[indice].Cells[0].Value.ToString()); using (ColegioEntities col = new ColegioEntities()) { Administradores admins = col.Administradores.FirstOrDefault(admins1 => admins1.id.Equals(id)); MessageBox.Show(admins.ToString()); col.Administradores.Remove(admins); col.SaveChanges(); actualizarTabla(); } }
private void button1_Click(object sender, EventArgs e) { using (ColegioEntities col = new ColegioEntities()) { Administradores admin = new Administradores { nombre = textBox1.Text, apellido = textBox2.Text, contrasena = textBox3.Text, }; col.Administradores.Add(admin); col.SaveChanges(); this.Hide(); MessageBox.Show("Se ha guardado con exito"); actualizarTabla(); } }
private void button2_Click(object sender, EventArgs e)//Boton iniciar sesion { using (ColegioEntities col = new ColegioEntities()) { var admin = from d in col.Administradores where d.nombre == textBox1.Text && d.contrasena == textBox2.Text select d; if (admin.Count() > 0) { this.Hide(); Form2 menu = new Form2(); menu.Show(); } else { MessageBox.Show("Credenciales incorrectas"); } } }
private void button1_Click(object sender, EventArgs e) { using (ColegioEntities col = new ColegioEntities()) { var id = int.Parse(datagridview1.Rows[indice].Cells[0].Value.ToString()); Administradores admin = col.Administradores.FirstOrDefault(admin1 => admin1.id.Equals(id)); admin.nombre = textBox1.Text; admin.apellido = textBox2.Text; admin.contrasena = textBox3.Text; col.SaveChanges(); IQueryable <Administradores> admin2 = from d in col.Administradores select d; List <Administradores> listado = admin2.ToList(); datagridview1.DataSource = listado; this.Hide(); MessageBox.Show("Se guardaron los cambios"); } }