CODIGO
CODIGO
interface
uses
type
TLibro=Record
cod:string[4];
tit:string[20];
aut:string[30];
edi:string[20];
nej:byte;
pre:real
end;
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label6: TLabel;
Edit6: TEdit;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
lib:TLibro;
fich:file of TLibro;
NomArch:string;
implementation
{$R *.dfm}
procedure SoloLectura(Valor:Boolean);
begin
with form1 do
begin
edit1.ReadOnly:=valor;
edit2.ReadOnly:=valor;
edit3.ReadOnly:=valor;
edit4.ReadOnly:=valor;
edit5.ReadOnly:=valor;
edit6.ReadOnly:=valor
end
end;
begin
if FileExists(NomArch) then
CloseFile(fich);
close
end;
begin
NomArch:=InputBox('Archivo','Ruta y Nombre','d:\IMAGENES\Libros1\invent01.dat');
assignFile(fich,NomArch);
rewrite(fich);
bitbtn3.Enabled:=False;
bitbtn1.Enabled:=True;
SoloLectura(false);
Edit1.SetFocus
end;
begin
with lib do
begin
cod:=edit1.Text;
tit:=edit2.Text;
aut:=edit3.Text;
edi:=edit4.Text;
nej:=StrToint(edit5.Text);
pre:=StrToFloat(edit6.Text);
end;
write(fich,Lib);
ShowMessage('Registro Almacenado');
SoloLectura(true);
bitbtn1.Enabled:=false;
bitbtn4.Enabled:=true
end;
begin
SoloLectura(false);
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
edit1.SetFocus;
BitBtn1.Enabled:=true;
BitBtn4.Enabled:=false
end;
SoloLectura(true);
end;
end.