0% found this document useful (0 votes)
2 views5 pages

CODIGO

The document outlines a Delphi unit for managing a library of books, defining a record structure for book details and a form with various controls for user interaction. It includes procedures for file handling, enabling/disabling input fields, and storing book records. The form allows users to input book information and save it to a specified file, with features for reading and editing entries.

Uploaded by

Sofia Flores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

CODIGO

The document outlines a Delphi unit for managing a library of books, defining a record structure for book details and a form with various controls for user interaction. It includes procedures for file handling, enabling/disabling input fields, and storing book records. The form allows users to input book information and save it to a specified file, with features for reading and editing entries.

Uploaded by

Sofia Flores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

unit lect_de_libros;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons;

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;

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

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;

procedure TForm1.BitBtn2Click(Sender: TObject);

begin

if FileExists(NomArch) then

CloseFile(fich);

close

end;

procedure TForm1.BitBtn3Click(Sender: TObject);

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;

procedure TForm1.BitBtn1Click(Sender: TObject);

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;

procedure TForm1.BitBtn4Click(Sender: TObject);

begin

SoloLectura(false);

Edit1.Text:='';

Edit2.Text:='';

Edit3.Text:='';

Edit4.Text:='';

Edit5.Text:='';

Edit6.Text:='';

edit1.SetFocus;

BitBtn1.Enabled:=true;

BitBtn4.Enabled:=false

end;

procedure TForm1.FormActivate(Sender: TObject);


begin

SoloLectura(true);

end;

end.

You might also like