Esempio n. 1
0
        protected void txtEmpleado_SelectedIndexChanged(object sender, EventArgs e)
        {
            DAL.Empleados emp = new DAL.Empleados();
            emp = emp.Obtener(txtEmpleado.SelectedValue.ToString());

            txtDescripcion.Text = emp.Apellido.ToUpper();
        }
Esempio n. 2
0
        protected void grdEmpleados_SelectedIndexChanged(object sender, EventArgs e)
        {
            frmSeleccionar.Visible = false;

            LimpiarControles();
            int id = 0;

            int.TryParse(grdEmpleados.SelectedDataKey.Value.ToString(), out id);
            if (id != 0)
            {
                DAL.Empleados emp = new DAL.Empleados();
                emp = emp.Obtener(id.ToString());

                if (ViewState["EmpleadoID"] != null)
                {
                    ViewState["EmpleadoID"] = emp.Id;
                }
                else
                {
                    ViewState.Add("EmpleadoID", emp.Id);
                }

                txtCodigo.Text         = emp.Id.ToString();
                txtApellido.Text       = emp.Apellido;
                txtNombre.Text         = emp.Nombre;
                txtFechaAlta.Text      = emp.Fecha_Alta;
                txtFechaBaja.Text      = emp.Fecha_Baja;
                txtFechaCierre.Text    = emp.Fecha_Cierre;
                txtGrupo.SelectedValue = emp.Grupo;
                txtTelLaboral.Text     = emp.Tel_laboral;
                txtTelPersonal.Text    = emp.Tel_personal;
                txtPassword.Text       = emp.Password;
                txtPassword.Attributes.Add("value", emp.Password);
                txtMail.Text            = emp.Mail;
                txtFechaNacimiento.Text = emp.Fecha_Nacimiento;
                txtDomicilio.Text       = emp.Domicilio;
                txtCUIL.Text            = emp.CUIL;
                txtTarea.Text           = emp.Tarea;
                txtHijos.Text           = emp.hijos.ToString();
                txtContacto.Text        = emp.Persona_contacto;
                txtTelAlternativo.Text  = emp.Tel_Alternativo;

                txtProvincia.ClearSelection();
                //txtProvincia.Items.FindByValue(emp.Provincia).Selected = true;
                txtProvincia.SelectedValue = emp.Provincia;

                txtEstadoCivil.ClearSelection();
                //txtEstadoCivil.Items.FindByValue(emp.Estado_Civil).Selected = true;
                txtEstadoCivil.SelectedValue = emp.Estado_Civil;

                chPercibeAdelantos.Checked = emp.PercibeAdelantos;
            }
        }
Esempio n. 3
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Si")
            {
                if (ViewState["adelanto_id"] != null)
                {
                    DAL.Empleados_Adelantos emp_adelanto = new DAL.Empleados_Adelantos();
                    emp_adelanto = emp_adelanto.obtener_datos(ViewState["adelanto_id"].ToString());

                    DAL.Empleados emp = new DAL.Empleados();
                    emp = emp.Obtener(emp_adelanto.empleado_id.ToString());

                    if (emp.Fecha_Cierre != null && emp.Fecha_Cierre != "")
                    {
                        DateTime fecha_cierre   = Convert.ToDateTime(emp.Fecha_Cierre);
                        DateTime fecha_adelanto = Convert.ToDateTime(emp_adelanto.fecha);

                        if (fecha_adelanto > fecha_cierre)
                        {
                            emp_adelanto.borrar(Convert.ToInt32(ViewState["adelanto_id"]));
                            obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro());
                            limpiar();
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("El registro no puede ser borrado ya que la fecha de registro es inferior a la fecha de cierre", 3000), true);
                        }
                    }
                    else
                    {
                        emp_adelanto.borrar(Convert.ToInt32(ViewState["adelanto_id"]));
                        obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro());
                        limpiar();
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Debe seleccionar un registro para poder borrarlo", 3000), true);
                }
            }
        }
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     DAL.Empleados emp = new DAL.Empleados();
     emp = emp.Obtener(Session["id"].ToString());
     if (emp.Password.ToString() == DAL.Varios.MD5Hash(txtClaveAnterior.Text))
     {
         if (txtClaveNueva.Text == txtRepetirClave.Text)
         {
             emp.Password = txtClaveNueva.Text;
             emp.Guardar(false);
             ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operación realizada!", 3000), true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Las claves no coinciden", 3000), true);
         }
     }
     else
     {
         ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La clave anterior no es válida", 3000), true);
     }
 }
Esempio n. 5
0
        protected void btnEmpleadosDialogoSeleccionar_Click(object sender, EventArgs e)
        {
            int count           = 0;
            int count_repetidos = 0; //se usa solo para el msg_toast
            List <DAL.Empleados> empleados_asignados = (List <DAL.Empleados>)Session["empleados_asignados"];

            foreach (GridViewRow row in grdEmpleados.Rows)
            {
                CheckBox chk = (row.Cells[0].FindControl("cbox") as CheckBox);
                string   id  = row.Cells[1].Text;
                if (chk.Checked == true)
                {
                    int index = empleados_asignados.FindIndex(item => item.Id.ToString() == id);
                    if (index < 0)
                    {
                        DAL.Empleados emp = new DAL.Empleados();
                        emp = emp.Obtener(id);
                        empleados_asignados.Add(emp);
                    }
                    else
                    {
                        count_repetidos++;
                    }
                }
                count++;
            }

            if (count_repetidos == 1)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Un empleado no se agrego ya que existe en la lista de asignados"), true);
            }
            if (count_repetidos > 1)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Algunos empleados no se agregaron ya que existen en la lista de asignados"), true);
            }

            frmBuscarEmpleado.Visible = false;
            cargar_empleadosAsignados();
        }
Esempio n. 6
0
        void guardarDatos(bool nuevo)
        {
            DateTime fecha   = DateTime.Now;
            decimal  importe = 0;
            bool     errores = false;

            try
            {
                fecha = Convert.ToDateTime(txtFecha.Text);
            }
            catch
            {
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe ingresar una fecha válida."), true);
            }


            if (!decimal.TryParse(txtImporte.Text.Replace(".", ","), out importe))
            {
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe ingresar valor númerico válido en el campo importe."), true);
            }

            if (txtEmpleado.SelectedValue.ToString() == "0")
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe especificar un empleado."), true);
                errores = true;
            }

            if (txtAsignadoPor.SelectedValue.ToString() == "0")
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El campo Asignado Por no puede ser nulo"), true);
                errores = true;
            }

            DAL.Empleados emp = new DAL.Empleados();
            emp = emp.Obtener(txtEmpleado.SelectedValue.ToString());

            if (emp.Fecha_Cierre != null && emp.Fecha_Cierre != "")
            {
                if (Convert.ToDateTime(emp.Fecha_Cierre) >= fecha)
                {
                    errores = true;
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se puede cargar una operacion anterior a la fecha de cierre establecida"), true);
                }
            }

            if (!errores)
            {
                DAL.Empleados_Adelantos emp_adelantos = new DAL.Empleados_Adelantos();
                if (!nuevo)
                {
                    emp_adelantos.adelanto_id = Convert.ToInt32(ViewState["adelanto_id"].ToString());
                }
                emp_adelantos.fecha        = txtFecha.Text;
                emp_adelantos.empleado_id  = Convert.ToInt32(txtEmpleado.SelectedItem.Value);
                emp_adelantos.descripcion  = txtDescripcion.Text;
                emp_adelantos.importe      = importe;
                emp_adelantos.asignado_por = txtAsignadoPor.SelectedValue.ToString();

                emp_adelantos.Guardar(nuevo);

                limpiar();
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true);
            }
        }
Esempio n. 7
0
        void guardar(bool nuevo)
        {
            bool errores = false;

            if (nuevo)
            {
                DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos();
                int registros = 0;

                if (txtCodigo.Text != "")
                {
                    registros = grupos.obtener(txtCodigo.Text).Count;
                }

                if (registros > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("La operación no pudo realizarse ya que el código ingresado existe en la base de datos!.", 3000), true);
                    errores = true;
                }
            }

            if (ViewState["GrupoID"] == null || ViewState["GrupoID"].ToString() == "")
            {
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un grupo para poder editarlo", 3000), true);
            }

            if (txtEmpleado.SelectedValue == null || txtEmpleado.SelectedValue.ToString() == "0")
            {
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un lider para el grupo", 3000), true);
            }

            if (txtDescripcion.Text == "")
            {
                if (txtDescripcion.Text == "")
                {
                    lblDescripcion.ForeColor = Color.Red;
                }
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Los campos señalados en rojo no pueden estar vacíos", 3000), true);
            }

            DAL.Empleados emp = new DAL.Empleados();
            emp = emp.Obtener(txtEmpleado.SelectedValue.ToString());

            if (emp.es_lider(emp.Id.ToString()))
            {
                errores = true;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El empleado seleccionado ya es lider de un grupo, elimine el grupo o bien cambie de lider e intentelo nuevamente", 3000), true);
            }



            int last_id = 0;

            if (!errores)
            {
                lblDescripcion.ForeColor = Color.Black;

                DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos();
                grupos.Id     = txtCodigo.Text;
                grupos.Nombre = txtDescripcion.Text;
                grupos.lider  = txtEmpleado.SelectedValue.ToString();

                if (grupos.Guardar(nuevo, out last_id))
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Operacion realizada!", 3000), true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Error al realizar el proceso", 3000), true);
                }

                if (nuevo)
                {
                    logs.modulo  = "RRHH - GRUPOS";
                    logs.accion  = "AGREGO EL GRUPO: " + grupos.Nombre.ToUpper();
                    logs.usuario = Session["usr"].ToString();
                    if (Session["id"] != null)
                    {
                        logs.empleado_id = Session["id"].ToString();
                    }
                    logs.guardar();

                    emp.Grupo = last_id.ToString();
                    emp.Guardar(false);
                }
                else
                {
                    logs.modulo  = "RRHH - GRUPOS";
                    logs.accion  = "MODIFICO EL GRUPO: " + grupos.Nombre.ToUpper();
                    logs.usuario = Session["usr"].ToString();
                    if (Session["id"] != null)
                    {
                        logs.empleado_id = Session["id"].ToString();
                    }
                    logs.guardar();

                    emp.Grupo = txtCodigo.Text;
                    emp.Guardar(false);
                }

                limpiar();
            }
        }