Exemplo n.º 1
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea eliminar el registro seleccionado?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         CLS.Lectores oLector = new CLS.Lectores();
         oLector.IDLector = dtgRegistros.CurrentRow.Cells["IDLector"].Value.ToString();
         if (oLector.Eliminar())
         {
             MessageBox.Show("Eliminado");
             CargarDatos();
         }
         else
         {
             MessageBox.Show("Falló la eliminación");
         }
     }
 }
Exemplo n.º 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            CLS.Lectores oLector = new CLS.Lectores();
            oLector.IDLector          = txtIDLector.Text;
            oLector.Usuario           = txtUsuario.Text;
            oLector.Credencial        = txtCredencial.Text;
            oLector.Nombres           = txtNombres.Text;
            oLector.Apellidos         = txtApellidos.Text;
            oLector.FechaNacimiento   = dtFecha.Text;
            oLector.Genero            = cmbGenero.SelectedItem.ToString();
            oLector.Fecha_inicio      = dtpFechaInicio.Text;
            oLector.MaxPrestamo       = txtMaxPrestamo.Text;
            oLector.MaxTiempoPrestamo = txtMaxTiempo.Text;
            oLector.Credibilidad      = txtCredibilidad.Text;
            oLector.Foto = pbxFoto.Image;

            if (txtIDLector.TextLength > 0)
            {
                if (txtCredencial.Text.Equals(txtConfirmarCredencial.Text) && cbCambiarContraseña.Checked)
                {
                    //ACTUALIZAR CON CREDENCIAL
                    if (oLector.Actualzar(true))
                    {
                        MessageBox.Show("Actualizado");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Falló la Actualización");
                    }
                }
                else
                {
                    //ACTUALIZAR SIN CREDENCIAL
                    if (oLector.Actualzar())
                    {
                        MessageBox.Show("Actualizado");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Falló la Actualización");
                    }
                }
            }
            else
            {
                if (txtCredencial.Text.Equals(txtConfirmarCredencial.Text))
                {
                    //INSERTAR
                    if (oLector.Insertar())
                    {
                        MessageBox.Show("Insertado");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Falló la Inserción");
                    }
                }
                else
                {
                    MessageBox.Show("Las Contraseñas no Coinciden");
                }
            }
        }