Скачиваний:
13
Добавлен:
17.06.2023
Размер:
1.3 Mб
Скачать

begin dm.oc.Active:=false;

dm.oc.CommandText:='Select id_oc,fio_st,nazv_dis,sem_dis,zn_oc,opis_oc,([zn_oc]&" ("&[opis_oc]&")") as ocen,zn_oc,lek_dis FROM stud,ocenka,discip WHERE (id_st=id_st_oc) and (id_dis=id_dis_oc) and (id_gr_oc='+id_gr+') and (id_dis_oc='+id_dis+')';

dm.oc.Active:=true;

if application.MessageBox('Хотите напечатать ведомость?','Печать',mb_yesno+mb_iconquestion)=idyes then

begin

WordApplication1.Connect; // Устанавливаем связь с сервером

//Открываем шаблон otchet.dot в Word Template:=ExtractFilePath(Application.EXEName)+'data\Шабл оны\Ведомость.dot'; //путь к шаблону документа

WordApplication1.Documents.Add(Template,EmptyParam,Empt yParam,EmptyParam);// создаем документ на основе шаблона

WordDocument1.ConnectTo(WordApplication1.ActiveDocumen t); //Связываем компонент WordDocument1 c активным документом (т.е. с только что созданным документом)

Replace:=true; // параметр, задающий режим замены

FindText:='#1'; // что меняем

ReplaceWith:=cb2.Text; // на что меняем

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

Replace:=true; // параметр, задающий режим замены

FindText:='#2'; // что меняем ReplaceWith:=label3.Caption; // на что меняем

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

Replace:=true; // параметр, задающий режим замены

FindText:='#3'; // что меняем

ReplaceWith:=cb1.Text; // на что меняем WordDocument1.Range.Find.Execute(FindText,EmptyParam,E mptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam, EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E mptyParam,EmptyParam,EmptyParam);

Replace:=true; // параметр, задающий режим замены

FindText:='#5'; // что меняем

ReplaceWith:=dm.oc.fieldbyname('lek_dis').AsString; // на что меняем

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

//Заполняем таблицу списка объектов

Table1:=WordDocument1.Tables.Item(1); //связываем имя

Table1 с первой таблицей документа //WordDocument1.Tables - это массив таблиц документа (тип

Tables), а WordDocument1.Tables.Item(i) - i-ая таблица i:=2; ocen:=0;

dm.temp.First;

While not dm.oc.Eof do begin

47

Table1.Rows.Add(EmptyParam); ocen:=ocen+dm.oc.Fieldbyname('zn_oc').AsInteger; Table1.Cell(i, 1).Range.Text := inttostr(i-1);

Table1.Cell(i, 2).Range.Text := dm.oc.Fieldbyname('fio_st').AsString;

Table1.Cell(i, 3).Range.Text := dm.oc.Fieldbyname('ocen').AsString;

inc(i);dm.oc.next;

end; Table1.Rows.Item(i).Delete;

Replace:=true; // параметр, задающий режим замены

FindText:='#4'; // что меняем ReplaceWith:=floattostr(roundto(ocen/(i-2),-2)); // на что

меняем

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam); WordApplication1.Visible:=true; //делаем приложение MS

Word видимым

WordApplication1.Disconnect; // Разрываем связь с сервером end;

end;

end;

procedure TFOcenka.cb3KeyPress(Sender: TObject; var Key: Char);

begin key:=#0; end;

procedure TFOcenka.BitBtn3Click(Sender: TObject); begin

if dm.oc.RecordCount=0 then showmessage('Записи отсутствуют')

else begin

if cb3.Text='' then showmessage('Оценка не выбрана') else

begin id_oc:=dm.oc.Fields[0].AsString;

dm.com.CommandText:='Update ocenka SET zn_oc="'+inttostr(cb3.ItemIndex+2)+'",opis_oc="'+cb3.Text+'" WHERE (id_oc='+id_oc+')';

dm.com.Execute; showmessage('Оценка выставлена'); dm.oc.Active:=false; dm.oc.CommandText:='Select

