Example #1
0
    public static Persona GetPersonaID(int id)
    {
        if (id <= 0)
        {
            throw new ArgumentException("Error con la id");
        }
        GetPersonaDSTableAdapters.PersonaTableAdapter adapter = new GetPersonaDSTableAdapters.PersonaTableAdapter();
        GetPersonaDS.PersonaDataTable table = adapter.GetPersonaID(id);
        Persona obj = null;

        if (table != null && table.Rows.Count == 1)
        {
            GetPersonaDS.PersonaRow row = table[0];
            obj = new Persona()
            {
                id        = row.id,
                nombre    = row.nombre,
                apellidoP = row.apellidoP,
                apellidoM = row.apellidoM,
                correo    = row.correo,
                telefono  = row.telefono
            };
        }
        return(obj);
    }
Example #2
0
    public static List <Persona> GetPersona()
    {
        GetPersonaDSTableAdapters.PersonaTableAdapter adapter = new GetPersonaDSTableAdapters.PersonaTableAdapter();
        //aƱadir getPErsona ID para buscar
        GetPersonaDS.PersonaDataTable table = adapter.GetPersonas();
        List <Persona> list = new List <Persona>();

        foreach (var row in table)
        {
            list.Add(new Persona()
            {
                id        = row.id,
                nombre    = row.nombre,
                apellidoP = row.apellidoP,
                apellidoM = row.apellidoM,
                correo    = row.correo,
                telefono  = row.telefono
            });
        }
        return(list);
    }