Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
мой диплом.docx
Скачиваний:
3
Добавлен:
23.09.2019
Размер:
1.38 Mб
Скачать

Приложение б

Входные формы приложения

Общая входная форма

Входная форма для преподавателя

Входная форма для студента

Форма для выбора действия преподавателя

Форма создания новой группы

Форма редактирования группы

Форма просмотра группы

Форма создания функций для домашнего задания

Форма для выбора действий студенту

Форма получения домашнего задания

Форма получения домашнего задания

Приложение в

Выходные формы

Форма после входа преподавателя

Форма создания новой группы

Форма редактирования группы

Форма просмотра группы

1 страничка файла Microsoft Word. Вариант №1 созданных преподавателей функций

2 страничка файла Microsoft Word. Вариант №2 созданных преподавателей функций

3 страничка файла Microsoft Word. Вариант №3 созданных преподавателей функций

4 страничка файла Microsoft Word. Вариант №4 созданных преподавателей функций

Форма входа студента

Страничка файла Microsoft Word. Домашнее задание, полученное студентом программно.

Вывод оценки студенту после проверки домашнего задания

Приложение г

Листинг программы (Unit1).

unit Unit1;

interface

uses

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

Dialogs, StdCtrls, Mask, ExtCtrls, jpeg;

type

TForm1 = class(TForm)

Edit1: TEdit;

Label2: TLabel;

Label3: TLabel;

Button2: TButton;

ComboBox1: TComboBox;

MaskEdit1: TMaskEdit;

Panel1: TPanel;

Panel2: TPanel;

Label4: TLabel;

Label5: TLabel;

Edit2: TEdit;

Edit3: TEdit;

Image1: TImage;

procedure Button2Click(Sender: TObject);

procedure ComboBox1Change(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses Unit2, Unit3, Unit4, Unit5, Unit6;

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);

var

s:string;

sl: TStringList;

i: integer;

b: boolean;

begin

s:=ComboBox1.Items[ComboBox1.ItemIndex];

if s = 'Преподаватель' then

begin

if (edit1.Text='') or (MaskEdit1.text='') then

ShowMessage('Введите Фамилию и/или Пароль!')

else

begin

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\prep.txt' );

for i := 0 to sl.Count-1 do

if Pos( Edit1.Text, sl[i] ) > 0 then

if Pos( MaskEdit1.Text, sl[i+1] ) > 0 then

begin

form6.Show;

form6.label1.caption:=Edit1.Text;

end

else

ShowMessage('Неверно введен логин и/или пароль!!!');

sl.Free; end; end;

if s = 'Студент' then

begin

if (edit2.Text='') or (edit3.text='') then

ShowMessage('Введите Фамилию и/или Группу!')

else

begin

