- •Содержание
- •Постановка задачи
- •Инструкции пользователю
- •2.1 Программа «Работа интернет клуба» в Microsoft Excel на языке Visual Basic For Application
- •2.2 Программа «Работа интернет клуба» на Delphi 7
- •Описание процесса разработки программы
- •3.1 Процесс разработки приложения в рабочей книге Microsoft Excel на языке Visual Basic for Application
- •3.2. Процесс разработки приложения для работы с файлом Microsoft Excel на языке Delphi 7
- •Библиографический список
- •Приложение приложение а Листинг программы «Работа интернет клуба» в Microsoft Excel на языке Visual Basic For Application
- •Приложение б Листинг программы «Работа интернет клуба» на языке Delphi 7
Приложение б Листинг программы «Работа интернет клуба» на языке Delphi 7
Unit1(Главное меню программы)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, OleServer, ExcelXP, ComCtrls, ImgList, Menus, ToolWin,
StdCtrls;
XLApp: TExcelApplication;
procedure FormCreate(Sender: TObject);
procedure btn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure tlb1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn9MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn3MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn4MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn6MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn7MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn8MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mas:array of zap;
t:zap;
x,y,n,j,i:integer;
WorkBk:_Workbook;
WorkSheet:_WorkSheet;
Mx:variant;
Path:widestring;
implementation
uses Unit2, Unit3, Unit4;
{$R *.dfm} //процедура открытия файла экселя
procedure Load(var WorkBk:_Workbook; var WorkSheet:_WorkSheet;Mx:variant;path:widestring);
var k,r:integer;
begin
form1.XLApp.Connect; //Подключение к серверу
form1.XLApp.Workbooks.Open(path,EmptyParam,EmptyParam,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,0); //Загрузка файла
WorkBk := form1.XLApp.WorkBooks.Item[1]; //Определяем первую книгу
WorkSheet := WorkBk.WorkSheets.Get_Item(1) as _WorkSheet; //Определяем первый лист
WorkSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate; //Активируем последнюю ячейку
X := form1.XLApp.ActiveCell.Row; //Узнаем адрес последней ячейки
Y := form1.XLApp.ActiveCell.Column;
form1.StringGrid1.ColCount:=y; //Определяем размер SG
form1.Stringgrid1.RowCount:=x;
Mx := form1.XLApp.Range['A1',form1.XLApp.Cells.Item[X,Y]].Formula; //Заполняем матрицу значениями из файла
for k:=1 to x do begin //Заполняем SG
for r:=1 to y do begin
form1.stringgrid1.Cells[r-1,k-1]:=Mx[k,r];
end;
end;
form1.XLApp.Disconnect;
Mx := Unassigned; //Очистка матрицы
end;
procedure Save(WorkBk:_Workbook;WorkSheet:_WorkSheet;Mx:variant); //процедура сохранения файла в страницу экселя
var r,c,i,j,lx,ly:integer;
begin
r:=form1.StringGrid1.RowCount; //Записываем размерность SG в переменные
c:=form1.StringGrid1.ColCount;
Mx:=VarArrayCreate([0,r,0,c],VarOleStr); //Определяем матрицу
WorkSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
lx := form1.XLApp.ActiveCell.Row; //Определяем адрес последней ячейки
ly := form1.XLApp.ActiveCell.Column;
if r=1 then //Если записей нет очищаем файл
Worksheet.Range['A1',Worksheet.Cells.Item[lx,ly]].Clear
else begin
for i:=0 to r do
begin
for j:=0 to c do
Mx[i,j]:=form1.StringGrid1.Cells[j,i]; //Заполняем матрицу
end; //Формирование заголовка файла
Worksheet.Range['A1',Worksheet.Cells.Item[lx,ly]].Clear; //Очищаем файл
Worksheet.Range['A1',Worksheet.Cells.Item[r,c]].Formula := Mx; //Заполняем файл значениями из матрицы
form1.XLApp.Visible[0] := false;
Mx := Unassigned; //Очищаем матрицу
for i:=1 to r do begin
for j:=1 to c do //Прорисовка рамок
worksheet.Cells.Item[i,j].BorderAround(xlContinuous,1,1,EmptyParam);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var path:WideString;
begin
path:=GetCurrentDir+'\data.xlsx'; //Загрузка файла по умолчанию
Load(WorkBk,WorkSheet,Mx,path);
stat1.Panels[1].Text:=path;
stat1.Panels[2].Text:='записей: '+IntToStr(StringGrid1.rowcount-1);
end;
procedure TForm1.btn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='открыть';
end;
procedure TForm1.tlb1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='';
end;
procedure TForm1.btn2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='сохранить';
end;
procedure TForm1.btn9MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='сохранить как';
end;
procedure TForm1.btn3MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='выход';
end;
procedure TForm1.btn4MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='добавить запись';
end;
procedure TForm1.btn6MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='удалить запись';
end;
procedure TForm1.btn7MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='сортировка';
end;
procedure TForm1.btn8MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='поиск';
end;
procedure TForm1.N1Click(Sender: TObject);
begin
Dialog1.Options:=[ofFileMustExist];
Dialog1.Filter:='.xls|*.xls|.xlsx|*.xlsx|.xlsm|*.xlsm|';
if Dialog1.Execute then
begin
path:= Dialog1.FileName;
Load(WorkBk,WorkSheet,Mx,path);
stat1.Panels[1].Text:=path;
end;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
Save(WorkBk,WorkSheet,Mx); //Сохраняем копию файла
WorkBk.Save(0);
end;
procedure TForm1.N3Click(Sender: TObject);
begin
dlgSave1.Options:=[ofFileMustExist];
dlgSave1.Filter:='.xls|*.xls|.xlsx|*.xlsx|.xlsm|*.xlsm|';
dlgSave1.DefaultExt:='.xlsx';
if dlgSave1.Execute then
begin
Save(WorkBk,WorkSheet,Mx); //Сохраняем копию файла
WorkBk.SaveCopyAs(dlgSave1.FileName,0);
end;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.N8Click(Sender: TObject);
begin
form2.showmodal;
form2.edt1.text:='';
form2.edt2.text:='';
form2.edt3.text:='';
form2.edt4.text:='';
form2.edt5.text:='';
form2.edt6.text:='';
form2.edt7.text:='';
form2.edt8.text:='';
end;
procedure TForm1.N10Click(Sender: TObject);
begin
if messagedlg('Вы точно хотите удалить строку?', mtconfirmation,[mbOK,mbCancel],0)=mrOK then
n:=StringGrid1.Row;
if n>=1 then
begin
for j:=1 to 7 do
begin
for i:=n to StringGrid1.RowCount-1 do
begin
StringGrid1.Cells[j,i]:=StringGrid1.Cells[j,i+1];
end;
end;
StringGrid1.RowCount:=StringGrid1.RowCount-1;
end;
stat1.Panels[2].Text:='записей: '+inttostr(StringGrid1.RowCount-1);
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
i:=arow;
end;
procedure TForm1.btn10MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
stat1.Panels[0].Text:='редактировать';
end;
procedure TForm1.N9Click(Sender: TObject);
begin
form3.edt1.text:=StringGrid1.Cells[1,i];
form3.edt2.text:=StringGrid1.Cells[2,i];
form3.edt3.text:=StringGrid1.Cells[3,i];
form3.edt4.text:=StringGrid1.Cells[4,i];
form3.edt5.text:=StringGrid1.Cells[5,i];
form3.edt6.text:=StringGrid1.Cells[6,i];
form3.edt7.text:=StringGrid1.Cells[7,i];
form3.edt8.text:=StringGrid1.Cells[8,i];
form3.showmodal;
end;
procedure TForm1.N6Click(Sender: TObject);
begin
form4.edt1.text:='';
form4.StringGrid1.Cells[0,0]:='№';
form4.StringGrid1.Cells[1,0]:='№ компьютера.';
form4.StringGrid1.Cells[2,0]:='Пользователь';
form4.StringGrid1.Cells[3,0]:='Начало сеанса';
form4.StringGrid1.Cells[4,0]:='Время пользования';
form4.StringGrid1.Cells[5,0]:='Тариф';
form4.StringGrid1.Cells[6,0]:='Скидка за ночное пользование';
form4.StringGrid1.Cells[7,0]:='Стоимость услуг консультанта';
form4.StringGrid1.Cells[8,0]:='Стоимость';
form4.showmodal;
end;
procedure TForm1.N12Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].num>mas[j+1].num then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.N13Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].polz>mas[j+1].polz then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.N14Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].tar>mas[j+1].tar then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.N15Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].sk>mas[j+1].sk then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.N16Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].usl>mas[j+1].usl then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.N17Click(Sender: TObject);
begin
j:=stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
for i:=1 to High(mas)-1 do
begin
for j:=1 to High(mas)-i do
if mas[j].pr>mas[j+1].pr then
begin
t:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=t;
end;
end;
for i:=1 to high(mas) do
begin
StringGrid1.Cells[0,i]:=mas[i].n;
StringGrid1.Cells[1,i]:=mas[i].num;
StringGrid1.Cells[2,i]:=mas[i].polz;
StringGrid1.Cells[3,i]:=mas[i].nach;
StringGrid1.Cells[4,i]:=mas[i].timer;
StringGrid1.Cells[5,i]:=mas[i].tar;
StringGrid1.Cells[6,i]:=mas[i].sk;
StringGrid1.Cells[7,i]:=mas[i].usl;
StringGrid1.Cells[8,i]:=mas[i].pr;
end;
Finalize(mas);
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if XLApp.Workbooks.Count<>0 then
begin //Проверка на открытые файлы
//Диалог с пользователем при закрытии программы
if(MessageBox(Handle,'Вы хотите сохранить данные в Excel?','Закрытие программы', MB_ICONQUESTION OR MB_YESNO)<>IDNO)then
begin
button2.Click; //Если "Да", то сохраняем и закрываем
XLApp.Workbooks.Close(0);
XLApp.Disconnect;
XLApp.Quit;
CanClose:=true;
end
else
begin
XLApp.Workbooks.Close(0); //Если "Нет", то просто закрываем
XLApp.Disconnect;
XLApp.Quit;
CanClose:=true;
end;
end;
end;
end.
Unit2 (Добавление записи)
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.btn2Click(Sender: TObject);
begin
Form2.Close;
end;
procedure TForm2.btn1Click(Sender: TObject);
begin
if (edt1.text='')or (edt2.text='')or(edt3.text='')or(edt4.text='')or(edt5.text='')or(edt6.text='') or(edt7.text='') or(edt8.text='')
then
ShowMessage('заполните все поля')
else
begin
i:=form1.stringgrid1.rowcount+1;
form1.stringgrid1.rowcount:=i;
form1.stringgrid1.cells[0,i-1]:=inttostr(i-1);
form1.stringgrid1.cells[1,i-1]:=edt1.text;
form1.stringgrid1.cells[2,i-1]:=edt2.text;
form1.stringgrid1.cells[3,i-1]:=edt3.text;
form1.stringgrid1.cells[4,i-1]:=edt4.text;
form1.stringgrid1.cells[5,i-1]:=edt5.text;
form1.stringgrid1.cells[6,i-1]:=edt6.text;
form1.stringgrid1.cells[7,i-1]:=edt7.text;
form1.stringgrid1.cells[8,i-1]:=edt8.text;
form1.stat1.Panels[2].Text:='записей: '+IntToStr(form1.stringgrid1.rowcount-1);
Form2.Close;
end;
end;
end.
Unit3 (Редактирование записи)
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
{ procedure lbl6Click(Sender: TObject);)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm3.btn1Click(Sender: TObject);
begin
With form1.StringGrid1 do
begin
Cells[1,i]:=Edt1.Text;
Cells[2,i]:=Edt2.Text;
Cells[3,i]:=Edt3.Text;
Cells[4,i]:=Edt4.Text;
Cells[5,i]:=Edt5.Text;
Cells[6,i]:=Edt6.Text;
Cells[7,i]:=Edt7.Text;
Cells[8,i]:=Edt8.Text;
end;
form3.Close;
end;
procedure TForm3.btn2Click(Sender: TObject);
begin
form3.Close;
end;
end.
Unit4 (Поиск данных)
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
a,c,j,i:integer;
b:string;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm4.btn2Click(Sender: TObject);
begin
Form4.Close;
end;
procedure TForm4.btn1Click(Sender: TObject);
begin
j:=form1.stringgrid1.RowCount;
setlength(mas,j);
for i:=1 to form1.stringgrid1.RowCount do
begin
mas[i].n:=form1.StringGrid1.Cells[0,i];
mas[i].num:=form1.StringGrid1.Cells[1,i];
mas[i].polz:=form1.StringGrid1.Cells[2,i];
mas[i].nach:=form1.StringGrid1.Cells[3,i];
mas[i].timer:=form1.StringGrid1.Cells[4,i];
mas[i].tar:=form1.StringGrid1.Cells[5,i];
mas[i].sk:=form1.StringGrid1.Cells[6,i];
mas[i].usl:=form1.StringGrid1.Cells[7,i];
mas[i].pr:=form1.StringGrid1.Cells[8,i];
end;
form4.stringgrid1.RowCount:=2;
a:=cbb1.ItemIndex+1;
b:=edt1.Text;
c:=1;
if a=1 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].num then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=2 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].polz then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=3 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].nach then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=4 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].timer then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=5 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].tar then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=6 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].sk then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=7 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].usl then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
if a=8 then
begin
for i:=1 to high(mas) do
begin
if b=mas[i].pr then
begin
form4.StringGrid1.Cells[0,c]:=mas[i].n;
form4.StringGrid1.Cells[1,c]:=mas[i].num;
form4.StringGrid1.Cells[2,c]:=mas[i].polz;
form4.StringGrid1.Cells[3,c]:=mas[i].nach;
form4.StringGrid1.Cells[4,c]:=mas[i].timer;
form4.StringGrid1.Cells[5,c]:=mas[i].tar;
form4.StringGrid1.Cells[6,c]:=mas[i].sk;
form4.StringGrid1.Cells[7,c]:=mas[i].usl;
form4.StringGrid1.Cells[8,c]:=mas[i].pr;
c:=c+1;
if c>1 then form4.stringgrid1.RowCount:=c;
end;
end;
end;
end;
end.