(. 6.14).
6.14
(. 6.15).
6.15
, (. 6.16).
6.16
.
. :
OnCreate TConnection, , .
OnClose .
:
, ;
Events
, .
OnCreate :
var
// ini
ini: tinifile;
//
servername, path: string;
begin
try
// ini
ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'config.ini');
// , ,
//
if ini.ReadString('options','servername','')='' then
begin
servername:='localhost';
//
if InputQuery(' ','',servername) then
begin
// ini -
ini.WriteString('options','servername',servername);
end;
end;
//
servername:=ini.ReadString('options','servername','');
// , .
if ini.ReadString('options','path','')='' then
begin
//
if InputQuery(' ','',path) then
begin
// ini -
ini.WriteString('options','path',path);
end;
end;
// ini -
path:=ini.ReadString('options','path','');
try
//
fConnection:=TConnection.Create;
//
fConnection.ServerName:=servername;
fConnection.DataBaseName:=path;
fConnection.UserName:='SYSDBA';
fConnection.Password:='masterkey';
//
fConnection.Connect;
except
//
|
|
ShowMessage(' ');
//
freeandnil(fConnection);
//
fmMain.Close;
//
Application.Terminate;
//
Exit;
end;
finally
// ini -
FreeAndNil(ini);
end;
//
fStudents:=TStudents.Create(fConnection,fConnection.TransactionObject);
// , //
dbgStudents.DataSource:=fStudents.DataSource;
//
fStudents.Select;
//
fBooks:=TBook.Create(fConnection,fConnection.TransactionObject);
// ,
dbgBooks.DataSource:=fBooks.DataSource;
//
fBooks.Select;
//
fStudentBook:=TStudentBook.Create(fConnection, fConnection.TransactionObject);
//
fStudents.OnAfterScroll:=StudentsAfterScroll;
//
fStudents.LoadCurrent;
//
fStudentBook.fk_student:=fStudents.id;
//
fStudentBook.Select;
// , //
dbgStudentsBook.DataSource:=fStudentBook.DataSource;
end;
TActionManager OnExecute, -. :
Try
//
fStudents.LoadCurrent;
//
fmChangeStudent:=TfmChangeStudent.Create(Application);
with fmChangeStudent do
begin
//
seNum.Value:=fStudents.Num;
edFamily.Text:=fStudents.Family;
edName.Text:=fStudents.Name;
edSecondName.Text:=fStudents.SecondName;
// TComboBox
cbGroup.Items.AddStrings(fStudents.GroupList);
// TComboBox
cbGroup.ItemIndex:=cbGroup.Items.IndexOf(fStudents.Group);
end;
//
if fmChangeStudent.ShowModal=mrOk then
begin
//
with fStudents do
begin
Num:=fmChangeStudent.seNum.Value;
Family:=fmChangeStudent.edFamily.Text;
Name:=fmChangeStudent.edName.Text;
SecondName:=fmChangeStudent.edSecondName.Text;
Group:=fmChangeStudent.cbGroup.Text;
//
Update;
end;
end;
finally
//
FreeAndNil(fmChangeStudent);
end;
File → Save All. , .
(Students, Users, Library), fm (fmUser, fmBook, fmGroup), Class (ClassUser, ClassBook, ClassGroup).
|
|
Borland Developer Studio . , FireBird, - .
1) ?
2) Borland Developer Studio 2006.
3) Developer Studio.
4) .
5) -, .
6) .
7) UML. .
8) TDBGrid.
9) TComboBox.