if FileExists('spiski\'+Edit3.Text+'.txt') then

begin

b:=false;

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\'+Edit3.Text+'.txt' );

for i := 0 to sl.Count-1 do

if Pos( Edit2.Text, sl[i] ) > 0 then

begin

form4.label1.caption:=Edit2.Text;

form4.label2.caption:=Edit3.Text;

form5.Show;

b:=true;

break;

end;

if not b then

ShowMessage('Неверно введена фамилия и/или группа');

sl.Free;

end

else

Begin

ShowMessage('Неправильно введен № группы!');

Edit3.Text:='';

end;

end;

end;

end;

procedure TForm1.ComboBox1Change(Sender: TObject);

var

s:string;

begin

Edit1.Text:='';

Edit2.Text:='';

Edit3.Text:='';

MaskEdit1.Text:='';

s:=ComboBox1.Items[ComboBox1.ItemIndex];

if s = 'Преподаватель' then

begin

Panel1.Visible:=true;

Panel2.Visible:=false;

end;

if s = 'Студент' then

begin

Panel2.Visible:=true;

Panel1.Visible:=false;

end;

end;

end.

Листинг программы (Unit2).

unit Unit2;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls, ComObj, WordXP, OleServer;

type

TForm2 = class(TForm)

GroupBox1: TGroupBox;

Label7: TLabel;

Label8: TLabel;

ChB11: TCheckBox;

CoB11: TComboBox;

Button2: TButton;

CoB12: TComboBox;

ChB12: TCheckBox;

Label9: TLabel;

ChB13: TCheckBox;

CoB13: TComboBox;

Label10: TLabel;

ChB14: TCheckBox;

GroupBox2: TGroupBox;

Label1: TLabel;

Label2: TLabel;

ChB21: TCheckBox;

CoB21: TComboBox;

Button1: TButton;

CoB22: TComboBox;

ChB22: TCheckBox;

Label3: TLabel;

ChB23: TCheckBox;

CoB23: TComboBox;

Label4: TLabel;

ChB24: TCheckBox;

Label6: TLabel;

GroupBox3: TGroupBox;

Label13: TLabel;

Label14: TLabel;

ChB31: TCheckBox;

CoB31: TComboBox;

Button3: TButton;

CoB32: TComboBox;

ChB32: TCheckBox;

Label15: TLabel;

ChB33: TCheckBox;

CoB33: TComboBox;

Label16: TLabel;

ChB34: TCheckBox;

GroupBox4: TGroupBox;

Label5: TLabel;

Label11: TLabel;

Label12: TLabel;

Label17: TLabel;

ChB41: TCheckBox;

CoB41: TComboBox;

Button4: TButton;

CoB42: TComboBox;

ChB42: TCheckBox;

ChB43: TCheckBox;

CoB43: TComboBox;

ChB44: TCheckBox;

GroupBox5: TGroupBox;

Label18: TLabel;

Label19: TLabel;

Label20: TLabel;

Label21: TLabel;

ChB51: TCheckBox;

CoB51: TComboBox;

Button5: TButton;

CoB52: TComboBox;

ChB52: TCheckBox;

ChB53: TCheckBox;

CoB53: TComboBox;

ChB54: TCheckBox;

Panel1: TPanel;

Panel2: TPanel;

Panel3: TPanel;

Panel4: TPanel;

Label22: TLabel;

Label23: TLabel;

Label26: TLabel;

Label24: TLabel;

Label25: TLabel;

Label27: TLabel;

Label28: TLabel;

Label29: TLabel;

Label30: TLabel;

Label31: TLabel;

Label32: TLabel;

Label33: TLabel;

Label34: TLabel;

Label35: TLabel;

Label36: TLabel;

Label37: TLabel;

Label38: TLabel;

Label39: TLabel;

Label40: TLabel;

Label41: TLabel;

Label42: TLabel;

Label43: TLabel;

Label44: TLabel;

Label45: TLabel;

Button6: TButton;

WordApplication1: TWordApplication;

Button7: TButton;

Memo1: TMemo;

Memo2: TMemo;

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button2Click(Sender: TObject);

var

s1,s2,s3,y1,y2,y3: string;

x1l1,x2l1,x3l1,x4l1:string;

x1l2,x2l2,x3l2,x4l2:string;

x1l3,x2l3,x3l3,x4l3:string;

x1l4,x2l4,x3l4,x4l4:string;

begin

Label23.Caption:='';

Label24.Caption:='';

Label25.Caption:='';

Label26.Caption:='';

if (CoB11.Text='') or (CoB12.Text='') or (CoB13.Text='') then

ShowMessage('Заполните все операции 1 функции!!!')

else

begin

begin

if Chb11.Checked = true then

begin

x1l1:='not x1 ';

x1l2:='x1 ';

x1l3:='not x1 ';

x1l4:='not x1 ';

end

else

x1l4:='x1 ';

x1l1:='x1 ';

x1l3:='x1 ';

x1l2:='not x1 ';

end;

Begin

s1:=Cob11.Items[Cob11.ItemIndex];

if s1 = 'Конъюнкция (*)' then

y1:='and ';

if s1 = 'Дизъюнкция (+)' then

y1:='or ';

if s1 = 'Исключающее (ИЛИ)' then

y1:='xor ';

end;

begin

if Chb12.Checked = true then

begin

x2l4:='not x2 ';

x2l1:='not x2 ';

x2l2:='x2 ';

x2l3:='x2 ';

end

else

x2l4:='x2 ';

x2l2:='not x2 ';

x2l1:='x2 ';

x2l3:='not x2 ';

end;

Begin

s2:=Cob12.Items[Cob12.ItemIndex];

if s2 = 'Конъюнкция (*)' then

y2:='and ';

if s2 = 'Дизъюнкция (+)' then

y2:='or ';

if s2 = 'Исключающее (ИЛИ)' then

y2:='xor ';

end;

begin

if Chb13.Checked = true then

begin

x3l4:='not x3 ';

x3l2:='not x3 ';

x3l1:='x3 ';

x3l3:='not x3 ';

end

else

x3l4:='x3 ';

x3l2:='x3 ';

x3l1:='not x3 ';

x3l3:='not x3 ';

end;

Begin

s3:=Cob13.Items[Cob13.ItemIndex];

if s3 = 'Конъюнкция (*)' then

y3:='and ';

if s3 = 'Дизъюнкция (+)' then

y3:='or ';

if s3 = 'Исключающее (ИЛИ)' then

y3:='xor ';

end;

begin

if Chb14.Checked = true then

begin

x4l4:='not x4 ';

x4l1:='not x4 ';

x4l2:='x4 ';

x4l3:='not x4 ';

end

else

x4l4:='x4 ';

x4l1:='x4 ';

x4l2:='not x4 ';

x4l3:='x4 ';

end;

begin

Label23.Caption:=x1l4+y1+x2l4+y2+x3l4+y3+x4l4;

Label24.Caption:=x1l1+y2+x2l1+y3+x3l1+y1+x3l1;

Label25.Caption:=x1l2+y3+x3l2+y2+x3l2;

Label26.Caption:=x1l3+y1+x2l3+y2+x3l3+y3+x4l3+y1+x1l3;

end; end;

end;

procedure TForm2.Button1Click(Sender: TObject);

var

s1,s2,s3,y1,y2,y3: string;

x1l1,x2l1,x3l1,x4l1:string;

x1l2,x2l2,x3l2,x4l2:string;

x1l3,x2l3,x3l3,x4l3:string;

x1l4,x2l4,x3l4,x4l4:string;

begin

Label30.Caption:='';

Label31.Caption:='';

Label32.Caption:='';

Label33.Caption:='';

if (CoB21.Text='') or (CoB22.Text='') or (CoB23.Text='') then

ShowMessage('Заполните все операции 2 функции!!!')

else

begin

begin

if Chb21.Checked = true then

begin

x1l1:='not x1 ';

x1l2:='x1 ';

x1l3:='not x1 ';

x1l4:='not x1 ';

end

else

x1l4:='x1 ';

x1l1:='x1 ';

x1l3:='x1 ';

x1l2:='not x1 ';

end;

Begin

s1:=Cob21.Items[Cob21.ItemIndex];

if s1 = 'Конъюнкция (*)' then

y1:='and ';

if s1 = 'Дизъюнкция (+)' then

y1:='or ';

if s1 = 'Исключающее (ИЛИ)' then

y1:='xor ';

end;

begin

if Chb22.Checked = true then

begin

x2l4:='not x2 ';

x2l1:='not x2 ';

x2l2:='x2 ';

x2l3:='x2 ';

end

else

x2l4:='x2 ';

x2l2:='not x2 ';

x2l1:='x2 ';

x2l3:='not x2 ';

end;

Begin

s2:=Cob22.Items[Cob22.ItemIndex];

if s2 = 'Конъюнкция (*)' then

y2:='and ';

if s2 = 'Дизъюнкция (+)' then

y2:='or ';

if s2 = 'Исключающее (ИЛИ)' then

y2:='xor ';

end;

begin

if Chb23.Checked = true then

begin

x3l4:='not x3 ';

x3l2:='not x3 ';

x3l1:='x3 ';

x3l3:='not x3 ';

end

else

x3l4:='x3 ';

x3l2:='x3 ';

x3l1:='not x3 ';

x3l3:='not x3 ';

end;

Begin

s3:=Cob23.Items[Cob23.ItemIndex];

if s3 = 'Конъюнкция (*)' then

y3:='and ';

if s3 = 'Дизъюнкция (+)' then

y3:='or ';

if s3 = 'Исключающее (ИЛИ)' then

y3:='xor ';

end;

begin

if Chb24.Checked = true then

begin

x4l4:='not x4 ';

x4l1:='not x4 ';

x4l2:='x4 ';

x4l3:='not x4 ';

end

else

x4l4:='x4 ';

x4l1:='x4 ';

x4l2:='not x4 ';

x4l3:='x4 ';

end;

begin

Label30.Caption:=x1l4+y1+x2l4+y2+x3l4+y3+x4l4;

Label32.Caption:=x1l1+y2+x2l1+y3+x3l1+y1+x3l1;

Label33.Caption:=x1l2+y3+x3l2+y2+x3l2;

Label31.Caption:=x1l3+y1+x2l3+y2+x3l3+y3+x4l3+y1+x1l3;

end;

end;

end;

procedure TForm2.Button3Click(Sender: TObject);

var

s1,s2,s3,y1,y2,y3: string;

x1l1,x2l1,x3l1,x4l1:string;

x1l2,x2l2,x3l2,x4l2:string;

x1l3,x2l3,x3l3,x4l3:string;

x1l4,x2l4,x3l4,x4l4:string;

begin

Label34.Caption:='';

Label35.Caption:='';

Label36.Caption:='';

Label37.Caption:='';

if (CoB31.Text='') or (CoB32.Text='') or (CoB33.Text='') then

ShowMessage('Заполните все операции 3 функции!!!')

else

begin

begin

if Chb31.Checked = true then

begin

x1l1:='not x1 ';

x1l2:='x1 ';

x1l3:='not x1 ';

x1l4:='not x1 ';

end

else

x1l4:='x1 ';

x1l1:='x1 ';

x1l3:='x1 ';

x1l2:='not x1 ';

end;

Begin

s1:=Cob31.Items[Cob31.ItemIndex];

if s1 = 'Конъюнкция (*)' then

y1:='and ';

if s1 = 'Дизъюнкция (+)' then

y1:='or ';

if s1 = 'Исключающее (ИЛИ)' then

y1:='xor ';

end;

begin

if Chb32.Checked = true then

begin

x2l4:='not x2 ';

x2l1:='not x2 ';

x2l2:='x2 ';

x2l3:='x2 ';

end

else

x2l4:='x2 ';

x2l2:='not x2 ';

x2l1:='x2 ';

x2l3:='not x2 ';

end;

Begin

s2:=Cob32.Items[Cob32.ItemIndex];

if s2 = 'Конъюнкция (*)' then

y2:='and ';

if s2 = 'Дизъюнкция (+)' then

y2:='or ';

if s2 = 'Исключающее (ИЛИ)' then

y2:='xor ';

end;

begin

if Chb33.Checked = true then

begin

x3l4:='not x3 ';

x3l2:='not x3 ';

x3l1:='x3 ';

x3l3:='not x3 ';

end

else

x3l4:='x3 ';

x3l2:='x3 ';

x3l1:='not x3 ';

x3l3:='not x3 ';

end;

Begin

s3:=Cob33.Items[Cob33.ItemIndex];

if s3 = 'Конъюнкция (*)' then

y3:='and ';

if s3 = 'Дизъюнкция (+)' then

y3:='or ';

if s3 = 'Исключающее (ИЛИ)' then

y3:='xor ';

end;

begin

if Chb34.Checked = true then

begin

x4l4:='not x4 ';

x4l1:='not x4 ';

x4l2:='x4 ';

x4l3:='not x4 ';

end

else

x4l4:='x4 ';

x4l1:='x4 ';

x4l2:='not x4 ';

x4l3:='x4 ';

end;

begin

Label34.Caption:=x1l4+y1+x2l4+y2+x3l4+y3+x4l4;

Label37.Caption:=x1l1+y2+x2l1+y3+x3l1+y1+x3l1;

Label35.Caption:=x1l2+y3+x3l2+y2+x3l2;

Label36.Caption:=x1l3+y1+x2l3+y2+x3l3+y3+x4l3+y1+x1l3;

end;

end;

end;

procedure TForm2.Button4Click(Sender: TObject);

var

s1,s2,s3,y1,y2,y3: string;

x1l1,x2l1,x3l1,x4l1:string;

x1l2,x2l2,x3l2,x4l2:string;

x1l3,x2l3,x3l3,x4l3:string;

x1l4,x2l4,x3l4,x4l4:string;

begin

Label38.Caption:='';

Label39.Caption:='';

Label40.Caption:='';

Label41.Caption:='';

if (CoB41.Text='') or (CoB42.Text='') or (CoB43.Text='') then

ShowMessage('Заполните все операции 4 функции!!!')

else

begin

begin

if Chb41.Checked = true then

begin

x1l1:='not x1 ';

x1l2:='x1 ';

x1l3:='not x1 ';

x1l4:='not x1 ';

end

else

x1l4:='x1 ';

x1l1:='x1 ';

x1l3:='x1 ';

x1l2:='not x1 ';

end;

Begin

s1:=Cob41.Items[Cob41.ItemIndex];

if s1 = 'Конъюнкция (*)' then

y1:='and ';

if s1 = 'Дизъюнкция (+)' then

y1:='or ';

if s1 = 'Исключающее (ИЛИ)' then

y1:='xor ';

end;

begin

if Chb42.Checked = true then

begin

x2l4:='not x2 ';

x2l1:='not x2 ';

x2l2:='x2 ';

x2l3:='x2 ';

end

else

x2l4:='x2 ';

x2l2:='not x2 ';

x2l1:='x2 ';

x2l3:='not x2 ';

end;

Begin

s2:=Cob42.Items[Cob42.ItemIndex];

if s2 = 'Конъюнкция (*)' then

y2:='and ';

if s2 = 'Дизъюнкция (+)' then

y2:='or ';

if s2 = 'Исключающее (ИЛИ)' then

y2:='xor ';

end;

begin

if Chb43.Checked = true then

begin

x3l4:='not x3 ';

x3l2:='not x3 ';

x3l1:='x3 ';

x3l3:='not x3 ';

end

else

x3l4:='x3 ';

x3l2:='x3 ';

x3l1:='not x3 ';

x3l3:='not x3 ';

end;

Begin

s3:=Cob43.Items[Cob43.ItemIndex];

if s3 = 'Конъюнкция (*)' then

y3:='and ';

if s3 = 'Дизъюнкция (+)' then

y3:='or ';

if s3 = 'Исключающее (ИЛИ)' then

y3:='xor ';

end;

begin

if Chb44.Checked = true then

begin

x4l4:='not x4 ';

x4l1:='not x4 ';

x4l2:='x4 ';

x4l3:='not x4 ';

end

else

x4l4:='x4 ';

x4l1:='x4 ';

x4l2:='not x4 ';

x4l3:='x4 ';

end;

begin

Label38.Caption:=x1l4+y1+x2l4+y2+x3l4+y3+x4l4;

Label39.Caption:=x1l1+y2+x2l1+y3+x3l1+y1+x3l1;

Label40.Caption:=x1l2+y3+x3l2+y2+x3l2;

Label41.Caption:=x1l3+y1+x2l3+y2+x3l3+y3+x4l3+y1+x1l3;

end;

end;

end;

procedure TForm2.Button5Click(Sender: TObject);

var

s1,s2,s3,y1,y2,y3: string;

x1l1,x2l1,x3l1,x4l1:string;

x1l2,x2l2,x3l2,x4l2:string;

x1l3,x2l3,x3l3,x4l3:string;

x1l4,x2l4,x3l4,x4l4:string;

begin

Label42.Caption:='';

Label43.Caption:='';

Label44.Caption:='';

Label45.Caption:='';

if (CoB51.Text='') or (CoB52.Text='') or (CoB53.Text='') then

ShowMessage('Заполните все операции 5 функции!!!')

else

begin

begin

if Chb51.Checked = true then

begin

x1l1:='not x1 ';

x1l2:='x1 ';

x1l3:='not x1 ';

x1l4:='not x1 ';

end

else

x1l4:='x1 ';

x1l1:='x1 ';

x1l3:='x1 ';

x1l2:='not x1 ';

end;

Begin

s1:=Cob51.Items[Cob51.ItemIndex];

if s1 = 'Конъюнкция (*)' then

y1:='and ';

if s1 = 'Дизъюнкция (+)' then

y1:='or ';

if s1 = 'Исключающее (ИЛИ)' then

y1:='xor ';

end;

begin

if Chb52.Checked = true then

begin

x2l4:='not x2 ';

x2l1:='not x2 ';

x2l2:='x2 ';

x2l3:='x2 ';

end

else

x2l4:='x2 ';

x2l2:='not x2 ';

x2l1:='x2 ';

x2l3:='not x2 ';

end;

Begin

s2:=Cob52.Items[Cob52.ItemIndex];

if s2 = 'Конъюнкция (*)' then

y2:='and ';

if s2 = 'Дизъюнкция (+)' then

y2:='or ';

if s2 = 'Исключающее (ИЛИ)' then

y2:='xor ';

end;

begin

if Chb53.Checked = true then

begin

x3l4:='not x3 ';

x3l2:='not x3 ';

x3l1:='x3 ';

x3l3:='not x3 ';

end

else

x3l4:='x3 ';

x3l2:='x3 ';

x3l1:='not x3 ';

x3l3:='not x3 ';

end;

Begin

s3:=Cob53.Items[Cob53.ItemIndex];

if s3 = 'Конъюнкция (*)' then

y3:='and ';

if s3 = 'Дизъюнкция (+)' then

y3:='or ';

if s3 = 'Исключающее (ИЛИ)' then

y3:='xor ';

end;

begin

if Chb54.Checked = true then

begin

x4l4:='not x4 ';

x4l1:='not x4 ';

x4l2:='x4 ';

x4l3:='not x4 ';

end

else

x4l4:='x4 ';

x4l1:='x4 ';

x4l2:='not x4 ';

x4l3:='x4 ';

end;

begin

Label42.Caption:=x1l4+y1+x2l4+y2+x3l4+y3+x4l4;

Label45.Caption:=x1l1+y2+x2l1+y3+x3l1+y1+x3l1;

Label43.Caption:=x1l2+y3+x3l2+y2+x3l2;

Label44.Caption:=x1l3+y1+x2l3+y2+x3l3+y3+x4l3+y1+x1l3;

end;

end;

end;

procedure TForm2.Button6Click(Sender: TObject);

var

MSWord: Variant;

begin

if (Label23.Caption='') or (Label30.Caption='') or (Label34.Caption='') or (Label38.Caption='') or( Label42.Caption='') then

showmessage('Заполните все функции!')

else

begin

try

MSWord:=CreateOleObject('Word.Application');

MSWord.Visible:=true;

except

Exception.Create('Error');

end;

MSWord.Documents.Add;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;

MSWord.Selection.TypeText(Memo1.Text);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;

MSWord.Selection.TypeText(Memo2.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Домашнее задание');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Вариант 1');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label23.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label30.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label34.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label38.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label42.Caption);

