Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Курсовик по ТРПО / Приложение 7 (Текст программы горизонтального прототипа)

.doc
Скачиваний:
38
Добавлен:
01.05.2014
Размер:
53.25 Кб
Скачать

unit UnitMain;//модуль главной формы

interface

uses

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

Dialogs, Menus, Grids, ComCtrls, StdCtrls;

type

TFormMain = class(TForm)

MainMenu1: TMainMenu;

File1: TMenuItem;

NewPro1: TMenuItem;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

PageControl1: TPageControl;

TabSheet1: TTabSheet;

TabSheet2: TTabSheet;

StringGrid1: TStringGrid;

Button1: TButton;

Button2: TButton;

CheckBox1: TCheckBox;

TabSheet3: TTabSheet;

MonthCalendar1: TMonthCalendar;

Label1: TLabel;

ComboBox1: TComboBox;

Label2: TLabel;

ComboBox2: TComboBox;

Label3: TLabel;

ComboBox3: TComboBox;

Label4: TLabel;

ComboBox4: TComboBox;

Label5: TLabel;

ComboBox5: TComboBox;

Label6: TLabel;

ComboBox6: TComboBox;

procedure N3Click(Sender: TObject);

procedure Init();

procedure N6Click(Sender: TObject);

procedure N1Click(Sender: TObject);

procedure StringGrid1DblClick(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure loadFromFile();

private

{ Private declarations }

public

{ Public declarations }

end;

var

FormMain: TFormMain;

vuz:array of string;//массив ВУЗов

adress:array of string;//массив адресов

site:array of string;//массив сайтов

events:array of string;//массив событий

fileName:string;//имя файла проекта

implementation

uses UnitInformation;

{$R *.dfm}

procedure TFormMain.N3Click(Sender: TObject);

begin

Close;

end;

procedure TFormMain.Init();//Инициализация формы

var i,j:integer;

begin

StringGrid1.ColCount:=2;

StringGrid1.Cells[1,0]:='Название';

loadFromFile();//Загрузка данных из файла

PageControl1.Visible:=true;

StringGrid1.RowCount:=length(vuz)+1;

for j:=0 to length(vuz)-1 do//Заполнение таблицы

begin

StringGrid1.Cells[0,j+1]:=IntToStr(j+1);

StringGrid1.Cells[1,j+1]:=vuz[j];

end;

end;

procedure TFormMain.loadFromFile();//Загрузка данных из файла

var f:textfile;code,i:integer;c:char;

begin

//Загрузка данных из файла

assignfile(f,fileName);

{$I-}

reset(f);

{$I+}

if IOResult<>0 then begin

MessageDlg('Файл с именем '+fileName+' не найден!',mtError,[mbOk],0);

exit;

end;

code:=0;

if not eof(f) then read(f,c);//Считывание 'типа' данных

while not Eof(f) do

begin

if c='V' then code:=1//ÂÓÇû

else

if c='A' then code:=2//Адреса

else

if c='S' then code:=3//Сайты

else

if c='E' then code:=4;//События

if code=0 then

begin

ShowMessage('Некорректное содержание файла!');

exit;

end

else

begin

read(f,c);//считываем пробел

case code of

1:

begin

i:=0;

SetLength(vuz, 1);

read(f,c);

while c<>'A' do

begin

if c<>'.' then

begin

if c=';' then

begin

SetLength(vuz, length(vuz)+1);

i:=i+1;

end

else

vuz[i]:=vuz[i]+c;

end

else begin read(f,c);read(f,c);end;

read(f,c);

end;

end;

2:

begin

i:=0;

SetLength(adress, 1);

read(f,c);

while c<>'S' do

begin

if c<>'.' then

begin

if c=';' then

begin

SetLength(adress, length(adress)+1);

i:=i+1;

end

else

adress[i]:=adress[i]+c;

end

else begin read(f,c);read(f,c);end;

read(f,c);

end;

end;

3:

begin

i:=0;

SetLength(site, 1);

read(f,c);

while c<>'E' do

begin

if c<>'.' then

begin

if c=';' then

begin

SetLength(site, length(site)+1);

i:=i+1;

end

else

site[i]:=site[i]+c;

end

else begin read(f,c);read(f,c);end;

read(f,c);

end;

end;

4:

begin

i:=0;

SetLength(events, 1);

read(f,c);

while (c<>'.') and (not Eof(f)) do

begin

if c<>'.' then

begin

if c=';' then

begin

SetLength(events, length(events)+1);

i:=i+1;

end

else

events[i]:=events[i]+c;

end

else begin read(f,c);read(f,c);end;

read(f,c);

end;

end;

end;

end;

end;

CloseFile(f);

end;

procedure TFormMain.N6Click(Sender: TObject);//Авторы

begin

ShowMessage('Программу разработали студенты группы 3305: Крупицкий Михаил, Мещеряков Анатолий');

end;

procedure TFormMain.N1Click(Sender: TObject);//Открытие

begin

fileName:= InputBox('Открыть', 'Введите имя файла проекта:','data.txt');

init();

end;

procedure TFormMain.StringGrid1DblClick(Sender: TObject);//Переход к форме с подробной информацией(событие по двойному клику)

var sel:integer;

begin

sel:=StringGrid1.row-1;

FormInformation.init(vuz[sel],adress[sel],site[sel],events[sel]);

FormInformation.Show;

end;

procedure TFormMain.Button1Click(Sender: TObject);//Применнение фильтра

begin

PageControl1.ActivePageIndex:=0;

end;

end.

/***********************************************************************************/

unit UnitInformation;//модуль формы с информацией о ВУЗах

interface

uses

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

Dialogs, StdCtrls, Grids, ComCtrls;

type

TFormInformation = class(TForm)

PageControl1: TPageControl;

TabSheet1: TTabSheet;

TabSheet2: TTabSheet;

StringGrid1: TStringGrid;

Button1: TButton;

GroupBox1: TGroupBox;

Memo1: TMemo;

GroupBox2: TGroupBox;

Memo2: TMemo;

procedure init(vuz,adress,site,event:string);

private

{ Private declarations }

public

{ Public declarations }

end;

var

FormInformation: TFormInformation;

events:array of string;//массив событий

implementation

uses UnitMain;

procedure TFormInformation.init(vuz,adress,site,event:string);//Инициализация формы

var j:integer;

begin

Memo1.Clear;

Memo2.Clear;

Memo1.Lines.Append('Âóç: '+ vuz);

Memo1.Lines.Append('Адрес: '+ adress);

Memo2.Lines.Append('Сайты: '+ site);

StringGrid1.RowCount:=3;

StringGrid1.ColCount:=3;

StringGrid1.Cells[1,0]:='Событие';

StringGrid1.Cells[2,0]:='Äàòà';

StringGrid1.Cells[1,1]:='День открытых дверей';

StringGrid1.Cells[1,2]:='Экзамен по математике';

StringGrid1.Cells[2,1]:='11.04.2007';

StringGrid1.Cells[2,2]:='15.06.2007';

{ StringGrid1.RowCount:=length(vuz)+1;

for j:=0 to length(event) do

begin

if event[j]

end;

for j:=0 to length(vuz)-1 do

begin

StringGrid1.Cells[0,j+1]:=IntToStr(j+1);

StringGrid1.Cells[1,j+1]:=vuz[j];

end;}

end;

{$R *.dfm}

end.

30