Delphi (File\New\Application). ElJur, Main. . 3 : Adocommand, AdoConnection AdoDataSet ( ADO). , . Data Module (File\New\Data Module), datm dm. . Data Module, (AdoConnection), Conn. Object Inspector, 5.
5 Ļ
ConnectionString , 6.
6
Build 7.
7 Ļ
ʻ , 8 .
8 Ļ
, 9.
9 Ļ
. . 10 ConnectionString.
10
Source D:\Access+Delphi\\BD_ElJur.mdb;. BD_ElJur.mdb;. ʻ.
Connected ( Object Inspector) TRUE. , .
, , . Form1 FMain. Data Module FMain. implementation uses Datm; ( , ). . , , Object Inspector Events OnShow . , : dm.Conn.Connected:=true;. ( , , password, name host, , ).
|
|
, , .
MainMenu Standart. Data Module MM. , . Data Module MainMenu. , 11.
11
FMain Object Inspector Menu DM.MM 12.
12
, , .
, . . Prep FPrep. DM : ADODataSet ADO, DataSource Data Access ImageList Win32 Pr, SPr IL . Pr Object Inspector Connection Conn 13. , .
13
Spr Object Inspector DataSet Pr 14. .
14
FPrep , , , . , . . 3 : ToolBar Win32 Panel Standart. Align Bottom Client. p2. ToolBar 3 New button, , New Separator. , 15 ( ). : DBGrid Data Control, Edit Standart BitBtn Additional ( , ). Panel1 p2. DBGrid Panel1 Align Client. Edit1 e1 ( Text) p2 BitBtn. , 16 ( ).
|
|
15 1
16 2
, ( : uses datm,main;).
DbGrid1 DataSourse spr.
Fmain , :
dm.pr.Active:=false;
dm.pr.CommandText:='Select * FROM Prep';
dm.pr.Active:=true;
Fprep.ShowModal;
Fprep . . DM Conn Connected True. Select * FROM Prep, Active True. , Fprep , . DBGRID1. 17. , 17. 0 - TColumn Object Inspector 18. 1 - TColumn 19.
17
18 DBFrid 1
19 DBFrid 2
, . . P2 , Visible False. , , .
Toolbar ( ):
e1.Text:=''; //
p2.Visible:=true; // "P2"
Caption BitBtn (). , . Kind bkOK bkCancel Modal Result mrNone. FMain Ed, integer. :
Var
FMain: TFMain;
ed:integer;
ToolBar. Ed:=1; DM Adodataset TEMP4 Conn. ToolBar ( ):
e1.Text:=dm.pr.Fields[1].AsString; //
p2.Visible:=true; // "P2"
Ed:=2;//
. :
e1.Text:='';
p2.visible:=false;
:
{1}if e1.Text='' then showmessage (' ')
{2}else
{3} begin
{4} if ed=1 then
{5} begin
{6} dm.TEMP4.Active:=false;
{7} dm.TEMP4.CommandText:='Select * FROM Prep WHERE (fio_pr = "'+TRIM(e1.Text)+'")';
{8} dm.TEMP4.Active:=true;
{9} if dm.TEMP4.Fields[0].AsString<>'' then
{10} begin
{11} showmessage(' ');
{12} exit;
{13} end
{14} else
{15} begin
{17} dm.COM.CommandText:='INSERT INTO Prep (fio_pr) values ("'+TRIM(e1.Text)+'")';
{18} dm.COM.Execute;
{19} showmessage(' ');
{20} e1.Text:='';
{21} dm.pr.active:=false;
|
|
{22} dm.pr.Active:=true;
{23} BitBtn2Click(Sender);
{24} end;
{25} end
{26} else
{27} begin
{28} dm.TEMP4.Active:=false;
{29} dm.TEMP4.CommandText:='Select * FROM Prep WHERE (fio_pr = "'+TRIM(e1.Text)+'")';
{30} dm.TEMP4.Active:=true;
{31} if dm.TEMP4.Fields[0].AsString<>'' then
{32} begin
{33} if dm.TEMP4.Fields[0].AsString <>dm.pr.Fields[0].AsString then
{34} begin
{35} showmessage(' ');
{36} exit;
{37} end;
{38} end
{39} else
{40} begin
{42} dm.com.CommandText:='Update Prep SET fio_pr = "'+TRIM(e1.Text)+'" WHERE id_pr = '+dm.pr.Fields[0].AsString+'';
{43} dm.com.Execute;
{44} showmessage(' ');
{45} e1.Text:='';
{46} dm.pr.active:=false;
{47} dm.pr.Active:=true;
{48} BitBtn2Click(Sender);
{49} end;
{50} end;
{51} end;
. , ed. 1, 2, .
.
{1}. , . , , :
if (e1.text='') OR (e2.text='') OR then showmessage(' ')
{4} , ( )
{6} - {13} .
{6} , .. .
{7} , Prep fio_pr ...
{8} , .
{9} , .
{10} - {13} , .
{14} - {15} , .
{17} , Prep fio_pr : .... TRIM ... .
{18} SQL-.
{19} , .
{20} .
{21} - {22} , , .
{23}
{27} ( ed 2).
{28} - {38} , .
{39} -{40} ,
{41} .
{42} , Prep, fio_pr ..., .
{43} .
{44} - {48} {19} - {23}.
. . .
If dm.pr.Fields[0].AsString='' then
Begin
showmessage(' ');
exit;
end;
, .
3- ToolBar. .
If application.MessageBox(' ?','', mb_yesno+mb_iconquestion)=idyes then
|
|
Begin
dm.TEMP4.CommandText:='DELETE Prep FROM Prep WHERE id_pr = "'+dm.pr.Fields[0].AsString+'"';
dm.TEMP4.Execute;
showmessage(' ');
dm.pr.Active:=false;
dm.pr.Active:=true;
end;
, , . . ToolBar Images Dm.il. DM ImageList . ToolBar. Image , . , 20. , Caption .
20
, , . , . , .
, 21 , 22 , 23 24 .
21
22
23
24
, . . , ( .). 3 : , .
, .. . . , . :
Select id_st,fio_st,nazv_n,nazv_ug,nazv_zv FROM kadri,nac,uchgr,zvanie WHERE (id_n = id_nc_st) AND (id_ug = id_ug_st) AND (id_zv = id_zv_st).
kadri , .. , .. FROM , , WHERE , kadri , .
, . , 1, , . (Combobox Standart, cb1).
{1}dm.TEMP4.Active:=false;
{2}dm.TEMP4.CommandText:='select * FROM nac ORDER by id_n';
{3}dm.TEMP4.Active:=true;
While not dm.TEMP.Eof do
Begin
{6} fkadr.cb1.Items.Add(dm.TEMP4.Fields[1].AsString);
{7} dm.TEMP.Next;
{8} end;
{1} ( ).
{2} . , Order BY. .
{3} , .
{4} . .
{6} .
{7} .
, . .. . : cb1.clear;. . OnKeyPress : key:=#0;
:
ed 3 id_n, id_ug, id_zv string. 25.
|
|
25
Combobox Events OnClick :
dm.TEMP4.Active:=false;
dm.TEMP4.CommandText:='Select id_n FROM nac WHERE nazv_n = "'+cb1.Text+'"';
dm.TEMP4.Active:=true;
id_n:=dm.temp.fields[0].asstring;
, - , , , . : cb1Click(Sender);. -. id_n, id_ug, id_zv. . : id_n:=''; .
:
{+Proverka}
If dm.st.Fields[0].AsString='' then
Begin
showmessage(' ');
exit;
end;
{-Proverka}
ed:=2;
p1.Visible:=true;
e1.Text:=TRIM(dm.st.Fields[1].AsString);
cb1.Text:=TRIM(dm.st.Fields[2].AsString);
cb2.Text:=TRIM(dm.st.Fields[4].AsString);
cb3.Text:=TRIM(dm.st.Fields[3].AsString);
cb1Click(Sender);cb2Click(Sender);cb3Click(Sender);
:
{1}if (e1.Text='') OR (id_n='') OR (id_ug='') OR (id_zv='') then showmessage (' ')
Else
Begin
{4} if ed=1 then
Begin
{6} dm.TEMP4.Active:=false;
{7} dm.TEMP4.CommandText:='Select * FROM kadri WHERE (fio_st = "'+TRIM(e1.Text)+'") AND (id_nc_st = '+id_n+') AND (id_ug_st = '+id_ug+') AND (id_zv_st = '+id_zv+')';
{8} dm.TEMP4.Active:=true;