MSWord.Selection.InsertNewPage;

//.............................

MSWord.Selection.Font.Size := 10;

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;

MSWord.Selection.TypeText(Memo1.Text);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;

MSWord.Selection.TypeText(Memo2.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Домашнее задание');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Вариант 2');

MSWord.Selection.Font.Bold := false;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(Label24.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label31.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label35.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label39.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label43.Caption);

MSWord.Selection.InsertNewPage;

//.............................

MSWord.Selection.Font.Size := 10;

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;

MSWord.Selection.TypeText(Memo1.Text);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;

MSWord.Selection.TypeText(Memo2.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Домашнее задание');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Вариант 3');

MSWord.Selection.Font.Bold := false;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(Label25.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label32.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label36.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label40.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label44.Caption);

MSWord.Selection.InsertNewPage;

//.............................

MSWord.Selection.Font.Size := 10;

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;

MSWord.Selection.TypeText(Memo1.Text);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;

MSWord.Selection.TypeText(Memo2.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Домашнее задание');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Вариант 4');

MSWord.Selection.Font.Bold := false;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(Label26.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label33.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label37.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label41.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Label45.Caption);

MSWord.ActiveDocument.SaveAs('C:\Lab_rab.doc');

end;

end;

procedure TForm2.Button7Click(Sender: TObject);

