3
Пермский государственный технический университет
Кафедра МСА
- КУРСОВАЯ РАБОТА:
- СУБД «Библиотека»
- Выполнила: студентка гр. АТПП01-1
- Таразов А.Ф.
- Проверил: доцент кафедры МСА
- Шмидт И. А.
Пермь, 2012
- Введение
- СУБД «Библиотека» — база данных версии InterBase6.5, построенная с помощью программ ERWin, IBConsole, IBExpert, выполнена в среде Delphi7.
- База данных учебная, охватывает далеко не все аспекты библиотечного дела. В ходе ее выполнения познакомилась с вышеперечисленными программами и построением запросов SQL.
- Приложение разработано в среде программирования Delphi 7.
- Модель
- библиотека база данные delphi
- База данных включает в себя 14 таблиц:
- 1. Читатель (Reader)
- 2. Штраф (Shtraf);
- 3. Выдача книги (Vida4a_kniga);
- 4. Автор (Author);
- 5. Автор произведения (Avtor_proizvedeniya);
- 6. Размещение книги (Place);
- 7. Экземпляр (Exzempl);
- 8. Издательство (Izdat);
- 9. Произведение в книге (ProizvedInBook);
- 10. Произведения (Proizvedenie);
- 11. Литературная форма (Tipe);
- 12. Жанр (Ganr);
- 13. Книга (Book);
- 14. Сотрудники библиотеки (Personal).
- Модель базы данных, построенная в ERWinе — ПРИЛОЖЕНИЕ1.
- Текст программы:
1. Главная форма
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit3, Unit2, Unit4, Unit5, Unit6, Unit7, Unit8,
Unit9, Unit10, Unit11, Unit12, Unit13, Unit14, Unit15, Unit16, Unit17,
Unit18, Unit19, Menus, IBDatabase, DB, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N14: TMenuItem;
IBDatabase1: TIBDatabase;
IBTransaction1: TIBTransaction;
Image1: TImage;
N13: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N17Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure N21Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.N2Click(Sender: TObject);
begin
Application.CreateForm(Tform2, Form2);
Form2.Show;
end;
procedure TForm1.N3Click(Sender: TObject);
begin
Application.CreateForm(Tform3, Form3);
Form3.Show;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
Application.CreateForm(Tform4, Form4);
Form4.Show;
end;
procedure TForm1.N5Click(Sender: TObject);
begin
Application.CreateForm(Tform5, Form5);
Form5.Show;
end;
procedure TForm1.N6Click(Sender: TObject);
begin
Application.CreateForm(Tform6, Form6);
Form6.Show;
end;
procedure TForm1.N7Click(Sender: TObject);
begin
Application.CreateForm(Tform7, Form7);
Form7.Show;
end;
procedure TForm1.N9Click(Sender: TObject);
begin
Application.CreateForm(Tform8, Form8);
Form8.Show;
end;
procedure TForm1.N10Click(Sender: TObject);
begin
Application.CreateForm(Tform9, Form9);
Form9.Show;
end;
procedure TForm1.N11Click(Sender: TObject);
begin
Application.CreateForm(Tform10, Form10);
Form10.Show;
end;
procedure TForm1.N12Click(Sender: TObject);
begin
Application.CreateForm(Tform11, Form11);
Form11.Show;
end;
procedure TForm1.N13Click(Sender: TObject);
begin
Application.CreateForm(Tform12, Form12);
Form12.Show;
end;
procedure TForm1.N14Click(Sender: TObject);
begin
close;
end;
procedure TForm1.N15Click(Sender: TObject);
begin
Application.CreateForm(Tform14, Form14);
Form14.Show;
end;
procedure TForm1.N16Click(Sender: TObject);
begin
Application.CreateForm(Tform13, Form13);
Form13.Show;
end;
procedure TForm1.N17Click(Sender: TObject);
begin
Application.CreateForm(Tform15, Form15);
Form15.Show;
end;
procedure TForm1.N19Click(Sender: TObject);
begin
Application.CreateForm(Tform16, Form16);
Form16.Show;
end;
procedure TForm1.N18Click(Sender: TObject);
begin
Application.CreateForm(Tform17, Form17);
Form17.Show;
end;
procedure TForm1.N20Click(Sender: TObject);
begin
Application.CreateForm(Tform18, Form18);
Form18.Show;
end;
procedure TForm1.N21Click(Sender: TObject);
begin
Application.CreateForm(Tform19, Form19);
Form19.Show;
end;
end.
2. Форма «Справочники: Книги»
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ExtCtrls, DBCtrls, Grids, DBGrids, IBCustomDataSet,
IBUpdateSQL, IBQuery, StdCtrls;
type
TForm2 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_BOOK: TIntegerField;
IBQuery1NAME: TIBStringField;
IBQuery1INDEX_KATAL: TIBStringField;
IBQuery1PAGES_1: TIntegerField;
IBQuery1PRACE: TFloatField;
IBQuery1DATE_POSTUPL: TDateField;
IBQuery1YEAR_IZD: TIBStringField;
IBQuery1ID_IZDAT: TIntegerField;
IBQuery2: TIBQuery;
IBQuery1izd: TStringField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery3: TIBQuery;
IBQuery4: TIBQuery;
DataSource3: TDataSource;
DBGrid3: TDBGrid;
DBGrid4: TDBGrid;
DataSource4: TDataSource;
IBQuery5: TIBQuery;
IBQuery3NAZVANIE: TIBStringField;
Label1: TLabel;
Label2: TLabel;
IBQuery4NAME: TIBStringField;
Label3: TLabel;
IBQuery5NAME: TIBStringField;
procedure IBQuery1AfterScroll(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.IBQuery1AfterScroll(DataSet: TDataSet);
begin
IBQuery3.Close;
IBQuery3.ParamByName(‘idbook’).AsInteger:=IBQuery1ID_BOOK.AsInteger;
IBQuery3.open;
IBQuery4.Close;
IBQuery4.ParamByName(‘book’).AsInteger:=IBQuery1ID_BOOK.AsInteger;
IBQuery4.open;
IBQuery5.Close;
IBQuery5.ParamByName(‘book’).AsInteger:=IBQuery1ID_BOOK.AsInteger;
IBQuery5.open;
end;
end
3. Форма «Справочники: Авторы»
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBQuery, ExtCtrls, DBCtrls, Grids, DBGrids,
IBUpdateSQL, StdCtrls;
type
TForm3 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
DataSource1: TDataSource;
DataSource2: TDataSource;
IBQuery2: TIBQuery;
IBQuery1ID_AUTHOR: TIntegerField;
IBQuery1FIO: TIBStringField;
IBQuery1DATE_BIRTH: TDateField;
IBQuery1DATE_MORE: TIBStringField;
IBQuery1COUNTRY: TIBStringField;
IBQuery2NAZVANIE: TIBStringField;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
DataSource3: TDataSource;
IBQuery3: TIBQuery;
IBQuery3NAME: TIBStringField;
Label2: TLabel;
Label3: TLabel;
procedure IBQuery1AfterScroll(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit1;
{$R *.dfm}
procedure TForm3.IBQuery1AfterScroll(DataSet: TDataSet);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘IDAUTHOR’).AsInteger:= IBQuery1ID_AUTHOR.AsInteger;
IBQuery2.Open;
IBQuery3.Close;
IBQuery3.ParamByName(‘avtor’).AsInteger:= IBQuery1ID_AUTHOR.AsInteger;
IBQuery3.Open;
end;
end.
4. Форма «Справочники: Штрафы»
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBUpdateSQL, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls, Buttons;
type
TForm4 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery2: TIBQuery;
IBQuery1ID_SHTRAF: TIntegerField;
IBQuery1ID_READER: TIntegerField;
IBQuery1SUMMA: TFloatField;
IBQuery1PRICHINA: TIBStringField;
IBQuery1DATE_STHRAF: TDateField;
IBQuery1Reader: TStringField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery3: TIBQuery;
IBQuery4: TIBQuery;
IBQuery3SUM: TFloatField;
IBQuery3reader: TStringField;
Label1: TLabel;
IBQuery3ID_READER: TIntegerField;
//procedure IBQuery1AfterInsert(DataSet: TDataSet);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses unit1;
{$R *.dfm}
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
//IBQuery3.ApplyUpdates;
end;
end.
5. Форма «Справочники: Читатели»
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls;
type
TForm5 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
IBQuery1: TIBQuery;
DataSource1: TDataSource;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_READER: TIntegerField;
IBQuery1FIO: TIBStringField;
IBQuery1DATE_BIRTH: TDateField;
IBQuery1NUMB_KARD: TIntegerField;
IBQuery1PLACE_WORK: TIBStringField;
IBQuery1ADRES: TIBStringField;
IBQuery1NUMB_TELEF: TIntegerField;
IBQuery1DATA_VID: TDateField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery2: TIBQuery;
IBQuery2NAME: TIBStringField;
IBQuery2DATE_VIDACH: TDateField;
IBQuery2DATE_VOZVR: TDateField;
Label1: TLabel;
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses unit1;
{$R *.dfm}
procedure TForm5.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘reader’).AsInteger:= IBQuery1ID_READER.AsInteger;
IBQuery2.Open;
end;
end.
6.Форма «Справочники: Издательства»
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ExtCtrls, DBCtrls, Grids, DBGrids, IBCustomDataSet,
IBUpdateSQL, IBQuery, StdCtrls;
type
TForm6 = class(TForm)
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1ID_IZDAT: TIntegerField;
IBQuery1NAME: TIBStringField;
IBQuery1CITY: TIBStringField;
IBQuery1COUTRY: TIBStringField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery2: TIBQuery;
IBQuery2NAME: TIBStringField;
Label1: TLabel;
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses unit1;
{$R *.dfm}
procedure TForm6.FormActivate(Sender: TObject);
begin
IBQuery1.Open;
end;
procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
IBQuery1.Close;
end;
procedure TForm6.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘izdat’).AsInteger:=IBQuery1ID_IZDAT.AsInteger;
IBQuery2.Open;
end;
end.
7. Форма «Справочники: Выдача книги»
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBTable, ExtCtrls, DBCtrls, Grids, DBGrids,
IBUpdateSQL, IBQuery;
type
TForm7 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1DATE_VIDACH: TDateField;
IBQuery1ID_READER: TIntegerField;
IBQuery1ID_EKZEMP: TIntegerField;
IBQuery1PRIM: TIBStringField;
IBQuery1SROK_VIDACH: TIntegerField;
IBQuery1DATE_VOZVR: TDateField;
IBQuery1ID_PERSONAL: TIntegerField;
IBQuery2: TIBQuery;
IBQuery1Reader: TStringField;
IBQuery3: TIBQuery;
IBQuery1personal: TStringField;
IBQuery4: TIBQuery;
IBQuery1book: TStringField;
// procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses unit1;
{$R *.dfm}
end.
8. Форма «Отчеты: Штрафы»
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBQuery, Grids, DBGrids, StdCtrls, ComCtrls;
type
TForm8 = class(TForm)
DBGrid2: TDBGrid;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBQuery2: TIBQuery;
IBQuery1ID_SHTRAF: TIntegerField;
IBQuery1ID_READER: TIntegerField;
IBQuery1SUMMA: TFloatField;
IBQuery1PRICHINA: TIBStringField;
IBQuery1DATE_STHRAF: TDateField;
IBQuery1reader: TStringField;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses unit1;
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
begin
IBQuery1.SQL.Text:= ‘select (date_vidach-cast(»’ + DateToStr(Today) + »’ as date) + srok_vidach) as dolg, id_reader, fio ‘ +
‘ from vida4a_kniga v, reader r where v.id_reader=r.id_reader and DATE_VIDACH between »’ + DateToStr(DateTimePicker1.Date) +
»’ and »’ + DateToStr(DateTimePicker2.Date) + »»;
IBQuery1.Open;
end;
end.
9. Форма «Отчеты: Должнки»
unit Unit9;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls, ComCtrls;
type
TForm9 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBQuery2: TIBQuery;
IBQuery1DATE_VIDACH: TDateField;
IBQuery1ID_EKZEMP: TIntegerField;
IBQuery1PRIM: TIBStringField;
IBQuery1SROK_VIDACH: TIntegerField;
IBQuery1DATE_VOZVR: TDateField;
IBQuery1ID_PERSONAL: TIntegerField;
IBQuery1reader: TStringField;
IBQuery1ID_READER: TIntegerField;
IBQuery5: TIBQuery;
IBQuery1personal: TStringField;
IBQuery3: TIBQuery;
IBQuery1book: TStringField;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form9: TForm9;
implementation
uses unit1;
{$R *.dfm}
procedure TForm9.Button1Click(Sender: TObject);
begin
IBQuery1.Close;
IBQuery1.ParamByName(‘s’).AsDateTime:=DateTimePicker1.DateTime;
IBQuery1.ParamByName(‘s1’).AsDateTime:=DateTimePicker2.DateTime;
IBQuery1.Open;
end;
end.
10. Форма «Отчеты: Поступившие книги»
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBQuery, Grids, DBGrids, StdCtrls, ComCtrls,
Buttons;
type
TForm10 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBQuery1ID_BOOK: TIntegerField;
IBQuery1NAME: TIBStringField;
IBQuery1INDEX_KATAL: TIBStringField;
IBQuery1PAGES_1: TIntegerField;
IBQuery1PRACE: TFloatField;
IBQuery1DATE_POSTUPL: TDateField;
IBQuery1YEAR_IZD: TIBStringField;
IBQuery1ID_IZDAT: TIntegerField;
IBQuery2: TIBQuery;
IBQuery1izdat: TStringField;
Label2: TLabel;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
uses unit1;
{$R *.dfm}
procedure TForm10.Button1Click(Sender: TObject);
begin
IBQuery1.Close;
IBQuery1.ParamByName(‘s’).AsDateTime:=DateTimePicker1.DateTime;
IBQuery1.ParamByName(‘s1’).AsDateTime:=DateTimePicker2.DateTime;
IBQuery1.Open;
end;
end.
11. Форма «Отчеты: Зарегистрированные читатели»
unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, DB, IBCustomDataSet, IBQuery, Grids, DBGrids;
type
TForm11 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
IBQuery1ID_READER: TIntegerField;
IBQuery1FIO: TIBStringField;
IBQuery1DATE_BIRTH: TDateField;
IBQuery1NUMB_KARD: TIntegerField;
IBQuery1PLACE_WORK: TIBStringField;
IBQuery1ADRES: TIBStringField;
IBQuery1NUMB_TELEF: TIntegerField;
IBQuery1DATA_VID: TDateField;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form11: TForm11;
implementation
uses unit1;
{$R *.dfm}
procedure TForm11.Button1Click(Sender: TObject);
begin
IBQuery1.Close;
IBQuery1.ParamByName(‘s’).AsDateTime:=DateTimePicker1.DateTime;
IBQuery1.ParamByName(‘s1’).AsDateTime:=DateTimePicker2.DateTime;
IBQuery1.Open;
end;
end.
12. Форма «Справочники: Форма произведения»
unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBUpdateSQL, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls;
type
TForm12 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_TYPE: TIntegerField;
IBQuery1NAME: TIBStringField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery2: TIBQuery;
IBQuery2NAZVANIE: TIBStringField;
Label1: TLabel;
DBGrid3: TDBGrid;
DataSource3: TDataSource;
IBQuery3: TIBQuery;
Label2: TLabel;
IBQuery3NAME: TIBStringField;
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
implementation
uses unit1;
{$R *.dfm}
procedure TForm12.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘tipe’).AsInteger:=IBQuery1ID_TYPE.AsInteger;
IBQuery2.Open;
IBQuery3.Close;
IBQuery3.ParamByName(‘tipe’).AsInteger:=IBQuery1ID_TYPE.AsInteger;
IBQuery3.Open;
end;
end.
13. Форма «Справочники: Сотрудники»
unit Unit13;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls;
type
TForm13 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_PERSONAL: TIntegerField;
IBQuery1FIO: TIBStringField;
IBQuery1DOLGNOST: TIBStringField;
IBQuery1DATE_BIRTH: TDateField;
DBGrid2: TDBGrid;
DataSource2: TDataSource;
IBQuery2: TIBQuery;
Label1: TLabel;
IBQuery2DATE_VIDACH: TDateField;
IBQuery2ID_EKZEMP: TIntegerField;
IBQuery2PRIM: TIBStringField;
IBQuery2SROK_VIDACH: TIntegerField;
IBQuery2DATE_VOZVR: TDateField;
IBQuery2ID_PERSONAL: TIntegerField;
IBQuery2ID_EKZEMP1: TIntegerField;
IBQuery2ID_BOOK: TIntegerField;
IBQuery2ID_BOOK1: TIntegerField;
IBQuery2NAME: TIBStringField;
IBQuery2INDEX_KATAL: TIBStringField;
IBQuery2PAGES_1: TIntegerField;
IBQuery2PRACE: TFloatField;
IBQuery2DATE_POSTUPL: TDateField;
IBQuery2YEAR_IZD: TIBStringField;
IBQuery2ID_IZDAT: TIntegerField;
IBQuery3: TIBQuery;
IBQuery2reader: TStringField;
IBQuery2ID_READER: TIntegerField;
IBQuery3ID_READER: TIntegerField;
IBQuery3FIO: TIBStringField;
IBQuery3DATE_BIRTH: TDateField;
IBQuery3NUMB_KARD: TIntegerField;
IBQuery3PLACE_WORK: TIBStringField;
IBQuery3ADRES: TIBStringField;
IBQuery3NUMB_TELEF: TIntegerField;
IBQuery3DATA_VID: TDateField;
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm13.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘personal’).AsInteger:=IBQuery1ID_PERSONAL.AsInteger;
IBQuery2.Open;
end;
end.
14. Форма «Справочники: Жанр»
unit Unit14;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls;
type
TForm14 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_GANR: TIntegerField;
IBQuery1NAME: TIBStringField;
DataSource2: TDataSource;
DBGrid2: TDBGrid;
IBQuery2: TIBQuery;
Label1: TLabel;
IBQuery2ID_PROIZV: TIntegerField;
IBQuery2NAZVANIE: TIBStringField;
IBQuery2ID_TYPE: TIntegerField;
IBQuery2ID_GANR: TIntegerField;
DBGrid3: TDBGrid;
DataSource3: TDataSource;
IBQuery3: TIBQuery;
IBQuery3NAME: TIBStringField;
Label2: TLabel;
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form14: TForm14;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm14.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery2.Close;
IBQuery2.ParamByName(‘ganr’).AsInteger:=IBQuery1ID_GANR.AsInteger;
IBQuery2.Open;
IBQuery3.Close;
IBQuery3.ParamByName(‘ganr’).AsInteger:=IBQuery1ID_GANR.AsInteger;
IBQuery3.Open;
end;
end.
15. Форма «Справочники: Книга-экземпляр»
unit Unit15;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBQuery, IBUpdateSQL, ExtCtrls, DBCtrls,
Grids, DBGrids;
type
TForm15 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1: TIBQuery;
IBQuery2: TIBQuery;
IBQuery1ID_EKZEMP: TIntegerField;
IBQuery1ID_BOOK: TIntegerField;
IBQuery1book: TStringField;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form15: TForm15;
implementation
uses Unit1;
{$R *.dfm}
end.
16. Форма «Справочники: Произведения»
unit Unit16;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids, StdCtrls;
type
TForm16 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_PROIZV: TIntegerField;
IBQuery1NAZVANIE: TIBStringField;
IBQuery1ID_TYPE: TIntegerField;
IBQuery1ID_GANR: TIntegerField;
IBQuery2: TIBQuery;
IBQuery1Ganr: TStringField;
IBQuery3: TIBQuery;
IBQuery1tipe: TStringField;
DataSource2: TDataSource;
DBGrid2: TDBGrid;
IBQuery4: TIBQuery;
Label1: TLabel;
IBQuery4ID_BOOK: TIntegerField;
IBQuery4ID_PROIZV: TIntegerField;
IBQuery4ID_BOOK1: TIntegerField;
IBQuery4NAME: TIBStringField;
IBQuery4INDEX_KATAL: TIBStringField;
IBQuery4PAGES_1: TIntegerField;
IBQuery4PRACE: TFloatField;
IBQuery4DATE_POSTUPL: TDateField;
IBQuery4YEAR_IZD: TIBStringField;
IBQuery4ID_IZDAT: TIntegerField;
DBGrid3: TDBGrid;
DataSource3: TDataSource;
IBQuery5: TIBQuery;
IBQuery5ID_AUTHOR: TIntegerField;
IBQuery5FIO: TIBStringField;
IBQuery5DATE_BIRTH: TDateField;
IBQuery5DATE_MORE: TIBStringField;
IBQuery5COUNTRY: TIBStringField;
IBQuery5ID_PROIZV: TIntegerField;
IBQuery5ID_AUTHOR1: TIntegerField;
Label2: TLabel;
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form16: TForm16;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm16.DataSource1DataChange(Sender: TObject; Field: TField);
begin
IBQuery4.Close;
IBQuery4.ParamByName(‘proizv’).AsInteger:=IBQuery1ID_PROIZV.AsInteger;
IBQuery4.Open;
IBQuery5.Close;
IBQuery5.ParamByName(‘proizv’).AsInteger:=IBQuery1ID_PROIZV.AsInteger;
IBQuery5.Open;
end;
end.
17. Форма «Справочники: Расположение книги»
unit Unit17;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids;
type
TForm17 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery1ID_PLACE: TIntegerField;
IBQuery1ID_EKZEMP: TIntegerField;
IBQuery1NUMB_POLK: TIntegerField;
IBQuery1NUMB_STELAG: TIntegerField;
IBQuery2: TIBQuery;
IBQuery2ID_BOOK: TIntegerField;
IBQuery2NAME: TIBStringField;
IBQuery2ID_EKZEMP: TIntegerField;
IBQuery2ID_BOOK1: TIntegerField;
IBQuery2INDEX_KATAL: TIBStringField;
IBQuery2PAGES_1: TIntegerField;
IBQuery2PRACE: TFloatField;
IBQuery2DATE_POSTUPL: TDateField;
IBQuery2YEAR_IZD: TIBStringField;
IBQuery2ID_IZDAT: TIntegerField;
IBQuery1book: TStringField;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form17: TForm17;
implementation
uses Unit1;
{$R *.dfm}
end.
18. Форма «Справочники: Автор-Произведение»
unit Unit18;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IBCustomDataSet, IBUpdateSQL, DB, IBQuery, ExtCtrls, DBCtrls,
Grids, DBGrids;
type
TForm18 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery1: TIBQuery;
IBUpdateSQL1: TIBUpdateSQL;
IBQuery2: TIBQuery;
IBQuery3: TIBQuery;
IBQuery1ID_PROIZV: TIntegerField;
IBQuery1ID_AUTHOR: TIntegerField;
IBQuery1proizved: TStringField;
IBQuery1avtor: TStringField;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form18: TForm18;
implementation
uses Unit1;
{$R *.dfm}
end.
19. Форма «Справочники: Произведение-книга»
unit Unit19;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ExtCtrls, DBCtrls, Grids, DBGrids, IBCustomDataSet, IBQuery,
IBUpdateSQL;
type
TForm19 = class(TForm)
IBQuery1: TIBQuery;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
IBQuery2: TIBQuery;
IBQuery3: TIBQuery;
IBQuery1ID_BOOK: TIntegerField;
IBQuery1ID_PROIZV: TIntegerField;
IBQuery1book: TStringField;
IBQuery1proizved: TStringField;
IBUpdateSQL1: TIBUpdateSQL;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form19: TForm19;
implementation
uses Unit1;
{$R *.dfm}
end.
Список литературы
1. Фаронов В. «Программирование баз данных в Delphi 7», — СПб, Питер, 2004 г.
2. Ульман Дж. Д., Уидом Дж. «Введение в системы баз данных», — М: Лори, 2000 г.
3. Гофман В, Хомоненко А «Delphi 6: Наиболее полное руководство», — СПб, «БХВ-Петербург», 2002 г.
4. Электронные лекции