Курсовая работа: Создание базы данных "РЭО-ГАИ"
procedure TForm1. N11Click (Sender: TObject);
begin
ADOTable1. Active: =false;
ADOTable1. TableName: ='Цвета';
ADOTable1. Active: =true;
StatusBar1. SimpleText: =n11. Caption;
end;
procedure TForm1. N12Click (Sender: TObject);
begin
ADOTable1. Active: =false;
ADOTable1. TableName: ='Автомобили';
ADOTable1. Active: =true;
StatusBar1. SimpleText: =n12. Caption;
end;
procedure TForm1. N13Click (Sender: TObject);
begin
ADOTable1. Active: =false;
ADOTable1. TableName: ='Движение';
ADOTable1. Active: =true;
StatusBar1. SimpleText: =n13. Caption;
end;
procedure TForm1. N14Click (Sender: TObject);
begin
ADOTable1. Active: =false;
ADOTable1. TableName: ='Владельцы';
ADOTable1. Active: =true;
StatusBar1. SimpleText: =n14. Caption;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB,
ADODB, Mask, Buttons;
type
TZaprosy = class (TForm)
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
MaskEdit1: TMaskEdit;
ComboBox1: TComboBox;
Label6: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
procedure SpeedButton1Click (Sender: TObject);
procedure SpeedButton2Click (Sender: TObject);
procedure SpeedButton3Click (Sender: TObject);
procedure SpeedButton4Click (Sender: TObject);
procedure SpeedButton5Click (Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Zaprosy: TZaprosy;
implementation
{$R *. dfm}
procedure TZaprosy. SpeedButton1Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: =' SELECT Автомобили. [РНН владельца], COUNT (Автомобили.
[№автомобиля]) '+
' FROM Автомобили '+
// ' WHERE Владельцы. [РНН владельца] = Автомобили. [РНН
владельца] ';
' GROUP BY Автомобили. [РНН владельца] ' +
' ORDER BY Автомобили. [РНН владельца] ; ';
adodataset1. Active: =true;
end;
procedure TZaprosy. SpeedButton2Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: =' SELECT [№автомобиля], [№двигателя] '+
' FROM Автомобили
'+
' WHERE [№двигателя]
LIKE '+''''+'%'+MaskEdit1. Text+'%'+'''';
adodataset1. Active: =true;
end;
procedure TZaprosy. SpeedButton3Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: =' SELECT Движение. [№автомобиля], datediff (yy, Автомобили. [Дата выпуска],getdate
()) '+
' FROM Движение, Автомобили, Операции '+
' WHERE Автомобили. [№автомобиля] =Движение. [№автомобиля] '+
' and Операции. [Код операции] =Движение. [Код операции] '+
' and Операции. [Наименование операции] like ''%постан%'''+
' and [Дата операции] < getdate (); ';
adodataset1. Active: =true;
end;
procedure TZaprosy. SpeedButton4Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: =' SELECT Движение. [№автомобиля], Районы_учета. [Наименование района учета], Операции.
[Наименование операции] '+
' FROM Операции, Районы_учета, Движение '+
' WHERE Районы_учета. [Код района учета] =Движение. [Код
района учета] '+
' AND Операции. [Код операции] =Движение. [Код операции] '+
' AND Районы_учета. [Наименование района учета] like '+''''+'%'+combobox1.
Text+'%'+'''' +
' AND month ([Дата операции]) =month (getdate ()); ';
adodataset1. Active: =true;
end;
procedure TZaprosy. SpeedButton5Click (Sender:
TObject);
begin
adodataset1. Active: =false;
adodataset1.commandText: =' SELECT Движение. [№автомобиля], Категории_цвета. [Наименование категории
цвета] '+
' FROM Категории_цвета, Цвета, Автомобили, Операции, Движение
'+
' WHERE Категории_цвета. [Код категории цвета] =Цвета. [Код
категории цвета] '+
' AND Цвета. [Код цвета] =Автомобили. [Код цвета] '+
' AND Автомобили. [№автомобиля] =Движение. [№автомобиля] '+
' AND Операции. [Наименование операции] = ''Постановка на
учет'''+
' AND year (Движение. [Дата операции]) =year (getdate ()); ';
adodataset1. Active: =true;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids,
DB, ADODB, Mask, Menus,
Word2000, OleServer;
type
TOtchety = class (TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ADODataSet2: TADODataSet;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Label4: TLabel;
ComboBox1: TComboBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Label5: TLabel;
Label6: TLabel;
ComboBox2: TComboBox;
Label7: TLabel;
N2: TMenuItem;
WordDocument1: TWordDocument;
WordApplication1: TWordApplication;
SaveDialog1: TSaveDialog;
procedure N1Click (Sender: TObject);
procedure SpeedButton1Click (Sender: TObject);
procedure SpeedButton2Click (Sender: TObject);
procedure SpeedButton3Click (Sender: TObject);
procedure N2Click (Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Otchety: TOtchety;
otchetnum: integer;
implementation
uses Unit6;
{$R *. dfm}
procedure TOtchety. N1Click (Sender: TObject);
var
c,n: integer;
s,rs: string;
begin
form6. Show;
// leep (10);
for n: =0 to adodataset2. RecordCount-1 do
begin
rs: ='';
s: ='';
if n=0 then
begin
for c: =0 to DBGrid1. Columns. Count-1 do
begin
s: =DBGrid1. Columns [c]. FieldName+ '';
rs: =rs+s;
end;
form6. Memo1. Lines. Add (rs);
rs: ='';
s: ='';
end;
for c: =0 to DBGrid1. Columns. Count-1 do
begin
s: =DBGrid1. Columns [c]. Field. AsString+'';
rs: =rs+s;
end;
form6. memo1. Lines. Add (rs);
adodataset2. Next;
end;
begin
if form6. savedialog1. Execute then
form6. memo1. Lines. SaveToFile (form6. savedialog1.
FileName);
end;
end;
procedure TOtchety. SpeedButton1Click (Sender:
TObject);
begin
adodataset2. Active: =false;
adodataset2.commandText: =' SELECT Движение. [№автомобиля], Движение. [РНН владельца],'+
'Операции. [Наименование операции], Районы_учета. [Наименование
района учета],'+
'Движение. [Дата операции] '+
' FROM Движение, Операции,Районы_учета '+
' WHERE Движение. [№автомобиля] like '+''''+'%'+combobox1. Text+'%'+''''
+
' AND Районы_учета. [Код района учета] = Движение. [Код
района учета] '+
' AND Операции. [Код операции] = Движение. [Код операции] ; ';
adodataset2. Active: =true;
end;
procedure TOtchety. SpeedButton2Click (Sender:
TObject);
begin
adodataset2. Active: =false;
adodataset2.commandText: =' SELECT [№автомобиля], Автомобили. [РНН владельца],
Владельцы. [ФИО/наименование] '+
' FROM Автомобили, Владельцы '+
' WHERE Владельцы. [Рнн владельца] = Автомобили. [РНН
владельца] '+
' AND [Признак владельца] = ''ф'' '+
' order by Владельцы. [ФИО/наименование] ';
adodataset2. Active: =true;
end;
procedure TOtchety. SpeedButton3Click (Sender:
TObject);
begin
// QuotedStr (Maskedit2. Text);
adodataset2. Active: =false;
adodataset2.commandText: =' SELECT Движение. [Дата операции], Движение. [№автомобиля], Движение. [РНН
владельца],'+
'Районы_учета. [Наименование района учета], Операции. [Наименование
операции] '+
' FROM Движение, Районы_учета, Операции '+
' WHERE Районы_учета. [Код района учета] = Движение. [Код
района учета] '+
' AND Операции. [Код операции] = Движение. [Код операции] '+
' and Движение. [Дата операции] ='''+ComboBox2. Text +'''';
// ' AND year (Движение. [Дата операции]) =year (''13 October
2007'') '+
// ' and month (Движение. [Дата операции]) =month (''13 October
2007'') '+
// ' and day (Движение. [Дата операции]) =day (''13 October 2007'');
';
// ' and SHTRAFI. Oplacheno = ''Оплачено '' AND dbo. SHTRAFI. Data BETWEEN '''+ MaskEdit3. Text +''' AND '''+
MaskEdit4. Text +''' '+
// ' AND Aaeea? aoee. "aaoa iiaa? e"='''+ComboBox2.
Text +''''+
adodataset2. Active: =true;
end;
procedure TOtchety. N2Click (Sender: TObject);
var filename,ran1: Olevariant;
rowcount,colcount, i,j: integer;
temp: string;
begin
savedialog1. FileName: ='otchet'+inttostr (otchetnum)
+'. doc'; // имя файла
otchetnum: =otchetnum+1; // формирование
след отчета
wordapplication1. Connect; // соединение
filename: =savedialog1. FileName;
wordapplication1. Documents. Add (emptyparam,emptyparam,emptyparam,emptyparam);
// создание нового файла
Страницы: 1, 2, 3, 4, 5 |