:






 

:

Quot;

"

 

: : . . . . . 107226, 6  
, : . .

 

 

- 2007


6

 

: TopenDialog TSaveDialog. .

: , : ..., , , . 144 .

 

 

:

unit Unit1;

 

interface

 

uses

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

Dialogs, StdCtrls, ExtCtrls, Buttons;

 

type

TForm1 = class(TForm)

Panel1: TPanel;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Button1: TButton;

OpenDialog1: TOpenDialog;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

SaveDialog1: TSaveDialog;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Button5: TButton;

Memo1: TMemo;

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

Type

info = record

name : string[40]; //Ïîëå ÔÈÎ

number : integer; //Ïîëå òàáåëüíîãî íîìåðà

kol : integer ; //Ïîëå êîë-âà ÷àñîâ

tarif : integer; //Ïîëå ïî÷àñàâîãî òàðèôà

zp : extended;

end;

 

var

zp : extended;

fz : file of info; //Ôàéë òèïà çàïèñü



ft : TextFile; //Òåêñòîâîé ôàéë

inf : array[1..100] of info; //Ìàññèâ çàïèñåé

nzap : integer; //Íîìåð çàïèñè

FileNameZ, FileNameT : string; //Èìÿ ôàéëà

 

 

var

Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

Edit1.Text := '';

Edit2.Text := '';

Edit3.Text := '';

Edit4.Text := '';

Memo1.Clear;

Button1.Hide;

nzap:=0;

 

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

nzap:=nzap+1;

with inf[nzap] do

begin

name :=Edit1.Text;

number:=StrToInt(Edit2.Text);

kol :=StrToInt(Edit3.Text);

tarif :=StrToInt(Edit4.Text);

Memo1.Lines.Add(name+', '+IntToStr(number)+' íîìåð, '+IntToStr(kol)+' ÷àñîâ, '+IntToStr(tarif)+' ðóá/÷');

end;

 

Write(fz,inf[nzap]); //çàïèñü â ôàéë

Edit1.Text := '';

Edit2.Text := '';

Edit3.Text := '';

Edit4.Text := '';

end;

 

procedure TForm1.Button2Click(Sender: TObject);

begin

Memo1.Clear;

OpenDialog1.Title:='Ñîçäàòü íîâûé ôàéë';



//Èçìåíåíèå çàãîëîâêà îêíà äèàëîãî

If OpenDialog1.Execute then

//Âûïîëíåíèå ñòàíäàðòíîãî äèàëîãî âûáîðà èìåíè ôàéëà

begin

FileNameZ:=OpenDialog1.FileName;

//Âîçâðàøåíèå èìåíè äèñêîâîãî ôàéëà

AssignFile(fz,FileNameZ);

//Ñâÿçûâàíèå ôàéëîâîé ïåðåìåííîé fz ñ èìåíåì ôàéëà

Rewrite(fz);//Ñîçäàíèå íîâîãî ôàéëà

Button1.Show;//Ñäåëàòü âèäèìîé êíîïêó "Ââåñòè çàïèñü"

end;

end;

 

procedure TForm1.Button3Click(Sender: TObject);

begin

Memo1.Clear;

If OpenDialog1.Execute then

//Âûïîëíåíèå ñòàíäàðòíîãî äèàîëãà âûáîðà èìåíè ôàéëà

begin

FileNameZ:=OpenDialog1.FileName;

//Âîçâðàùåíèå èìåíè äèñêîâîãî ôàéëà

AssignFile(fz,FileNameZ);

//Ñâÿçûâàíèå ôàéëîâîé ïåðåìåííîé fz ñ èìåíåì ôàéëà

Reset(fz);//Îòêðûòèå ñóùåñòâóþùåãî ôàéëà

end;

nzap:=0;

While not EOF(fz) do

begin

nzap:=nzap+1;

Read(fz,inf[nzap]);//×òåíèå çàïèñè èç ôàéëà

with inf[nzap] do

Memo1.Lines.Add(name+', '+IntToStr(number)+' íîìåð, '+IntToStr(kol)+' ÷àñîâ, '+IntToStr(tarif)+' ðóá/÷');

end;

Button1.Show;//Ñäåëàòü âèäèìîé êíîïêó "Ââåñòè çàïèñü"

end;

 

procedure TForm1.Button4Click(Sender: TObject);

//Âûâîä çàðïëàò ðàáîòíèêîâ

var

i :word;

//zp: extended;

begin

Memo1.Clear;

Memo1.Lines.Add(' Çàðïëàòû ðàáî÷èõ ñîñòàâëÿþò:');

Memo1.Lines.Add('************************************************************************');

for i:=1 to nzap do

begin

If inf[i].kol>144 then

inf[i].zp:= (144*inf[i].tarif+(inf[i].kol-144)*inf[i].tarif*2)-0.12*(144*inf[i].tarif+(inf[i].kol-144)*inf[i].tarif*2)

else inf[i].zp:=inf[i].kol * inf[i].tarif - (inf[i].kol * inf[i].tarif * 0.12);

with inf[i] do

Memo1.Lines.Add(name+' - '+FloatToStr(zp)+' ðóá');

end;

end;

 

procedure TForm1.Button5Click(Sender: TObject);

//Ñîõðàíåíèå

var

i:word;

begin

If SaveDialog1.Execute then

//Âûïîëíåíèå ñòàíäàðòíîãî äèàëîãà âûáîðà èìåíè ôàéëà

begin

FileNameT:=SaveDialog1.FileName;

//Âîçâðàùåíèå èìåíè äèñêîâîãî ôàéëà

AssignFile(ft,FileNameT);

//Ñâÿçûâàíèå ôàéëîâîé ïåðåìåííîé ft ñ èìåíåì ôàéëà

Rewrite(ft);//Îòêðûòèå íîâîãî òåêñòîâîãî ôàéëà

end;

for i:=1 to nzap do

with inf[i] do

//Writeln(ft,i:4,'. ',name,' .. ò/í-',number,' .. ÷àñû-',kol,' .. òàðèô-',tarif);

Writeln(ft,i:4,'. ',name,' Çàðïëàòà:',zp:10);

//Çàïèñü â òåêñòîâûé ôàéë

CloseFile(ft);//Çàêðûòèå òåêñòîâîãî ôàéëà

end;

 

end.

:

 

: : TopenDialog TSaveDialog. .

.

<== | ==>
|

mylektsii.ru - - 2015-2018 . (0.109 .)