id_oc,fio_st,nazv_dis,sem_dis,zn_oc,opis_oc,([zn_oc]&" ("&[opis_oc]&")") as ocen FROM stud,ocenka,discip WHERE (id_st=id_st_oc) and (id_dis=id_dis_oc) and (id_gr_oc='+id_gr+') and (id_dis_oc='+id_dis+')';

dm.oc.Active:=true;

end;

end;

end;

end.

Листинг Б.14 – ot1

unit ot1; interface uses

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

Dialogs, StdCtrls, Buttons, ExtCtrls, WordXP, OleServer,registry,math;

type

TFot1 = class(TForm)

Label1: TLabel;

Panel1: TPanel; BitBtn1: TBitBtn; BitBtn2: TBitBtn; cb1: TComboBox;

WordApplication1: TWordApplication; WordDocument1: TWordDocument;

procedure cb1KeyPress(Sender: TObject; var Key: Char); procedure BitBtn2Click(Sender: TObject);

procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);

procedure FormShow(Sender: TObject); procedure BitBtn1Click(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

Fot1: TFot1; implementation uses datm; {$R *.dfm}

procedure TFot1.cb1KeyPress(Sender: TObject; var Key: Char); begin

key:=#0;

end;

procedure TFot1.BitBtn2Click(Sender: TObject); begin

closequery;

end;

procedure TFot1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin cb1.Clear;close; end;

procedure TFot1.FormShow(Sender: TObject); begin

dm.temp.active:=false;

dm.temp.commandtext:='Select ([nazv_dis]&", сем.:

"&[sem_dis]) as sem from discip ORDER BY sem_dis'; dm.temp.active:=true;

While not dm.temp.Eof do begin

cb1.items.add(dm.temp.fields[0].asstring);

dm.temp.next;

end;

end;

procedure TFot1.BitBtn1Click(Sender: TObject); var

Template,NewTemplate,FindText, NewStr, Replace,ReplaceWith:OleVariant;

LinkToFile,SaveWithDocument,Range:OleVariant; Table1: Table;

i: integer;

Reg: TRegistry; flag:boolean; ocen:real;

begin

if tm=0 then begin

WordApplication1.Connect; // Устанавливаем связь с сервером

//Открываем шаблон otchet.dot в Word

Template:=ExtractFilePath(Application.EXEName)+'data\Шабл оны\БаллПоДисциплине.dot'; //путь к шаблону документа

WordApplication1.Documents.Add(Template,EmptyParam,Empt yParam,EmptyParam);// создаем документ на основе шаблона

WordDocument1.ConnectTo(WordApplication1.ActiveDocumen t); //Связываем компонент WordDocument1 c активным документом (т.е. с только что созданным документом)

Replace:=true; // параметр, задающий режим замены

FindText:='#0'; // что меняем

ReplaceWith:=cb1.Text;

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

dm.temp.Active:=false;

dm.temp.CommandText:='Select avg(zn_oc) as sred from ocenka,discip,gruppa WHERE (id_dis=id_dis_oc) and

(id_gr=id_gr_oc) and (([nazv_dis]&", сем.:

"&[sem_dis])="'+cb1.Text+'") '; dm.temp.Active:=true;

tmp:=floattostr(roundto(dm.temp.Fieldbyname('sred').asfloat,- 2)) ;

Replace:=true; // параметр, задающий режим замены

FindText:='#1'; // что меняем

ReplaceWith:=tmp; // на что меняем WordDocument1.Range.Find.Execute(FindText,EmptyParam,E mptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

dm.temp.Active:=false;

dm.temp.CommandText:='Select nazv_gr,avg(zn_oc) as sred from ocenka,discip,gruppa WHERE (id_dis=id_dis_oc) and

(id_gr=id_gr_oc) and (([nazv_dis]&", сем.:

"&[sem_dis])="'+cb1.Text+'") GROUP BY nazv_gr'; dm.temp.Active:=true;

//Заполняем таблицу списка объектов

Table1:=WordDocument1.Tables.Item(1); //связываем имя

Table1 с первой таблицей документа //WordDocument1.Tables - это массив таблиц документа (тип

Tables), а WordDocument1.Tables.Item(i) - i-ая таблица i:=2; ocen:=0;

dm.temp.First;

While not dm.temp.Eof do begin

Table1.Rows.Add(EmptyParam); Table1.Cell(i, 1).Range.Text := inttostr(i-1);

Table1.Cell(i, 2).Range.Text := dm.temp.Fieldbyname('nazv_gr').AsString;

Table1.Cell(i, 3).Range.Text := floattostr(roundto(dm.temp.Fieldbyname('sred').asfloat,-2));

//ocen:=ocen+dm.temp.Fieldbyname('sred').asfloat; inc(i);dm.temp.next;

end; Table1.Rows.Item(i).Delete;

WordApplication1.Visible:=true; //делаем приложение MS Word видимым

WordApplication1.Disconnect; // Разрываем связь с сервером end

else if tm=1 then begin

tmp:='';

dm.temp.Active:=false;

dm.temp.CommandText:='Select zn_oc,count(zn_oc) as kol from ocenka,discip,gruppa WHERE (id_dis=id_dis_oc) and (id_gr=id_gr_oc) and (([nazv_dis]&", сем.:

"&[sem_dis])="'+cb1.Text+'") GROUP BY zn_oc ORDER BY zn_oc';

dm.temp.Active:=true;

48

if dm.temp.RecordCount=0 then showmessage('Экзамен по дисциплине не проводился')

else begin

While not dm.temp.Eof do begin tmp:=tmp+'Оценка:

'+dm.temp.fieldbyname('zn_oc').AsString+', количество:

'+dm.temp.fieldbyname('kol').AsString+#13; dm.temp.Next;

end;

showmessage(tmp);

end;

end;

end;

end.

Листинг Б.15 – ot2

unit ot2; interface uses

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

Dialogs, WordXP, OleServer, StdCtrls, Buttons, ExtCtrls, Spin,registry,math;

type

TFot2 = class(TForm) Label1: TLabel; Panel1: TPanel; BitBtn1: TBitBtn; BitBtn2: TBitBtn;

WordApplication1: TWordApplication; WordDocument1: TWordDocument; se1: TSpinEdit;

procedure BitBtn2Click(Sender: TObject);

procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);

procedure BitBtn1Click(Sender: TObject); private

{Private declarations } public

{Public declarations } end;

var

Fot2: TFot2; implementation uses datm; {$R *.dfm}

procedure TFot2.BitBtn2Click(Sender: TObject); begin

closequery;

end;

procedure TFot2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin se1.Value:=1;;close; end;

procedure TFot2.BitBtn1Click(Sender: TObject); var

Template,NewTemplate,FindText, NewStr, Replace,ReplaceWith:OleVariant;

LinkToFile,SaveWithDocument,Range:OleVariant; Table1: Table;

i: integer;

Reg: TRegistry; flag:boolean; ocen:real;

begin

WordApplication1.Connect; // Устанавливаем связь с сервером

//Открываем шаблон otchet.dot в Word

Template:=ExtractFilePath(Application.EXEName)+'data\Шабл оны\БаллПоСеместру.dot'; //путь к шаблону документа

WordApplication1.Documents.Add(Template,EmptyParam,Empt yParam,EmptyParam);// создаем документ на основе шаблона

WordDocument1.ConnectTo(WordApplication1.ActiveDocumen t); //Связываем компонент WordDocument1 c активным документом (т.е. с только что созданным документом)

Replace:=true; // параметр, задающий режим замены

FindText:='#0'; // что меняем

ReplaceWith:=se1.Text;

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

dm.temp.Active:=false;

dm.temp.CommandText:='Select avg(zn_oc) as sred from ocenka,discip,gruppa WHERE (id_dis=id_dis_oc) and (id_gr=id_gr_oc) and (sem_dis='+se1.Text+') ';

dm.temp.Active:=true; tmp:=floattostr(roundto(dm.temp.Fieldbyname('sred').asfloat,-

2)) ;

eplace:=true; // параметр, задающий режим замены

FindText:='#1'; // что меняем

ReplaceWith:=tmp; // на что меняем

WordDocument1.Range.Find.Execute(FindText,EmptyParam,E

mtyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,E

mptyParam,EmptyParam,EmptyParam);

dm.temp.Active:=false;

dm.temp.CommandText:='Select ([fio_st]&", ном. зачет.:

"&[nom_st]) as student,avg(zn_oc) as sred from ocenka,discip,gruppa,stud WHERE (id_dis=id_dis_oc) and (id_gr=id_gr_oc) and (id_st=id_st_oc) and

(sem_dis='+se1.Text+') GROUP BY ([fio_st]&", ном. зачет.:

"&[nom_st])'; dm.temp.Active:=true;

//Заполняем таблицу списка объектов

Table1:=WordDocument1.Tables.Item(1); //связываем имя

Table1 с первой таблицей документа //WordDocument1.Tables - это массив таблиц документа (тип

Tables), а WordDocument1.Tables.Item(i) - i-ая таблица i:=2; ocen:=0;

dm.temp.First;

While not dm.temp.Eof do begin

Table1.Rows.Add(EmptyParam); Table1.Cell(i, 1).Range.Text := inttostr(i-1);

Table1.Cell(i, 2).Range.Text := dm.temp.Fieldbyname('student').AsString;

Table1.Cell(i, 3).Range.Text := floattostr(roundto(dm.temp.Fieldbyname('sred').asfloat,-2));

//ocen:=ocen+dm.temp.Fieldbyname('sred').asfloat; inc(i);dm.temp.next;

end; Table1.Rows.Item(i).Delete;

49

WordApplication1.Visible:=true; //делаем приложение MS Word видимым

WordApplication1.Disconnect; // Разрываем связь с сервером end;

end.

Листинг Б.16 – pass

unit pass; interface uses

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

Dialogs,inifiles, StdCtrls, Buttons, ExtCtrls; type

TFpass = class(TForm) Panel1: TPanel; BitBtn1: TBitBtn; BitBtn2: TBitBtn; Label1: TLabel;

cb: TComboBox; Label2: TLabel; e: TEdit;

procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);

procedure FormShow(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

Fpass: TFpass; implementation uses datm, main; {$R *.dfm}

procedure TFpass.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin

if application.MessageBox('Вы уверены?','Выход из программы!',mb_yesno+mb_iconquestion)=idyes then

begin dm.ado.Connected:=false; application.Terminate; end

else canclose:=false; end;

procedure TFpass.FormShow(Sender: TObject); var inifile:tinifile;

dbp:string; begin

IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Data\op tions.ini'); photodir:=ExtractFilePath(Application.ExeName)+'Data\Фото\'; DBP := IniFile.ReadString('options', 'DBPath', ''); application.Title:=IniFile.ReadString('options', 'Title', ''); fmain.Caption:=IniFile.ReadString('options', 'mform', ''); avtor:=IniFile.ReadString('options', 'avtor', ''); grupa:=IniFile.ReadString('options', 'gruppa', '');

IniFile.Free;

fpass.Caption:=application.Title;

dm.od.InitialDir:=ExtractFilePath(Application.ExeName)+'Data\'

;

try dm.ADO.Connected:=false;

50

dm.ADO.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4. 0;Data Source='+dbp+';Persist Security Info=False';

dm.ADO.Connected:=true; except

if application.MessageBox('Произошла ошибка при подключении к базе данных!'#13'Хотите указать месторасположение базы данных?','База данных',mb_yesno+mb_iconquestion)=idyes then

begin

if dm.od.Execute then begin

IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Data\op tions.ini');

inifile.WriteString('options','DBPath',dm.od.FileName);

IniFile.Free;

dbp:=dm.od.FileName;

dm.ADO.Connected:=false;

dm.ADO.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4. 0;Data Source='+dbp+';Persist Security Info=False';

dm.ADO.Connected:=true; end

else begin

dm.ado.Connected:=false; showmessage('Вы вышли из программы'); application.Terminate;

end; end

else begin

dm.ado.Connected:=false; showmessage('Вы вышли из программы'); application.Terminate;

end;

end;

cb.Clear;

dm.temp.Active:=false;

dm.temp.CommandText:='Select login from pass order by login'; dm.temp.Active:=true;

while not dm.temp.Eof do begin

cb.Items.Add(dm.temp.Fields[0].AsString);

dm.temp.Next;

end;

end;

procedure TFpass.BitBtn2Click(Sender: TObject); begin

closequery;

end;

procedure TFpass.BitBtn1Click(Sender: TObject); begin

if (cb.Text='') OR (e.Text='') then showmessage('Вы не выбрали имя пользователя и/или не ввели пароль')

else begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select login from pass where (login="'+cb.Text+'") and (pass="'+e.Text+'")';

dm.temp.Active:=true;

if dm.temp.RecordCount=0 then showmessage('Данный пароль не соответствует выбранному имени пользователя')

else begin

if (dm.temp.Fields[0].AsString='Администратор') then begin

end

else if (dm.temp.Fields[0].AsString='Учебный отдел')then

begin end

else if (dm.temp.Fields[0].AsString='Преподаватель')then begin

end;

fpass.Hide;

fmain.ShowModal;

end;

end;

end;

end.

Листинг Б.17 – Spec

unit Spec; interface uses

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

Dialogs, Grids, DBGrids, Menus,accessdb; type

TFSpec = class(TForm) DBGrid1: TDBGrid; PopupMenu1: TPopupMenu; N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure DBGrid1DblClick(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

FSpec: TFSpec; implementation

uses aspec, datm, Discip; {$R *.dfm}

procedure TFSpec.N1Click(Sender: TObject); begin

faspec.Caption:=caption+' :: '+n1.caption; tm:=0;

faspec.ShowModal;

end;

procedure TFSpec.N2Click(Sender: TObject); begin

if dm.sp.RecordCount=0 then showmessage('Записи отсутствуют')

else begin tm:=1;

id_sp:=dm.sp.Fields[0].AsString;

if accessdb.Update('sp','spec',id_sp)=false then showmessage('Запись используется другим пользователем')

else begin

faspec.e1.Text:=dm.sp.fieldbyname('nazv_sp').AsString; faspec.Caption:=caption+' :: '+n2.caption;

51

faspec.ShowModal;

end;

end;

end;

procedure TFSpec.N3Click(Sender: TObject); begin

if dm.sp.RecordCount=0 then showmessage('Записи отсутствуют')

else begin tm:=1;

id_sp:=dm.sp.Fields[0].AsString;

if accessdb.Delete('sp','spec',id_sp)=false then showmessage('Запись используется другим пользователем')

else dm.sp.Requery(); end;

end;

procedure TFSpec.N6Click(Sender: TObject); begin

dm.sp.Active:=false;

dm.sp.CommandText:='Select * from spec order by nazv_sp'; dm.sp.Active:=true;

end;

procedure TFSpec.N7Click(Sender: TObject); begin

dm.sp.Active:=false; dm.sp.CommandText:='Select * from spec'; dm.sp.Active:=true;

end;

procedure TFSpec.N5Click(Sender: TObject); begin

tmp:=inputbox('Фильтр',n5.Caption,''); dm.sp.Active:=false;

dm.sp.CommandText:='Select * from spec WHERE (nazv_sp like "%'+tmp+'%")';

dm.sp.Active:=true;

end;

procedure TFSpec.DBGrid1DblClick(Sender: TObject); begin

if fdiscip.Visible=true then begin

if dm.sp.RecordCount=0 then showmessage('Записи отсутствуют')

else begin

id_sp:=dm.sp.Fields[0].AsString; dm.com.CommandText:='Insert into disspec

(id_dis_ds,id_sp_ds) values ('+id_dis+','+id_sp+')'; dm.com.Execute;

dm.dsp.Active:=false;

dm.dsp.Active:=true;

close;

end;

end;

end;

end.

Листинг Б.18 – Stud

unit Stud; interface uses

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

Dialogs, Menus, Grids, DBGrids,accessdb; type

TFStud = class(TForm) DBGrid1: TDBGrid; PopupMenu1: TPopupMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N6: TMenuItem;

procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N5Click(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

FStud: TFStud; implementation uses aStud, datm; {$R *.dfm}

procedure TFStud.N1Click(Sender: TObject); begin

fastud.Caption:=caption+' :: '+n1.caption; tm:=0; fastud.Button1.Enabled:=true;

fastud.im1.Picture.LoadFromFile(photodir+'0.jpg');

dm.temp.active:=false; dm.temp.commandtext:='Select nazv_gr from gruppa '; dm.temp.active:=true;

While not dm.temp.Eof do begin

fastud.cb1.items.add(dm.temp.fields[0].asstring);

dm.temp.next;

end;

fastud.ShowModal;

end;

procedure TFStud.N2Click(Sender: TObject); begin

if dm.st.RecordCount=0 then showmessage('Записи отсутствуют')

else begin tm:=1;

id_st:=dm.st.Fields[0].AsString; fastud.Button1.Enabled:=false;

if accessdb.Update('st','stud',id_st)=false then showmessage('Запись используется другим пользователем')

else begin

dm.temp.active:=false; dm.temp.commandtext:='Select nazv_gr from gruppa '; dm.temp.active:=true;

While not dm.temp.Eof do begin

fastud.cb1.items.add(dm.temp.fields[0].asstring);

dm.temp.next;

end; fastud.e1.Text:=dm.st.fieldbyname('fio_st').AsString; fastud.im1.Picture.LoadFromFile(photodir+id_st+'.jpeg'); fastud.cb1.Text:=dm.st.fieldbyname('nazv_gr').AsString; fastud.e2.Text:=dm.st.fieldbyname('nom_st').AsString; fastud.cb1Change(Sender);

fastud.Caption:=caption+' :: '+n2.caption; fastud.ShowModal;

end;

end;

end;

procedure TFStud.N3Click(Sender: TObject); begin

if dm.st.RecordCount=0 then showmessage('Записи отсутствуют')

else begin tm:=1;

id_st:=dm.st.Fields[0].AsString;

if accessdb.Delete('st','stud',id_st)=false then showmessage('Запись используется другим пользователем')

else dm.st.Requery(); end;

end;

procedure TFStud.N7Click(Sender: TObject); begin

dm.st.Active:=false;

dm.st.CommandText:='Select id_st,fio_st,nazv_gr,nom_st from stud,gruppa where (id_gr=id_gr_st)';

dm.st.Active:=true;

end;

procedure TFStud.N6Click(Sender: TObject); begin

dm.st.Active:=false;

dm.st.CommandText:='Select id_st,fio_st,nazv_gr,nom_st from stud,gruppa where (id_gr=id_gr_st) ORDER BY fio_st'; dm.st.Active:=true;

end;

procedure TFStud.N5Click(Sender: TObject); begin

tmp:=inputbox('Фильтр',n5.Caption,''); dm.st.Active:=false;

dm.st.CommandText:='Select id_st,fio_st,nazv_gr,nom_st from stud,gruppa where (id_gr=id_gr_st) and (nom_st like "%'+tmp+'%")';

dm.st.Active:=true;

end;

end.

Листинг Б.18 – UEasyPath

unit UEasyPath; interface

uses

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

Dialogs, StdCtrls;

function PathWithoutExt(Path:string):string; function NameFile(Path:string;Ext:boolean):string; function PathToFile(Path:string):string;

function Ext(Path:string):string; implementation

function PathWithoutExt(Path:string):string; var s:string;

i:integer; begin i:=1;

while s<>'.' do begin

s:=copy(path,length(path)-i+1,1); inc(i);

end; result:=copy(path,0,length(path)-i+1); end;

function NameFile(Path:string;Ext:boolean):string; var s,s1:string;

i:integer; begin i:=1;

while s<>'\' do

52

begin

i:=1;

s:=copy(path,length(path)-i+1,1);

while s<>'\' do

inc(i);

begin

end;

s:=copy(path,length(path)-i+1,1);

s1:=copy(path,length(path)-i+3,i);

inc(i);

if Ext=true then result:=s1

end;

else

result:=copy(path,0,length(path)-i+2);

begin

end;

i:=1;

function Ext(Path:string):string;

while s<>'.' do

var s:string;

begin

i:integer;

s:=copy(s1,length(s1)-i+1,1);

begin

inc(i);

i:=1;

end;

while s<>'.' do

result:=copy(s1,0,length(s1)-i+1);

begin

end;

s:=copy(path,length(path)-i+1,1);

end;

inc(i);

function PathToFile(Path:string):string;

end;

var s:string;

result:=copy(path,length(path)-i+3,i);

i:integer;

end;

begin

end.

53

Соседние файлы в папке Курсовые работы