unit Uconexion;

interface

 uses
  SysUtils, Classes, DB, ADODB, forms, DBCtrls, Buttons, Graphics;

 procedure InitButtons(navegador:DBCtrls.TDBNavigator; TipoLetra:string);
 Function conectar(conector: TAdoconnection; base: string; directorio: string; pass: string; aplicacion: Tapplication): boolean;

implementation

type
 	TDBNavigator = class(DBCtrls.TDBNavigator);

procedure InitButtons(navegador:DBCtrls.TDBNavigator; TipoLetra:string);
const
  BtnTypeName: array[TNavigateBtn] of String = (
    'Primero', 'Anterior', 'Siguiente', 'Último', 'Añadir',  'Suprimir',
    'Editar', 'Guardar', 'Cancelar', 'Actualizar', 'Aplicar', 'Deshacer'
  );

var
	I: TNavigateBtn;

begin
	with TDBNavigator(navegador) do
		for I := Low(Buttons) to High(Buttons) do
		begin
      Buttons[I].Font.Name:= TipoLetra;
      Buttons[I].Font.Size:= 12;
      Buttons[I].Font.Style:= [fsbold];
			Buttons[I].Caption := BtnTypeName[I];
			Buttons[I].Layout := blGlyphTop;
		end;
end;


 Function conectar(conector: TAdoconnection; base: string; directorio: string; pass: string; aplicacion: Tapplication): boolean;
  var
   ruta, cadena: string;
  begin
  try
    conector.Connected:= false;
    ruta:= ExtractFilePath(application.ExeName) + '\'+ directorio + '\'+base + '.mdb';
    cadena:= 'Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=' + ruta + ';Mode=ReadWrite;Jet OLEDB:Database Password='+pass;
    Conector.ConnectionString := cadena;
    conector.Connected:= true;
    result:= true;
   except
    result:= false;
   end
  end;

end.
