Node1:=TreeView1.Items.AddChild(Node0,frmFunc_Proc.SimpleTrim(tbUprav.FieldByName('NameUprav').AsString));
//Node4:=TreeView1.Items.AddChild(Node0,frmFunc_Proc.SimpleTrim(tbUprav.FieldByName('NameUprav').AsString));
tbOtdel.Close;
tbOtdel.SQL.Clear;
tbOtdel.SQL.Add('Select * from dbo.tbOtdel where (flag<>3) and UpravID = '+IntToStr(IDFld)+' order by sort');
tbOtdel.Open;
tbOtdel.First;
du := 0;
if tbOtdel.RecordCount > 0 then
begin
while not tbOtdel.Eof do
begin
Node2 := TreeView1.Items.AddChild(Node1,frmFunc_Proc.SimpleTrim(
tbOtdel.FieldByName('NameOtdel').AsString));
tbDolzhnosts.Close;
tbDolzhnosts.SQL.Clear;
tbDolzhnosts.SQL.Add('select * from dbo.tbDolzhnosts where (flag<>3) and (UpravID = '+IntToStr(IDFld)+')');
tbDolzhnosts.SQL.Add('and (OtdelID in ('+IntToStr(tbOtdel.FieldValues['ID'])+',0)) order by ID desc '); //ID sort
tbDolzhnosts.Open;
tbDolzhnosts.First;
iftbDolzhnosts.RecordCount> 0 then
begin
while not tbDolzhnosts.Eof do
begin
s := frmFunc_Proc.NameByID(ADOQ_temp,'dbo.tbDolzhnost',tbDolzhnosts.FieldValues['DolzhnostID']);
kol_ed := tbDolzhnosts.FieldValues['KolShtatEd'];
s := s + ' (Штатных ед.: '+IntToStr(kol_ed)+')';
if str <> s then //исключение дубликатов
if (tbDolzhnosts['otdelid'] = 0) and (du<frmFunc_Proc.SHRPaint(tbDolzhnosts['upravid'])) then
begin//esli odein raz to hvatit
if du = 0 then
Node:=TreeView1.Items.AddChildFirst(Node1,frmFunc_Proc.SimpleTrim(s))
else
Node := TreeView1.Items.AddChildFirst(Node1,frmFunc_Proc.SimpleTrim(s));
inc(du,1);
end;
if (tbDolzhnosts['otdelid'] <> 0) then
Node := TreeView1.Items.AddChildFirst(Node2,frmFunc_Proc.SimpleTrim(s));
str := s; //***исключение дубликатов
tbDolzhnosts.Next;
end;
end
else
begin
tbDolzhnosts.Close;
tbDolzhnosts.SQL.Clear;
tbDolzhnosts.SQL.Add('select * from dbo.tbDolzhnosts where (flag<>3) and (UpravID = '
+IntToStr(IDFld)+') order by ID');
tbDolzhnosts.Open; tbDolzhnosts.First;
if tbDolzhnosts.RecordCount > 0 then
begin
while not tbDolzhnosts.Eof do
begin
s := '*'+frmFunc_Proc.NameByID(ADOQ_temp,'dbo.tbDolzhnost',tbDolzhnosts.FieldValues['DolzhnostID']);
if str <> s then //исключение дубликатов
Node := TreeView1.Items.AddChild(Node1,frmFunc_Proc.SimpleTrim(s));
str := s;
tbDolzhnosts.Next;
end;
end;
end;
tbOtdel.Next;
end;
end
else
begin
tbDolzhnosts.Close;
tbDolzhnosts.SQL.Clear;
tbDolzhnosts.SQL.Add('select * from dbo.tbDolzhnosts where (flag<>3) and (UpravID = '
+IntToStr(IDFld)+') order by ID');
tbDolzhnosts.Open;
tbDolzhnosts.First;
if tbDolzhnosts.RecordCount > 0 then
begin
while not tbDolzhnosts.Eof do
begin
s := frmFunc_Proc.NameByID(ADOQ_temp,'dbo.tbDolzhnost',tbDolzhnosts.FieldValues['DolzhnostID']);
kol_ed := tbDolzhnosts.FieldValues['KolShtatEd'];
s := s + ' (Штатных ед.: '+IntToStr(kol_ed)+')';
if str <> s then //исключение дубликатов
Node := TreeView1.Items.AddChild(Node1,frmFunc_Proc.SimpleTrim(s));
str := s;
tbDolzhnosts.Next;
end;
end;
end;
tbUprav.Next;
end;
//раскрытие только одного узла (0)
//TreeView1.TopItem := TreeView1.Items.Item[1];
//TreeView1.Items.Item[0].Expand(True);//раскрытие всех узлов
end;
TreeView1.Items.EndUpdate; //конец изменений
end;
procedure TfrmMain.DBGridEh1DblClick(Sender: TObject);
var
FF_work : string;
begin
FF_work:='flag<>3 and';
if DM.tbSotrudnik.RecordCount > 0 then
begin
SotrID := DM.tbSotrudnik['ID'];//ID текущего сотрудника
frmSotrudnik := TfrmSotrudnik.Create(nil);
try
with DM do
begin
tbSotrudnikObr.Close;
tbSotrudnikObr.SQL.Clear;
tbSotrudnikObr.SQL.Add('Select * from tbSotrudnikObr where '+FF_work);
tbSotrudnikObr.SQL.Add('SotrID = '+IntToStr(dm.tbSotrudnik['id'])+' order by ID');
tbSotrudnikObr.Open;
tbSotrudnikRodstv.Close;
tbSotrudnikRodstv.SQL.Clear;
tbSotrudnikRodstv.SQL.Add('Select * from tbSotrudnikRodstv where '+FF_work);
tbSotrudnikRodstv.SQL.Add('SotrID = '+IntToStr(dm.tbSotrudnik['id'])+' order by ID');
tbSotrudnikRodstv.Open;
tbSotrudnikPredRab.Close;
tbSotrudnikPredRab.SQL.Clear;
tbSotrudnikPredRab.SQL.Add('Select * from tbSotrudnikPredRab where '+FF_work);
tbSotrudnikPredRab.SQL.Add('SotrID = '+IntToStr(dm.tbSotrudnik['id'])+' order by DateBegin');
tbSotrudnikPredRab.Open;
end;
frmSotrudnik.Caption := 'Карточка сотрудника: '+DM.tbSotrudnik['FIO_Long'];
frmSotrudnik.ShowModal;
GroupBox5.Visible := false;
finally
FreeAndNil(frmSotrudnik);
end;
end;
end;