var

f1,f2,f3,f4: Textfile;

begin

if (Label23.Caption='') or (Label30.Caption='') or (Label34.Caption='') or (Label38.Caption='') or( Label42.Caption='') then

showmessage('Заполните все функции!')

else

begin

AssignFile(f1, 'lab_rab\var1.txt');

AssignFile(f2, 'lab_rab\var2.txt');

AssignFile(f3, 'lab_rab\var3.txt');

AssignFile(f4, 'lab_rab\var4.txt');

ReWrite(f1);

ReWrite(f2);

ReWrite(f3);

ReWrite(f4);

Writeln(f1,Label23.Caption);

Writeln(f1,Label30.Caption);

Writeln(f1,Label34.Caption);

Writeln(f1,Label38.Caption);

Writeln(f1,Label42.Caption);

////////////////////////////

Writeln(f2,Label24.Caption);

Writeln(f2,Label31.Caption);

Writeln(f2,Label35.Caption);

Writeln(f2,Label39.Caption);

Writeln(f2,Label43.Caption);

////////////////////////////

Writeln(f3,Label25.Caption);

Writeln(f3,Label32.Caption);

Writeln(f3,Label36.Caption);

Writeln(f3,Label30.Caption);

Writeln(f3,Label44.Caption);

///////////////////////////

