Скачиваний:
36
Добавлен:
02.05.2014
Размер:
2.71 Кб
Скачать
unit Unit3;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;

type
TFormEditCard = class(TForm)
LabeledEditTypeOfCard: TLabeledEdit;
LabeledEditPIN: TLabeledEdit;
LabeledEditSumma: TLabeledEdit;
CheckBoxBlocked: TCheckBox;
DateTimePickerDateLimit: TDateTimePicker;
ButtonOpen: TButton;
ButtonSave: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure ButtonSaveClick(Sender: TObject);
procedure ButtonOpenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormEditCard: TFormEditCard;

implementation

Uses Unit2;
{$R *.dfm}

procedure TFormEditCard.ButtonOpenClick(Sender: TObject);
var FileHandle:integer;
TypeOfCard,PIN,Summa:integer;
Pbool:boolean;
Pdate:TDateTime;
Card:TCard;
begin
if OpenDialog1.Execute then
begin
try
FileHandle := FileOpen(OpenDialog1.FileName,fmOpenRead);
Card := Tcard.Create;
FileRead(FileHandle,TypeOfCard,SizeOf(integer));
Card.fTypeOfCard := TypeOfCard;
FileRead(FileHandle,Pdate,SizeOf(TdateTime));
Card.fDateLimit := Pdate;
FileRead(FileHandle,Pbool,SizeOf(boolean));
Card.fBlocked := Pbool;
FileRead(FileHandle,PIN,SizeOf(integer));
Card.fPIN := PIN;
FileRead(FileHandle,Summa,SizeOf(integer));
Card.fSumma := Summa;
FileClose(FileHandle);
except
ShowMessage('Не удалось открыть файл!');
exit;
end;
LabeledEditTypeOfCard.Text := IntToStr(Card.fTypeOfCard);
LabeledEditPIN.Text := IntToStr(Card.fPIN);
LabeledEditSumma.Text := IntToStr(Card.fSumma);
CheckBoxBlocked.Checked := Card.fBlocked;
DateTimePickerDateLimit.DateTime := Card.fDateLimit;
end;
end;

procedure TFormEditCard.ButtonSaveClick(Sender: TObject);
var FileHandle:integer;
Card:TCard;
begin
if SaveDialog1.Execute then
begin
Card := TCard.Create;
Card.fTypeOfCard := StrToInt(LabeledEditTypeOfCard.Text);
Card.fPIN := StrToInt(LabeledEditPIN.Text);
Card.fSumma := StrToInt(LabeledEditSumma.Text);
Card.fBlocked := CheckBoxBlocked.Checked;
Card.fDateLimit := DateTimePickerDateLimit.DateTime;
FileHandle := FileCreate(SaveDialog1.FileName);
FileWrite(FileHandle,Card.fTypeOfCard,SizeOf(integer));
FileWrite(FileHandle,Card.fDateLimit,SizeOf(TDateTime));
FileWrite(FileHandle,Card.fBlocked,SizeOf(boolean));
FileWrite(FileHandle,Card.fPIN,SizeOf(integer));
FileWrite(FileHandle,Card.fSumma,SizeOf(integer));
FileClose(FileHandle);
end;

end;

end.
Соседние файлы в папке Программа