示例#1
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            if (txtId.Text != "0")
            {
                if (VerificarFormulario())
                {
                    int      id       = Convert.ToInt32(txtId.Text);
                    string   nombre   = txtNombre.Text;
                    int      dni      = Convert.ToInt32(txtDNI.Text);
                    DateTime fechaNac = dtpFechaNac.Value;
                    int      telefono = Convert.ToInt32(txtTelefono.Text);
                    string   correo   = txtCorreo.Text;

                    ProfesorCE profesorCE = new ProfesorCE(id, nombre, dni, fechaNac, telefono, correo);

                    ProfesorCN profesorCN = new ProfesorCN();

                    int numFile = profesorCN.Actualizar(profesorCE);

                    MessageBox.Show(numFile + " Filas Actualizadas");
                }
                else
                {
                    MessageBox.Show("Al parecer no se ha llenado correctamente el formulario.");
                }
            }
            else
            {
                MessageBox.Show("No podemos actualizar con datos nulos o inexistentes.");
            }
        }
示例#2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (txtId.Text != "0")
            {
                int        id         = Convert.ToInt32(txtId.Text);
                ProfesorCE profesorCE = new ProfesorCE();
                profesorCE.Id = id;

                ProfesorCN profesorCN = new ProfesorCN();


                int numFile = profesorCN.Eliminar(profesorCE);

                MessageBox.Show(numFile + " Filas eliminadas");

                if (numFile > 0)
                {
                    LimpiarFormulario();
                }
            }
            else
            {
                MessageBox.Show("No podemos eliminar con datos nulos o inexistentes.");
            }
        }
示例#3
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtId.Text == "0")
            {
                if (VerificarFormulario())
                {
                    string   nombre   = txtNombre.Text;
                    int      dni      = Convert.ToInt32(txtDNI.Text);
                    DateTime fechaNac = dtpFechaNac.Value;
                    int      telefono = Convert.ToInt32(txtTelefono.Text);
                    string   correo   = txtCorreo.Text;

                    ProfesorCE profesorCE = new ProfesorCE(0, nombre, dni, fechaNac, telefono, correo);
                    ProfesorCN profesorCN = new ProfesorCN();

                    int idNuevo = profesorCN.Insertar(profesorCE);
                    txtId.Text = idNuevo.ToString();
                }
                else
                {
                    MessageBox.Show("Los datos del formulario no han sido rellenados correctamente.");
                }
            }
            else
            {
                LimpiarFormulario();
            }
        }
示例#4
0
        private void BuscarProfesor()
        {
            if (txtIdProfesor.Text.Length > 0)
            {
                ProfesorCN profesorCN = new ProfesorCN();

                int idBuscado = Convert.ToInt32(txtIdProfesor.Text);

                ProfesorCE profesorCE = profesorCN.BuscarID(idBuscado);

                txtProfesor.Text = profesorCE.Nombre;
            }
        }
示例#5
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     if (txtBuscar.Text.Length > 0)
     {
         // extraer nombre a buscar
         string name = txtBuscar.Text;
         // Instanciar objeto ProfesorCN
         ProfesorCN profesorCN = new ProfesorCN();
         // Insertar retornando los datos del metodo Buscarnombre
         dgvProfesores.DataSource = profesorCN.BuscarNombre(name);
     }
     else
     {
         // Instanciar ProfesorCN
         ProfesorCN profesorCN = new ProfesorCN();
         // Extraer todos los datos
         dgvProfesores.DataSource = profesorCN.Listar();
     }
 }