Курсовая работа: Создание базы данных "РЭО-ГАИ"
worddocument1. connectto (wordapplication1.
activedocument); // обратится к новому файлу
// ran1: =worddocument1. Range;
rowcount: =adodataset2. RecordCount;
// сколько строк нужно создать в файле
colcount: =dbgrid1. Columns. Count; // сколько столбцов
нужно создать в файле
worddocument1. Tables. Add (worddocument1. Range,rowcount,colcount,emptyparam,emptyparam);
// соз-е строк и столбцов
for i: =1 to rowcount do
begin
for j: =1 to colcount do
begin
temp: =dbgrid1. Fields [j-1]. AsString; // содержание
ячейки в таблице
worddocument1. Tables. Item (1). cell (i,j).
range. text: =temp; // занести в doc
end;
adodataset2. Next; // следующая строка
end;
WordApplication1. Visible: = True; // сделать
документ видимым
worddocument1. SaveAs (filename); // сохранить
документ
end;
end.
procedure TForm3. BitBtn1Click (Sender: TObject);
begin
QuotedStr (maskedit1. Text);
QuotedStr (maskedit2. Text);
adodataset2. Active: =false;
adodataset2.commandText: =' SELECT dbo. UDOSTOVERENIYA.
N_udostovereniya, dbo. UDOSTOVERENIYA. Data_vipiski, dbo. UDOSTOVERENIYA. Srok_deistviya,
dbo. INSPEKTOR. FIO '+
' FROM dbo. UDOSTOVERENIYA INNER JOIN '+
' dbo. INSPEKTOR ON dbo. UDOSTOVERENIYA. Kod_inspectora
= dbo. INSPEKTOR. Kod_inspektora '+
' WHERE (dbo. INSPEKTOR. FIO LIKE '+'''%'+Edit3.
Text+'%'+''' AND dbo. UDOSTOVERENIYA. Data_vipiski BETWEEN '''+ MaskEdit1. Text
+ ''' AND '''+ MaskEdit2. Text +''') ';
adodataset2. Active: =true;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB,
ADODB, Buttons;
type
TProcedury = class (TForm)
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label1: TLabel;
Label2: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
ComboBox1: TComboBox;
Label8: TLabel;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Label10: TLabel;
Label11: TLabel;
procedure ComboBox1KeyPress (Sender: TObject;
var Key: Char);
procedure ComboBox3KeyPress (Sender: TObject;
var Key: Char);
procedure ComboBox2KeyPress (Sender: TObject;
var Key: Char);
procedure ComboBox3Change (Sender: TObject);
procedure ComboBox4Change (Sender: TObject);
procedure SpeedButton1Click (Sender: TObject);
procedure SpeedButton2Click (Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Procedury: TProcedury;
implementation
{$R *. dfm}
procedure TProcedury.comboBox1KeyPress (Sender:
TObject; var Key: Char);
begin
if not (key in ['0'. '9',#8]) then key: =#0;
end;
procedure TProcedury.comboBox3KeyPress (Sender:
TObject; var Key: Char);
begin
if not (key in ['0'. '9',#8]) then key: =#0;
end;
procedure TProcedury.comboBox2KeyPress (Sender:
TObject; var Key: Char);
begin
if not (key in ['0'. '9',#8]) then key: =#0;
end;
procedure TProcedury.comboBox3Change (Sender:
TObject);
var
i: integer;
begin
for i: =0 to ComboBox3. Items. Count do
if ComboBox3. ItemIndex=i then ComboBox1. ItemIndex:
=i;
end;
procedure TProcedury.comboBox4Change (Sender:
TObject);
var
i: integer;
begin
for i: =0 to ComboBox4. Items. Count do
if ComboBox4. ItemIndex=i then ComboBox2. ItemIndex:
=i;
end;
procedure TProcedury. SpeedButton1Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: ='execute
Vyboravto1';
adodataset1. Active: =true;
end;
procedure TProcedury. SpeedButton2Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: ='execute
Vyboravto2 '''+ combobox1. Text + ''',''' + combobox2. Text +''' ';
adodataset1. Active: =true;
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids,
StdCtrls, Buttons;
type
TSpravka = class (TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADODataSet1: TADODataSet;
Label5: TLabel;
Label8: TLabel;
Label3: TLabel;
ComboBox4: TComboBox;
Label11: TLabel;
Label12: TLabel;
ComboBox5: TComboBox;
Label14: TLabel;
Label15: TLabel;
ComboBox6: TComboBox;
BitBtn1: TBitBtn;
procedure BitBtn1Click (Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Spravka: TSpravka;
sum1, sum2, sum3: boolean;
implementation
{$R *. dfm}
procedure TSpravka. BitBtn1Click (Sender: TObject);
begin
sum1: =false;
sum2: =false;
sum3: =false;
if ComboBox4. Text<>'' then sum1: =true;
if ComboBox5. Text<>'' then sum2: =true;
if ComboBox6. Text<>'' then sum3: =true;
if (sum1) and (sum2) and (sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Марки_автомобиля, Цвета, Типы_кузова' +
' WHERE Автомобили. [Код типа кузова] =Типы_кузова. [Код
типа кузова] ' +
' AND Автомобили. [Код марки авто] =Марки_автомобиля. [Код
марки авто] ' +
' AND Автомобили. [Код цвета] =Цвета. [Код цвета] '+
' AND Типы_кузова. [Наименование] ='''+ComboBox4. Text
+''''+
' AND Марки_автомобиля. [Наименование] ='''+ComboBox5. Text
+''''+
' AND Цвета. [Наименование] ='''+ComboBox6. Text +'''';
adodataset1. Active: =true;
end;
if (not sum1) and (not sum2) and (not sum3)
then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECT* '+
' FROMАвтомобили';
adodataset1. Active: =true;
end;
if (not sum1) and (not sum2) and (sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Цвета' +
' WHERE Автомобили. [Код цвета] =Цвета. [Код цвета] '+
' AND Цвета. [Наименование] ='''+ComboBox6. Text +'''';
adodataset1. Active: =true;
end;
if (not sum1) and (sum2) and (not sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Марки_автомобиля' +
' WHERE Автомобили. [Код марки авто] =Марки_автомобиля. [Код
марки авто] ' +
' AND Марки_автомобиля. [Наименование] ='''+ComboBox5. Text
+'''';
adodataset1. Active: =true;
end;
if (sum1) and (not sum2) and (not sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Типы_кузова' +
' WHERE Автомобили. [Код типа кузова] =Типы_кузова. [Код
типа кузова] ' +
' AND Типы_кузова. [Наименование] ='''+ComboBox4. Text +'''';
adodataset1. Active: =true;
end;
if (not sum1) and (sum2) and (sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Марки_автомобиля, Цвета' +
' WHERE Автомобили. [Код марки авто] =Марки_автомобиля. [Код
марки авто] ' +
' AND Автомобили. [Код цвета] =Цвета. [Код цвета] '+
' AND Марки_автомобиля. [Наименование] ='''+ComboBox5. Text +''''+
' AND Цвета. [Наименование]
='''+ComboBox6. Text +'''';
adodataset1. Active: =true;
end;
if (sum1) and (not sum2) and (sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Марки_автомобиля, Цвета, Типы_кузова' +
' WHERE Автомобили. [Код типа кузова] =Типы_кузова. [Код
типа кузова] ' +
' AND Автомобили. [Код цвета] =Цвета. [Код цвета] '+
' AND Типы_кузова. [Наименование] ='''+ComboBox4. Text +''''+
' AND Цвета. [Наименование]
='''+ComboBox6. Text +'''';
adodataset1. Active: =true;
end;
if (sum1) and (sum2) and (not sum3) then
begin
adodataset1. Active: =false;
adodataset1.commandText: ='SELECTАвтомобили. * ' +
' FROMАвтомобили, Марки_автомобиля, Типы_кузова' +
' WHERE Автомобили. [Код типа кузова] =Типы_кузова. [Код
типа кузова] ' +
' AND Автомобили. [Код марки авто] =Марки_автомобиля. [Код
марки авто] ' +
' AND Типы_кузова. [Наименование] ='''+ComboBox4. Text
+''''+
' AND Марки_автомобиля. [Наименование] ='''+ComboBox5. Text +'''';
adodataset1. Active: =true;
end;
end;
end.
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm6 = class (TForm)
Memo1: TMemo;
SaveDialog1: TSaveDialog;
Button1: TButton;
procedure Button1Click (Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
{$R *. dfm}
procedure TForm6. Button1Click (Sender: TObject);
begin
memo1. Lines. Text: ='';
form6. Hide;
end; end.
|