.


:




:

































 

 

 

 


.. Delphi. Delphi. 2006 . - 1152 .




 

- , , "" type. "" :

type <' > = record
<' 1>:<>;
..................
<' N>:<>;
end;
var <' >:<' >;

:

' ' "";

record Delphi, , () ;

_i _i ' i- () , i=1..., ;

end Delphi, , .

:

Type

TPerson = record

FName: string [20];

LName: string [20];

day: integer;

month: integer;

year: integer;

address: string[50];

End;

TDate = record

day: integer; month: integer; year: integer;

End;

ϳ - ( ), :

Var

student: TPerson;

birthday: TDate;

, () - (), ' ' , . ,

ShowMessage ('': ', student.FName + #13 + ': ', student.address);

f_name (') address () - student.

- . ' , . , student var :

student: record

FName:string[20];

LName:string[20];

day:integer;

month:integer;

year:integer;

address:string[50];

End;

 

 

7.2. with

with -. with :

with ' do

Begin

( }

End;

:

' ' -;

with Delphi, , , end, ', ' .

,

student :record //

FName: string [30]; //

LName: string [20]; // '

address: string [50]; //

End;

Edit1, Edit2 Edit3 ,

student.FName:= Edit1.text;

student.LName:= Edit2.text;

student.address:= Edit3.text;

:

with student do begin

FName:= Edit1.text;

LName:= Edit2.text;

address:= Edit3.text;

End;

7.3.

 

. , - , , "". , :

  type rson = record FName: string [20]; LName: string[20]; address: string[50]; end; var f: file of TPerson;

, TPerson.

. Assign ' . ( , ). ϳ .

, , , , . (. 8.1) , TOCinka.

. 7.1. ³

 

c ( Edit). ComboBox ( ).

ComboBox, Standard (. 7.2), -, , ' , .

. 7.2. ComboBox . 8.1 ComboBox.

7.1. ComboBox

       
   
  Name ' .  
  Text , -  
  Items ,  
  DropDownCount ʳ , ,  
  Left ³  
  Top ³  
  Height ( -)  
  Width  
  Font ,  
  ParentFont  
       

 

, ' , , . , ObjectInspector Items, ( ) (. 7.3).

 

 

. 7.3. ComboBox1 ComboBox2

7.1.

˳ 7.1.

unit AddRecord;

interface

Uses

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

Type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Edit1: TEdit; //

ComboBox1: TComboBox; //

ComboBox2: TComboBox; //

RadioGroup1: TRadioGroup; //

Button1: TButton; //

Label3: TLabel;

Label4: TLabel;

procedure FormActivate(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Button1Click(Sender: TObject);

Private

{ Private declarations }

Public

{ Public declarations }

End;

//

TBall = (NEZADOV, ZADOV, DOBRE, VIDMIN);

TOcinka=record //

NumberGroup: string [80]; // -

NazvaPredmt: string [100]; //

fName: string[40]; //

ball: TBall; //

End;

Var

Form1: TForm1;

f: file of TOcinka; //

Implementation

{$R *.DFM}

//

procedure TForm1.FormActivate(Sender: TObject);

Var

resp: word; //

Begin

AssignFile(f, 'c\ocinka.db');

{$I-}

Reset (f); //

Seek(f, FileSize(f)); //

{$I+}

if IOResult = 0 then Button1.Enabled:=TRUE

//

Else begin

resp:=MessageDlg(' .'

+ ' ?', mtlnformation,[mbYes,mbNo],0);

if resp = mrYes then

Begin

{$I-}

rewrite(f);

{$I+}

if IOResult = 0 then Button1.Enabled:=TRUE

else ShowMessage(' .');

End;

End;

End;

procedure TForm1.Button1Click(Sender: TObject); //

var ocinka: TOcinka;

Begin

with ocinka do begin

NumberGroup:= ComboBox1.Text;

NazvaPredmt:= ComboBox2.Text;

FName:= Edit1.Text;

case RadioGroup1.ItemIndex of

0: ball:= NEZADOV;

1: ball:= ZADOV;

2: ball:= DOBRE;

3:ball:= VIDMIN;

End;

End;

write(f,ocinka); //

End;

//

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

Begin

CloseFile(f); //

End;

End.

TForm1.FormActivate . , . AppendFile, , , . Rewrite , Seek / . seek Filesize, ( ).

TForm1.Button1Click, (Button1), . NumberGroup NazvaPredmt , , Text - (omboBox1) (ComboBox2).

fName ( Edit1), ball RadioGroup1.

TForm1. FormClose TOCinka (TForm1.FormActivate TForm1.Button1lick), type . f .

, . , . items Add. , ( Tform1.FormActivate):

Form1.ComboBox1.Item.Add('-11');

Form1.ComboBox1.Item.Add('-12');

Form1.ComboBox1.Item.Add('-13');

Form1.ComboBox1.Item.Add('-11');

Form1.ComboBox1.Item.Add('-12');

7.5.

, . , . 7.4, 7.2, , , , , , , , , . Memo1.

. 7.2 .

Memo1 , ReadOnly ( , ) True. scrollBars ( ) Memo , . scrollBars ssNone, . , ScrollBars ssVertical.

7.2.

       
   
  RadioButton1. Checked True  
  Label1.Enabled False  
  ComboBox1. Enabled False  
  Memo1. Readonly True  
  Memo1. ScroiiBars ssVertical  
       

- ComboBox1, - , . - items.

- ( ), Enabled ComboBox1 Label1 False.

- - (ComboBox1) . 䳿 Onclick RadioButton2 ComboBox1.

. 7.4. ³

˳ 7.2.

unit ReadRec;

Interface

Uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

Type

TForm1 = class(TForm)

RadioButton1: TRadioButton; //

RadioButton2: TRadioButton; //

//

Button1: TButton;

GroupBox1: TGroupBox;

Label1: TLabe1;

procedure Button1Click(Sender: TObject);

procedure RadioButton2Click(Sender: TObject);

procedure RadioButton1Click(Sender: TObject);

ComboBox1: TComboBox; //

//

Memo1: TMemo; // ,

//

private

{ Private declarations }

public

{ Public declarations }

End;

Var

Form1: TForm1;

Implementation

{$R *.DFM}

Type

TBall = (NEZADOV, ZADOV, DOBRE, VIDMIN); //

TOcinka=record //

NumberGroup: string [80]; // -

NazvaPredmt: string [100]; //

FName: string[40]; //

ball: TBall; //

End;

procedure TForm1.Button1Click(Sender: TObject);

Var

f: file of TOcinka; //

rec: TOcinka; // ,

n: integer; // - ,

st: string[80];

Begin

AssignFile(f,'c:\ocinka.db');

{$I-}

Reset (f); //

{$I-}

if IOResult < > 0 then begin

ShowMessage(' .');

Exit;

End;

//

if RadioButton2.Checked then

Memo1.Lines.Add('*** ' + ComboBox1.Text + ' ***');

n:= 0;

Memo1.Clear; // Memo

while not EOF(f) do begin

read(f, rec); //

if RadioButton1.Checked or

(rec.NumberGroup = ComboBox1.Text) then begin

n:= n + 1;

st:= rec.fName+ ', ' + rec.NazvaPredmt;

if RadioButton1.Checked then

st:= st + ', '+ rec.NumberGroup;

case rec.ball of

VIDMIN: st:= st+ ', ';

DOBRE:st:= st+ ', ';

ZADOV:st:= st+ ', ';

NEZADOV:st:= st+ ', ';

End;

Memo1.Lines.Add(st); end;

End;

CloseFile(f); if n = 0 then

ShowMessage(' .');

End;

//

procedure TForm1.RadioButton2Click(Sender: TObject);

Begin

Label1.Enabled:= True;

ComboBox1.Enabled:= True; // -

ComboBox1.SetFocus; // -

End;

//

procedure TForm1.RadioButton1Click(Sender: TObject);

Begin

Label1.Enabled:= False;

ComboBox1.Enabled:= False; // -

End;

End.

TForm1.Button1Click , . Memo1, , NumberGroup - , ComboBox1, RadioButton1.

Memo Memo1.Lines.Add(st), Add () Memo1.

 

 


:

1. ?

2. ?

3. ?

4. ?

 

˳:

 

.. Delphi. Delphi. 2006 . - 1152 .

2. .. Delphi 2006. : Delphi, , Win32 .NET, 2006 . - 1152 .





:


: 2017-02-25; !; : 539 |


:

:

, .
==> ...

1526 - | 1376 -


© 2015-2024 lektsii.org - -

: 0.125 .