Exemple #1
0
    protected void brnGrabar_Click(object sender, EventArgs e)
    {
        try
        {
            objEmpleadoBE.IdEmpleado     = Session["IdEmpleado"].ToString();
            objEmpleadoBE.ApeEmpPat      = txtApe.Text;
            objEmpleadoBE.ApeEmpMat      = txtApeMat.Text;
            objEmpleadoBE.NomEmpleado    = txtNom.Text;
            objEmpleadoBE.Sexo           = cboGenero.SelectedValue.ToString();
            objEmpleadoBE.NroDNI         = txtDocumento.Text;
            objEmpleadoBE.Direccion      = txtDireccion.Text;
            objEmpleadoBE.IdDistrito     = cboDistrito.SelectedValue.ToString();
            objEmpleadoBE.Telefono       = txtTelefono.Text;
            objEmpleadoBE.Celular        = txtCelular.Text;
            objEmpleadoBE.Email          = txtCorreo.Text;
            objEmpleadoBE.IdEspecialidad = cboEspecialidad.SelectedValue.ToString();

            if (objEmpleadoBL.ActualizarEmpleado(objEmpleadoBE) == true)
            {
                Response.Redirect("frmEmpleados.aspx");
            }
            else
            {
                lblMensaje.Text = "Error, verifique los datos";
            }
        }
        catch (Exception ex)
        {
            lblMensaje.Text = "Se ha producido el error: " + ex.Message;
        }
    }
Exemple #2
0
        private void BtnActualizar_Click(object sender, EventArgs e)
        {
            string mensaje = "Debe seleccionar un registro válido antes de actualizar. " +
                             "Por favor seleccione un registro en la pestaña de busqueda que " +
                             "desea actualizar y vuelva a intentarlo.";

            try
            {
                Empleados  entidad    = new Empleados();
                EmpleadoBL actualizar = new EmpleadoBL();

                if (txtEmpleado.Text == string.Empty)
                {
                    txtEmpleado.Text = null;
                }
                if (txtSueldoInic.Text == string.Empty)
                {
                    txtSueldoInic.Text = "0.00";
                }
                if (txtSueldoAct.Text == string.Empty)
                {
                    txtSueldoAct.Text = "0.00";
                }

                if (cbDepto.SelectedValue.ToString() == string.Empty || cbDepto.SelectedValue.ToString() == "A")
                {
                    entidad.DeptoId = null;
                }
                else
                {
                    entidad.DeptoId = cbDepto.SelectedValue.ToString();
                }

                if (ID < 1)
                {
                    MessageBox.Show(mensaje, "Error de Actualización",
                                    MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    tabControl1.SelectedIndex = 0;
                }
                else
                {
                    mensaje            = "Registro Actualizado.";
                    entidad.CodEmp     = ID;
                    entidad.NombreEmp  = txtEmpleado.Text;
                    entidad.SueldoInic = float.Parse(txtSueldoInic.Text);
                    entidad.SueldoAct  = float.Parse(txtSueldoAct.Text);
                    entidad.Activo     = chkActivo.Checked;

                    actualizar.ActualizarEmpleado(entidad);

                    LlenarGridEmpleado();
                    MessageBox.Show(mensaje, "Actualización",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnNuevo.PerformClick();
                    tabControl1.SelectedIndex = 0;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }