Пример #1
0
        public List <Empleado> ObtenerTodo()
        {
            List <Empleado> resultado = new List <Empleado>();

            try
            {
                string str = Ejecutor.Consultar(TABLA, campos, CONDICION_ESTADO);
                elementos = JArray.Parse(str);

                foreach (JObject el in elementos)
                {
                    resultado.Add(new Empleado()
                    {
                        id         = (int)el["id"],
                        Nombre     = el["nombre"].ToString(),
                        Apellido   = el["apellido"].ToString(),
                        Email      = el["email"].ToString(),
                        Direccion  = el["direccion"].ToString(),
                        Telefono   = el["telefono"].ToString(),
                        SueldoBase = Convert.ToDouble(el["sueldoBase"].ToString()),
                        idGerencia = (int)el["idGerencia"],
                        idUsuario  = (int)el["idUsuario"]
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(resultado);
        }
Пример #2
0
        public List <Gerencia> ObtenerTodo()
        {
            List <Gerencia> resultado = new List <Gerencia>();

            try
            {
                string str = Ejecutor.Consultar(TABLA, campos);
                elementos = JArray.Parse(str);

                foreach (JObject el in elementos)
                {
                    resultado.Add(new Gerencia()
                    {
                        id             = (int)el["id"],
                        Nombre         = el["nombre"].ToString(),
                        DerechoBono    = (bool)el["derechoBono"],
                        HorasExtras    = (bool)el["horasExtras"],
                        PorcentajeBono = (double)el["porcentajeBono"]
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(resultado);
        }
Пример #3
0
        public List <Planilla> ObtenerPorMes()
        {
            condiciones = $"Month(fecha) = {fecha.Month} AND Year(fecha) = {fecha.Year}";
            List <Planilla> resultado = new List <Planilla>();

            try
            {
                string str = Ejecutor.Consultar(TABLA, campos, condiciones);
                elementos = JArray.Parse(str);

                foreach (JObject el in elementos)
                {
                    resultado.Add(new Planilla()
                    {
                        id     = (int)el["id"],
                        Nombre = el["nombre"].ToString(),
                        Fecha  = Convert.ToDateTime(el["fecha"].ToString())
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(resultado);
        }
Пример #4
0
        public Planilla Obtener(int id)
        {
            condiciones = $"ID = {id}";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            var first = elementos.First;

            try
            {
                return(new Planilla()
                {
                    id = (int)first["id"],
                    Nombre = (string)first["nombre"],
                    Fecha = (DateTime)first["fecha"],
                    idUsuario = (int)first["idUsuario"]
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error: {ex.Message}");
            }

            return(null);
        }
        public List <DetallePlanilla> ObtenerPorEmpleadoMes(int id, DateTime mes)
        {
            List <DetallePlanilla> resultado = new List <DetallePlanilla>();

            condiciones = $"idEmpleado = {id} AND Month(fecha) = {mes.Month} AND Year(fecha) = {mes.Year}";
            try
            {
                string str = Ejecutor.Consultar(TABLA, campos, condiciones);
                elementos = JArray.Parse(str);

                foreach (JObject el in elementos)
                {
                    resultado.Add(new DetallePlanilla()
                    {
                        id         = (int)el["id"],
                        sueldoBase = (double)el["sueldoBase"],
                        fecha      = (DateTime)el["fecha"],
                        idEmpleado = (int)el["idEmpleado"],
                        idPlanilla = (int)el["idPlanilla"]
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(resultado);
        }
Пример #6
0
        public List <Usuario> ObtenerTodo()
        {
            List <Usuario> resultado = new List <Usuario>();

            try
            {
                string str = Ejecutor.Consultar(TABLA, campos, CONDICION_ESTADO);
                elementos = JArray.Parse(str);

                foreach (JObject el in elementos)
                {
                    resultado.Add(new Usuario()
                    {
                        id     = (int)el["id"],
                        Nombre = el["nombre"].ToString(),
                        Login  = el["login"].ToString(),
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(resultado);
        }
        public DetallePlanilla Obtener(int id)
        {
            condiciones = $"ID = {id}";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            var first = elementos.First;

            return(new DetallePlanilla()
            {
                id = (int)first["id"],
                SueldoBase = (double)first["sueldoBase"],
                Fecha = (DateTime)first["fecha"],
                idEmpleado = (int)first["idEmpleado"]
            });
        }
Пример #8
0
        public Gerencia Obtener(int id)
        {
            condiciones = $"id = {id}";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            var first = elementos.First;

            return(new Gerencia()
            {
                id = (int)first["id"],
                Nombre = (string)first["nombre"],
                DerechoBono = (bool)first["derechoBono"],
                HorasExtras = (bool)first["horasExtras"],
                PorcentajeBono = (double)first["porcentajeBono"]
            });
        }
Пример #9
0
        public Usuario LogIn()
        {
            condiciones = $"login = '******' AND clave = '{clave}' AND estado = true";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            if (elementos.Count != 1)
            {
                return(null);
            }

            var first = elementos.First;

            return(new Usuario()
            {
                id = (int)first["id"],
                Nombre = (string)first["nombre"],
                Login = (string)first["login"],
                Estado = (bool)first["estado"]
            });
        }
Пример #10
0
        public Usuario Obtener(int id)
        {
            condiciones = $"ID = {id}";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            if (elementos.Count != 1)
            {
                return(null);
            }

            var first = elementos.First;

            return(new Usuario()
            {
                id = (int)first["id"],
                Nombre = (string)first["nombre"],
                Login = (string)first["login"],
                Estado = (bool)first["estado"]
            });
        }
Пример #11
0
        public Empleado Obtener(int id)
        {
            condiciones = $"ID = {id} AND {CONDICION_ESTADO}";
            string str = Ejecutor.Consultar(TABLA, campos, condiciones);

            elementos = JArray.Parse(str);

            var first = elementos.First;

            return(new Empleado()
            {
                id = (int)first["id"],
                Nombre = first["nombre"].ToString(),
                Apellido = first["apellido"].ToString(),
                Email = first["email"].ToString(),
                Direccion = first["direccion"].ToString(),
                Telefono = first["telefono"].ToString(),
                sueldoBase = Convert.ToDouble(first["sueldoBase"].ToString()),
                Estado = (bool)first["estado"],
                idGerencia = (int)first["idGerencia"],
                idUsuario = (int)first["idUsuario"]
            });
        }