unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrls, StdCtrls, ExtCtrls, Grids, DBGrids ,ShellApi, dblookup,
CheckLst;
type
TMyThread1 = class(TThread)
private
{ Private declarations }
protected
procedure DoWork;
procedure Execute; override;
end;
TMyThread2 = class(TThread)
private
{ Private declarations }
protected
procedure DoWork;
procedure Execute; override;
end;
TForm8 = class(TForm)
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
DBLookupComboBox1: TDBLookupComboBox;
DBLookupComboBox2: TDBLookupComboBox;
DBLookupComboBox3: TDBLookupComboBox;
DBLookupComboBox4: TDBLookupComboBox;
DBLookupComboBox5: TDBLookupComboBox;
CheckListBox1: TCheckListBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
a: string;
T1 : TMyThread1;
T2 : TMyThread2;
implementation
uses Unit2;
{$R *.dfm}
procedure TMyThread1.Execute;
begin
{Пока процесс не прервали, выполняем DoWork}
while not Terminated do
Synchronize(DoWork);
end;
procedure TMyThread2.Execute;
begin
{Пока процесс не прервали, выполняем DoWork}
while not Terminated do
Synchronize(DoWork);
end;
procedure TMyThread1.DoWork;
begin
{Пытаемся победить второй процесс :-)}
Form8.CheckListBox1.Checked[1]:= True;
end;
procedure TMyThread2.DoWork;
begin
{Пытаемся победить первый процесс :-)}
Form8.CheckListBox1.Checked[0]:= False;
end;
procedure TForm8.Button3Click(Sender: TObject);
begin
if Button3.Caption = 'Stop' then begin
// Прерываем оба процесса
T1.Terminate;
T2.Terminate;
// Изменяем название кнопки
Button3.Caption := 'Start';
// Выходим из процедуры
Exit;
end;
//Создаем и сразу запускаем два процесса
T1 := TMyThread1.Create(False);
T2 := TMyThread2.Create(False);
// Переименовываем кнопку
Button3.Caption := 'Stop';
end;
procedure TForm8.Button1Click(Sender: TObject);
begin
with DataModule2.ADOQuery1 do
begin close;
SQL.Clear;
datamodule2.adoquery1.Active:=false;
if CheckListBox1.Checked[0]=true then begin
datamodule2.ADOquery1.Close;
datamodule2.ADOquery1.SQl.Clear;
datamodule2.ADOquery1.sql.add('SELECT s.Familia as [Фамилия] ,s.Imya as [Имя] , s.Otchestvo as [Отчество] , s.Telefon as [Телефон], g.fakultet as [Факультет], g.Kafedra as [Кафедра] ');
datamodule2.ADOquery1.sql.add('FROM Gruppi as g, Studenti as s');
datamodule2.ADOquery1.sql.add('WHERE g.fakultet = :myparam');
datamodule2.ADOquery1.Parameters.ParamByName('myparam').Value := dblookupcombobox4.text;
datamodule2.ADOquery1.Open;
end;
if CheckListBox1.Checked[1]=true then begin
datamodule2.ADOquery1.Close;
datamodule2.ADOquery1.SQl.Clear;
datamodule2.ADOquery1.sql.add('select d.specializaciya as [Специализация],d.familia as [Фамилия], d.imya as [Имя], d.otchestvo as [Отчество], d.telefon as [Телефон]');
datamodule2.ADOquery1.sql.add('from Prepod as d');
datamodule2.ADOquery1.sql.add('where d.specializaciya = :myparam');
datamodule2.ADOquery1.Parameters.ParamByName('myparam').Value := dblookupcombobox5.text;
datamodule2.ADOquery1.Open;
end;
if CheckListBox1.Checked[2]=true then begin
datamodule2.ADOquery1.Close;
datamodule2.ADOquery1.SQl.Clear;
datamodule2.ADOquery1.sql.add( 'select g.kurator as [Куратор], g.Kafedra as [Кафедра],g.fakultet as[Факультет],g.№_gruppi as [№группы]');
datamodule2.ADOquery1.sql.add('from Gruppi as g');
datamodule2.ADOquery1.sql.add('where g.№_gruppi = :myparam');
datamodule2.ADOquery1.Parameters.ParamByName('myparam').Value := dblookupcombobox1.text;
datamodule2.ADOquery1.Open;
end;
if CheckListBox1.Checked[3]=true then begin
datamodule2.ADOquery1.Close;
datamodule2.ADOquery1.SQl.Clear;
datamodule2.ADOquery1.sql.add( 'select p.nazvanie as [Название], p.Tip as [Тип предмета], p.obem as [Количество часов] ');
datamodule2.ADOquery1.sql.add('from Predmeti as p');
datamodule2.ADOquery1.sql.add('where p.Tip = :myparam');
datamodule2.ADOquery1.Parameters.ParamByName('myparam').Value := dblookupcombobox2.text;
datamodule2.ADOquery1.Open;
end;
if CheckListBox1.Checked[4]=true then begin
datamodule2.ADOquery1.Close;
datamodule2.ADOquery1.SQl.Clear;
datamodule2.ADOquery1.sql.add('select p.Prepod as [N], d.familia as [Фамилия], p.nazvanie as [Предмет], p.obem as [Кол-во часов], p.Semestri as [Семестры], p.obem/p.Semestri as [Нагрузка] ');
datamodule2.ADOquery1.sql.add('from Prepod d inner join Predmeti p on p.Prepod=d.kod_prepod ');
datamodule2.ADOquery1.sql.Add('where d.kod_prepod = :myparam');
datamodule2.ADOquery1.Parameters.ParamByName('myparam').Value := dblookupcombobox3.KeyValue;
datamodule2.ADOquery1.Open;
end;
end;
end;
procedure TForm8.Button2Click(Sender: TObject);
// тут html отчет, нафиг никому не нужный
end;
procedure TForm8.FormShow(Sender: TObject);
begin
DataModule2.ADOTable3.Active := true;
end;
end.