Writeln(f4,Label26.Caption);

Writeln(f4,Label33.Caption);

Writeln(f4,Label37.Caption);

Writeln(f4,Label41.Caption);

Writeln(f4,Label45.Caption);

Closefile(f1);

Closefile(f2);

Closefile(f3);

Closefile(f4);

end;

end;

end.

Листинг программы (Unit3).

unit Unit3;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls, XPMan, Menus;

type

TForm3 = class(TForm)

XPManifest1: TXPManifest;

Panel1: TPanel;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Memo1: TMemo;

Memo2: TMemo;

Button2: TButton;

Label1: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

procedure FormCreate(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

implementation

uses Unit4;

{$R *.dfm}

function prov (s,s1:string):integer;

var

i:integer;

begin

result:=0;

for i:=1 to 16 do

begin

if s[i]<>s1[i] then

result:=result+1;

end;

end;

function element( var s:string):integer;

var

l,n:integer;

begin

l:=length(s);

if s[1]='x' then

begin

n:=StrToInt(s[2]);

result:=2*n-1;

s:=copy(s,4,l-3);

end

else

begin

n:=StrToInt(s[6]);

result:=2*n;

s:=copy(s,8,l-7);

end;

end;

function oper(var s:string):integer;

var

l:integer;

begin

l:=length(s);

if s[1]='a' then

begin

result:=1;

s:=copy(s,5,l-4);

end

else

if s[1]='o' then

begin

result:=2;

s:=copy(s,4,l-3);

end

else

begin

result:=3;

s:=copy(s,5,l-4);

end;

end;

function Bin(x: Integer): string;

const t:array[0..1] of char = ('0','1');

var res:string;

d:0..1;

begin

res:='';

while (x<>0) do

begin

d:=x mod 2 ;

res:=t[d]+res;

x:=x div 2 ;

end;

Bin:=res;

end;

procedure TForm3.FormCreate(Sender: TObject);

var

a,i,j:integer;

s,s1,s2,s3,s4,s5:string;

f: TextFile; // файл

fName: String[80]; // имя файла

buf: string[80]; // буфер для чтения из файла

x1,x2,x3,x4:byte;

begin

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

Edit4.Clear;

Edit5.Clear;

for i:= 0 to 15 do

begin

Memo1.Lines.Add(Bin(i));

end;

for i:= 0 to 15 do

for j:= 0 to 15 do

begin

if length(Memo1.Lines[i])<4 then

Memo1.Lines[i]:='0'+Memo1.Lines[i];

end;

s:=Memo1.Lines[13] ;

//ShowMessage(s[3]);

begin

AssignFile(f, 'lab_rab\var1.txt');

Reset(f); // открыть для чтения

// чтение из файла

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo2.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

end;

procedure TForm3.Button2Click(Sender: TObject);

var

sl: TStringList;

s,s1,s2:string;

x1,x2,x3,x4,i,res,j,k,o:integer;

a:array [1..5] of integer;

begin

if (length(Edit1.text)<>16)or (length(Edit2.text)<>16)or(length(Edit3.text)<>16)or(length(Edit4.text)<>16)or(length(Edit5.text)<>16)then

begin

Showmessage('длина ответа должна рaвняться 16 символам!');

exit;

end;

for i:=1 to 16 do

if not(Edit1.Text[i] in ['0','1']) or not(Edit2.Text[i] in ['0','1']) or not(Edit3.Text[i] in ['0','1']) or not(Edit4.Text[i] in ['0','1']) or not(Edit5.Text[i] in ['0','1']) then

begin

ShowMessage('Вводятся только "0" и "1"!');

Exit;

end;

s1:=Memo2.Lines[0] ;

Label2.Caption:='';

for i:= 0 to 15 do

begin

s2:=s1;

s:=Memo1.Lines[i] ;

x1:=StrToInt(s[1]);

x2:=StrToInt(s[2]);

x3:=StrToInt(s[3]);

x4:=StrToInt(s[4]);

case element(s2) of

1: res:=x1;

2: res:=1-x1;

3: res:=x2;

4: res:=1-x2;

5: res:=x3;

6: res:=1-x3;

7: res:=x4;

8: res:=1-x4;

end;

while length(s2)>0 do

begin

case oper(s2) of

1:

case element(s2) of

1: res:=res and x1;

2: res:=res and (1-x1);

3: res:=res and x2;

4: res:=res and (1-x2);

5: res:=res and x3;

6: res:=res and (1-x3);

7: res:=res and x4;

8: res:=res and (1-x4);

end;

2:

case element(s2) of

1: res:=res or x1;

2: res:=res or (1-x1);

3: res:=res or x2;

4: res:=res or (1-x2);

5: res:=res or x3;

6: res:=res or (1-x3);

7: res:=res or x4;

8: res:=res or (1-x4);

end;

3:

case element(s2) of

1: res:=res xor x1;

2: res:=res xor (1-x1);

3: res:=res xor x2;

4: res:=res xor (1-x2);

5: res:=res xor x3;

6: res:=res xor (1-x3);

7: res:=res xor x4;

8: res:=res xor (1-x4);

end;

end;

end;

label2.Caption:=Label2.Caption+IntToStr(res);

end;

// вторая функция

s1:=Memo2.Lines[1] ;

Label3.Caption:='';

for i:= 0 to 15 do

begin

s2:=s1;

s:=Memo1.Lines[i] ;

x1:=StrToInt(s[1]);

x2:=StrToInt(s[2]);

x3:=StrToInt(s[3]);

x4:=StrToInt(s[4]);

case element(s2) of

1: res:=x1;

2: res:=1-x1;

3: res:=x2;

4: res:=1-x2;

5: res:=x3;

6: res:=1-x3;

7: res:=x4;

8: res:=1-x4;

end;

while length(s2)>0 do

begin

case oper(s2) of

1:

case element(s2) of

1: res:=res and x1;

2: res:=res and (1-x1);

3: res:=res and x2;

4: res:=res and (1-x2);

5: res:=res and x3;

6: res:=res and (1-x3);

7: res:=res and x4;

8: res:=res and (1-x4);

end;

2:

case element(s2) of

1: res:=res or x1;

2: res:=res or (1-x1);

3: res:=res or x2;

4: res:=res or (1-x2);

5: res:=res or x3;

6: res:=res or (1-x3);

7: res:=res or x4;

8: res:=res or (1-x4);

end;

3:

case element(s2) of

1: res:=res xor x1;

2: res:=res xor (1-x1);

3: res:=res xor x2;

4: res:=res xor (1-x2);

5: res:=res xor x3;

6: res:=res xor (1-x3);

7: res:=res xor x4;

8: res:=res xor (1-x4);

end;

end;

end;

label3.Caption:=Label3.Caption+IntToStr(res);

end;

// третья функция

s1:=Memo2.Lines[2] ;

Label4.Caption:='';

for i:= 0 to 15 do

begin

s2:=s1;

s:=Memo1.Lines[i] ;

x1:=StrToInt(s[1]);

x2:=StrToInt(s[2]);

x3:=StrToInt(s[3]);

x4:=StrToInt(s[4]);

case element(s2) of

1: res:=x1;

2: res:=1-x1;

3: res:=x2;

4: res:=1-x2;

5: res:=x3;

6: res:=1-x3;

7: res:=x4;

8: res:=1-x4;

end;

while length(s2)>0 do

begin

case oper(s2) of

1:

case element(s2) of

1: res:=res and x1;

2: res:=res and (1-x1);

3: res:=res and x2;

4: res:=res and (1-x2);

5: res:=res and x3;

6: res:=res and (1-x3);

7: res:=res and x4;

8: res:=res and (1-x4);

end;

2:

case element(s2) of

1: res:=res or x1;

2: res:=res or (1-x1);

3: res:=res or x2;

4: res:=res or (1-x2);

5: res:=res or x3;

6: res:=res or (1-x3);

7: res:=res or x4;

8: res:=res or (1-x4);

end;

3:

case element(s2) of

1: res:=res xor x1;

2: res:=res xor (1-x1);

3: res:=res xor x2;

4: res:=res xor (1-x2);

5: res:=res xor x3;

6: res:=res xor (1-x3);

7: res:=res xor x4;

8: res:=res xor (1-x4);

end;

end;

end;

label4.Caption:=Label4.Caption+IntToStr(res);

end;

// четвертая функция

s1:=Memo2.Lines[3] ;

Label5.Caption:='';

for i:= 0 to 15 do

begin

s2:=s1;

s:=Memo1.Lines[i] ;

x1:=StrToInt(s[1]);

x2:=StrToInt(s[2]);

x3:=StrToInt(s[3]);

x4:=StrToInt(s[4]);

case element(s2) of

1: res:=x1;

2: res:=1-x1;

3: res:=x2;

4: res:=1-x2;

5: res:=x3;

6: res:=1-x3;

7: res:=x4;

8: res:=1-x4;

end;

while length(s2)>0 do

begin

case oper(s2) of

1:

case element(s2) of

1: res:=res and x1;

2: res:=res and (1-x1);

3: res:=res and x2;

4: res:=res and (1-x2);

5: res:=res and x3;

6: res:=res and (1-x3);

7: res:=res and x4;

8: res:=res and (1-x4);

end;

2:

case element(s2) of

1: res:=res or x1;

2: res:=res or (1-x1);

3: res:=res or x2;

4: res:=res or (1-x2);

5: res:=res or x3;

6: res:=res or (1-x3);

7: res:=res or x4;

8: res:=res or (1-x4);

end;

3:

case element(s2) of

1: res:=res xor x1;

2: res:=res xor (1-x1);

3: res:=res xor x2;

4: res:=res xor (1-x2);

5: res:=res xor x3;

6: res:=res xor (1-x3);

7: res:=res xor x4;

8: res:=res xor (1-x4);

end;

end;

end;

label5.Caption:=Label5.Caption+IntToStr(res);

end;

// пятая функция

s1:=Memo2.Lines[4] ;

Label6.Caption:='';

for i:= 0 to 15 do

begin

s2:=s1;

s:=Memo1.Lines[i] ;

x1:=StrToInt(s[1]);

x2:=StrToInt(s[2]);

x3:=StrToInt(s[3]);

x4:=StrToInt(s[4]);

case element(s2) of

1: res:=x1;

2: res:=1-x1;

3: res:=x2;

4: res:=1-x2;

5: res:=x3;

6: res:=1-x3;

7: res:=x4;

8: res:=1-x4;

end;

while length(s2)>0 do

begin

case oper(s2) of

1:

case element(s2) of

1: res:=res and x1;

2: res:=res and (1-x1);

3: res:=res and x2;

4: res:=res and (1-x2);

5: res:=res and x3;

6: res:=res and (1-x3);

7: res:=res and x4;

8: res:=res and (1-x4);

end;

2:

case element(s2) of

1: res:=res or x1;

2: res:=res or (1-x1);

3: res:=res or x2;

4: res:=res or (1-x2);

5: res:=res or x3;

6: res:=res or (1-x3);

7: res:=res or x4;

8: res:=res or (1-x4);

end;

3:

case element(s2) of

1: res:=res xor x1;

2: res:=res xor (1-x1);

3: res:=res xor x2;

4: res:=res xor (1-x2);

5: res:=res xor x3;

6: res:=res xor (1-x3);

7: res:=res xor x4;

8: res:=res xor (1-x4);

end;

end;

end;

label6.Caption:=Label6.Caption+IntToStr(res);

end;

k:=prov(Edit1.Text,Label2.Caption);

if k=0 then

a[1]:=5

else

if k<=2 then

a[1]:=4

else

if k<=7 then

a[1]:=3

else

a[1]:=2;

k:=prov(Edit2.Text,Label3.Caption);

if k=0 then

a[2]:=5

else

if k<=2 then

a[2]:=4

else

if k<=7 then

a[2]:=3

else

a[2]:=2;

k:=prov(Edit3.Text,Label4.Caption);

if k=0 then

a[3]:=5

else

if k<=2 then

a[3]:=4

else

if k<=7 then

a[3]:=3

else

a[3]:=2;

k:=prov(Edit4.Text,Label5.Caption);

if k=0 then

a[4]:=5

else

if k<=2 then

a[4]:=4

else

if k<=7 then

a[4]:=3

else

a[4]:=2;

k:=prov(Edit5.Text,Label6.Caption);

if k=0 then

a[5]:=5

else

if k<=2 then

a[5]:=4

else

if k<=7 then

a[5]:=3

else

a[5]:=2;

o:=(a[1]+a[2]+a[3]+a[4]+a[5])div 5;

Showmessage('Оценка '+IntToStr(o));

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\'+form4.label2.caption+'.txt' );

for i := 0 to sl.Count-1 do

if Pos( form4.label1.Caption, sl[i] ) > 0 then

begin

sl[i+1]:=sl[i+1]+' Оценка '+IntToStr(o);

sl.SaveToFile('spiski\'+form4.label2.Caption+'.txt');

sl.Free;

Form3.Close;

break;

end;

end;

end.

Листинг программы (Unit4).

unit Unit4;

interface

uses

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

Dialogs, StdCtrls, OleServer, WordXP;

type

TForm4 = class(TForm)

Label1: TLabel;

Label2: TLabel;

ComboBox1: TComboBox;

Memo1: TMemo;

Button1: TButton;

WordApplication1: TWordApplication;

Memo2: TMemo;

Memo3: TMemo;

procedure ComboBox1Change(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form4: TForm4;

implementation

uses ComObj;

{$R *.dfm}

procedure TForm4.ComboBox1Change(Sender: TObject);

var

s:string;

f: TextFile; // файл

buf: string[80]; // буфер для чтения из файла

begin

s:=ComboBox1.Items[ComboBox1.ItemIndex];

if s = 'Вариант 1' then

begin

Memo1.Clear;

AssignFile(f, 'lab_rab\var1.txt');

Reset(f); // открыть для чтения

// чтение из файла

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo1.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

if s = 'Вариант 2' then

begin

Memo1.Clear;

AssignFile(f, 'lab_rab\var2.txt');

Reset(f); // открыть для чтения

while not EOF(f) do// чтение из файла

begin

readln(f, buf); // прочитать строку из файла

Memo1.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

if s = 'Вариант 3' then

begin

Memo1.Clear;

AssignFile(f, 'lab_rab\var3.txt');

Reset(f); // открыть для чтения

// чтение из файла

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo1.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

if s = 'Вариант 4' then

begin

Memo1.Clear;

AssignFile(f, 'lab_rab\var4.txt');

Reset(f); // открыть для чтения

// чтение из файла

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo1.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

end;

procedure TForm4.Button1Click(Sender: TObject);

var

sl: TStringList;

i: integer;

MSWord: Variant;

begin

begin

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\'+label2.Caption+'.txt' );

for i := 0 to sl.Count-1 do

if Pos( label1.Caption, sl[i] ) > 0 then

if sl.Count>=(i+2) then

begin

if pos ('Вариант',sl[i+1])>0 then

begin

showmessage('задание уже получено!');

sl.Free;

form4.Close;

exit;

end

else

begin

sl.Insert((i+1),ComboBox1.Text );

sl.SaveToFile('spiski\'+label2.Caption+'.txt');

sl.Free;

break;

end;

end

else

begin

sl.Insert((i+1),ComboBox1.Text );

sl.SaveToFile('spiski\'+label2.Caption+'.txt');

sl.Free;

break;

end;

end;

begin

try

MSWord:=CreateOleObject('Word.Application');

MSWord.Visible:=true;

except

Exception.Create('Error');

end;

MSWord.Documents.Add;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;

MSWord.Selection.TypeText(Memo3.Text);

MSWord.Selection.Font.Size := 12;

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Домашнее задание');

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;

MSWord.Selection.TypeText('Группа : ');

MSWord.Selection.TypeText(Label2.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText('Студент : ');

MSWord.Selection.TypeText(Label1.Caption);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Memo2.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(ComboBox1.Text);

MSWord.Selection.TypeText(#13#10);

MSWord.Selection.TypeText(Memo1.Text);

end;

Application.Terminate;

end;

end.

Листинг программы (Unit5).

unit Unit5;

interface

uses

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

Dialogs, StdCtrls, XPMan;

type

TForm5 = class(TForm)

Button1: TButton;

Button2: TButton;

XPManifest1: TXPManifest;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form5: TForm5;

implementation

uses Unit4, Unit3;

{$R *.dfm}

procedure TForm5.Button1Click(Sender: TObject);

var

i:integer;

sl: TStringList;

begin

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\'+form4.label2.caption+'.txt' );

for i := 0 to sl.Count-1 do

if Pos( form4.label1.Caption, sl[i] ) > 0 then

if sl.Count=i+1 then

begin

Form4.Show;

break;

end

else

if pos ('Вариант',sl[i+1])>0 then

showmessage('Вариант уже выбран!')

else

begin

Form4.Show;

break;

end;

end;

procedure TForm5.Button2Click(Sender: TObject);

var

i:integer;

sl: TStringList;

begin

sl := TStringList.Create;

sl.LoadFromFile( 'spiski\'+form4.label2.caption+'.txt' );

for i := 0 to sl.Count-1 do

if Pos( form4.label1.Caption, sl[i] ) > 0 then

if sl.Count=i+1 then

begin

Form4.Show;

break;

end

else

if pos ('Оценка',sl[i+1])>0 then

showmessage('Оценка уже получена')

else

begin

Form3.Show;

break;

end;

end;

end.

Листинг программы (Unit6).

unit Unit6;

interface

uses

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

Dialogs, XPMan, StdCtrls;

type

TForm6 = class(TForm)

Button1: TButton;

Button2: TButton;

Button3: TButton;

Button4: TButton;

XPManifest1: TXPManifest;

Label1: TLabel;

Label2: TLabel;

procedure Button4Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form6: TForm6;

implementation

uses Unit2, Unit7;

{$R *.dfm}

procedure TForm6.Button4Click(Sender: TObject);

begin

form2.show;

end;

procedure TForm6.Button1Click(Sender: TObject);

begin

Form7.show;

Form7.Panel1.Show;

Form7.Caption:='Создание';

Form7.Panel2.Hide;

Form7.Panel3.Hide;

end;

procedure TForm6.Button2Click(Sender: TObject);

begin

Form7.show;

Form7.Caption:='Редактирование';

Form7.Panel2.Show;

Form7.Panel1.Hide;

Form7.Panel3.Hide;

end;

procedure TForm6.Button3Click(Sender: TObject);

begin

Form7.Show;

Form7.Panel3.Show;

Form7.Caption:='Просмотр';

Form7.Panel1.Hide;

Form7.Panel2.Hide;

end;

end.

Листинг программы (Unit7).

unit Unit7;

interface

uses

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

Dialogs, ExtCtrls, StdCtrls, XPMan;

type

TForm7 = class(TForm)

Memo1: TMemo;

Edit1: TEdit;

Button1: TButton;

Label1: TLabel;

Panel1: TPanel;

Label2: TLabel;

Panel2: TPanel;

Edit2: TEdit;

Memo2: TMemo;

Button2: TButton;

Label3: TLabel;

Label4: TLabel;

Button3: TButton;

XPManifest1: TXPManifest;

Panel3: TPanel;

Edit3: TEdit;

Label5: TLabel;

Label6: TLabel;

Memo3: TMemo;

Button4: TButton;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure FormShow(Sender: TObject);

private

{ Private declarations }

public

f1:string;

{ Public declarations }

end;

var

Form7: TForm7;

implementation

uses Unit6;

{$R *.dfm}

procedure TForm7.Button1Click(Sender: TObject);

var

f:Textfile;

begin

if Edit1.Text='' then

showmessage('Введите номер группы!')

else

begin

AssignFile(f,'spiski\'+Edit1.Text+'.txt');

ReWrite(f);

Writeln(f,Memo1.Text);

Closefile(f);

Showmessage('Группа успешно создана');

Edit1.Clear;

form6.show;

form7.Close;

end;

end;

procedure TForm7.Button2Click(Sender: TObject);

var

f:Textfile;

begin

if Edit2.Text='' then

showmessage('Введите номер группы!')

else

begin

DeleteFile('spiski\'+f1+'.txt');

AssignFile(f,'spiski\'+Edit2.Text+'.txt');

ReWrite(f);

Writeln(f,Memo2.Text);

Closefile(f);

Showmessage('Группа успешно редактирована');

Edit1.Clear;

form6.show;

form7.Close;

end;

end;

procedure TForm7.Button3Click(Sender: TObject);

var

f:Textfile;

buf: string[80];

begin

if Edit2.Text='' then

showmessage('Введите номер группы!')

else

begin

Memo2.Clear;

Memo2.Show;

Label4.Show;

f1:=Edit2.Text;

Button2.Show;

AssignFile(f,'spiski\'+Edit2.Text+'.txt');

Reset(f);

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo2.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end;

end;

procedure TForm7.Button4Click(Sender: TObject);

var

f:Textfile;

buf: string[80];

begin

Memo3.Clear;

Memo3.Show;

Label6.Show;

if Edit3.Text='' then

ShowMessage('Введите название группы!')

else

begin

AssignFile(f,'spiski\'+Edit3.Text+'.txt');

Reset(f);

while not EOF(f) do

begin

readln(f, buf); // прочитать строку из файла

Memo3.Lines.Add(buf); // добавить строку в поле Memo1

end; // закрыть файл

CloseFile(f);

end; end;

procedure TForm7.FormShow(Sender: TObject);

begin

Form7.Memo1.Clear;

Form7.Edit1.Clear;

Form7.Edit2.Clear;

Form7.Memo2.Clear;

Form7.Memo3.Clear;

Form7.Edit3.Clear;

end;

end.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]