public static List <Contrato> searchContratosA(string pText, int pLimit)
        {
            List <Contrato> lista = new List <Contrato>();

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand comando = new MySqlCommand("select * from contrato as c inner join Empleado as e on e.Id=c.IdEmpleado inner join " +
                                                            " Cargo as ca on ca.Id = c.IdCargo inner join Persona as p on p.Id=e.IdPersona where (" +
                                                            " upper(ca.Nombre) like '%" + pText.ToUpper() + "%' or e.Telefono like'%" + pText.ToUpper() + "%' or upper(e.correo) like '%" + pText.ToUpper() + "%' " +
                                                            " or upper(p.Nombre) like '%" + pText.ToUpper() + "%' or upper(p.Dui) like '%" + pText.ToUpper() + "%' or upper(p.Nit) like '%" + pText.ToUpper() + "%') and Estado='A' order by c.Id desc limit @pLimit", _con);
                    comando.Parameters.AddWithValue("@pLimit", pLimit);
                    comando.Parameters.AddWithValue("@Text", pText.ToUpper());

                    MySqlDataReader _reader = comando.ExecuteReader();
                    while (_reader.Read())
                    {
                        Contrato item = new Contrato(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetString(2),
                            _reader.IsDBNull(3) ? null : _reader.GetString(3),
                            _reader.GetString(4),
                            _reader.GetInt64(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            CargoDAL.getCargoById(_reader.GetInt64(5)),
                            EmpleadoDAL.getEmpleadoById(_reader.GetInt64(6))


                            );

                        lista.Add(item);
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(lista);
        }
        public static List <Contrato> getContratos(int pLimit)
        {
            List <Contrato> lista = new List <Contrato>();

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand comando = new MySqlCommand("select * from contrato order by Id desc limit @pLimit", _con);
                    comando.Parameters.AddWithValue("@pLimit", pLimit);

                    MySqlDataReader _reader = comando.ExecuteReader();
                    while (_reader.Read())
                    {
                        Contrato item = new Contrato(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetString(2),
                            _reader.IsDBNull(3) ? null : _reader.GetString(3),
                            _reader.GetString(4),
                            _reader.GetInt64(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            CargoDAL.getCargoById(_reader.GetInt64(5)),
                            EmpleadoDAL.getEmpleadoById(_reader.GetInt64(6))


                            );

                        lista.Add(item);
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(lista);
        }
        public static Contrato getContratoById(Int64 pId)
        {
            Contrato item = null;

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand cmdGetItemById = new MySqlCommand("select * from contrato where Id=@pId", _con);
                    cmdGetItemById.Parameters.AddWithValue("@pId", pId);
                    MySqlDataReader _reader = cmdGetItemById.ExecuteReader();
                    while (_reader.Read())
                    {
                        item = new Contrato(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetString(2),
                            _reader.IsDBNull(3) ? null : _reader.GetString(3),
                            _reader.GetString(4),
                            _reader.GetInt64(5),
                            _reader.GetInt64(6),
                            _reader.GetInt64(7),
                            CargoDAL.getCargoById(_reader.GetInt64(5)),
                            EmpleadoDAL.getEmpleadoById(_reader.GetInt64(6))

                            );
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(item);
        }