コード例 #1
0
        private void modificar(int id)
        {
            tbl_profesor profe = new tbl_profesor();

            profe = db.tbl_profesor.Find(id);
            profe.nombreProfesor   = txtNombre.Text;
            profe.apellidoProfesor = txtApellido.Text;
            db.SaveChanges();
        }
コード例 #2
0
        private void eliminar(int id)
        {
            tbl_profesor profe = new tbl_profesor();

            profe = db.tbl_profesor.Find(id);
            db.tbl_profesor.Remove(profe);
            db.SaveChanges();
            listarProfe();
            limpiar();
        }
コード例 #3
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     if (txtId.Text != "")
     {
         tbl_profesor profe = new tbl_profesor();
         profe.idProfesor       = Convert.ToInt32(txtId.Text);
         profe.nombreProfesor   = txtNombre.Text;
         profe.apellidoProfesor = txtApellido.Text;
         addProfe(profe);
         listarProfe();
         limpiar();
     }
     else
     {
         MessageBox.Show("Debe llenar los campos");
     }
 }
コード例 #4
0
 private void addProfe(tbl_profesor profe)
 {
     using (MaestrosEntities bd = new MaestrosEntities())
     {
         tbl_profesor newProfe = bd.tbl_profesor.Find(profe.idProfesor);
         if (newProfe != null)
         {
             MessageBox.Show("El profesor ya existe");
         }
         else
         {
             newProfe = profe;
             bd.tbl_profesor.Add(newProfe);
             db.SaveChanges();
             MessageBox.Show("Se hizo");
         }
     }
 }
コード例 #5
0
        private void buscarProfe()
        {
            tbl_profesor profe = new tbl_profesor();

            profe = db.tbl_profesor.Find(Convert.ToInt32(txtId.Text));
            if (profe != null)
            {
                txtNombre.Text   = profe.nombreProfesor;
                txtApellido.Text = profe.apellidoProfesor;
                if (profe != null)
                {
                    btnModificar.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("No se encontraron coincidencias");
            }
        }