Код:
var
Form6: TForm6;
implementation
uses pds5, pds1, ADOInt;
{$R *.dfm}
procedure tform6.getpdat;
var i:integer;
begin
peop.Cells[0,0]:='Ôàìèëèÿ';
peop.Cells[1,0]:='Èìÿ';
peop.Cells[2,0]:='Îò÷åñòâî';
peop.Cells[3,0]:='Ñòàòóñ';
peop.Cells[4,0]:='Äîñòàâëåí';
peop.Cells[5,0]:='Îáñòîÿòåëüñòâà';
peop.Cells[6,0]:='Ñèëà';
cres.Filtered:=false;
if res.cells[0,res.row]='' then
begin
peop.RowCount:=2;
peop.Rows[1].Clear;
exit
end;
cres.Filter:='rregnum='+quotedstr(res.Cells[0,res.Row]);
cres.Filtered:=true;
//cres.first;
pm.Active:=false;
pm.filtered:=false;
pm.CommandText:='select peoples.pid, peoples.pfname, peoples.pnname, peoples.poname, stat.sname from peoples, who_why, stat where who_why.wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and peoples.pid=who_why.wwpid and who_why.wwsid=stat.sid';
pm.Active:=true;
if pm.RecordCount=0 then peop.RowCount:=pm.RecordCount+2
else peop.RowCount:=pm.RecordCount+1;
pp.Active:=false;
pp.CommandText:='select who_when.wwpid, reasons.rtype, influence.itype from who_when, influence, reasons where who_when.wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and who_when.wwiid=influence.iid and who_when.wwwhy=reasons.rid';
pp.Active:=true;
for i:=1 to pm.RecordCount do
begin
peop.Cells[0,i]:=pm.Recordset.Fields[1].get_value();
peop.Cells[1,i]:=pm.Recordset.Fields[2].get_value();
peop.Cells[2,i]:=pm.Recordset.Fields[3].get_value();
peop.Cells[3,i]:=pm.Recordset.Fields[4].get_value();
pp.Filtered:=false;
pp.Filter:='wwpid='+quotedstr(pm.Recordset.Fields[0].get_value());
pp.Filtered:=true;
if pp.RecordCount=1 then
begin
if pp.Recordset.Fields[1].get_value()='íå âîçíèêëî' then peop.Cells[4,i]:='Äà'
else peop.Cells[4,i]:='Íåò';
peop.Cells[5,i]:=pp.Recordset.Fields[1].get_value();
peop.Cells[6,i]:=pp.Recordset.Fields[2].get_value()
end;
pp.Filtered:=false;
pm.Next
end;
end;
procedure tform6.getresdat;
var i:integer; st:string;
tdate1 : TDateTime;
begin
cres.Active:=false;
cres.Filtered:=false;
st:=datetostr(dat.date);
cres.CommandText:='select resolution.rid, resolution.rregnum, resolution.rrgid, res_givers.rgfname, res_givers.rgnoname, organs.oname, resolution.rprice from resolution, res_givers, organs where int (resolution.rtodate)=:date '+' and resolution.rrgid=res_givers.rgid and res_givers.rgorg=organs.oid';
cres.Parameters.ParamByName('date').DataType := ftDate;
tdate1 := Trunc(dat.date);
cres.Parameters.ParamByName('date').Value := tdate1;
cres.Active:=true;
if cres.RecordCount=0 then res.RowCount:=cres.RecordCount+2
else res.RowCount:=cres.RecordCount+1;
for i:=1 to res.RowCount do
res.Rows[i].Clear;
res.Cells[0,0]:='Íîìåð';
res.Cells[1,0]:='Êóäà';
res.Cells[2,0]:='Êîìó';
res.Cells[3,0]:='Ðàñõîäû';
for i:=1 to cres.RecordCount do
begin
res.Cells[0,i]:=cres.Recordset.Fields[1].get_value();
res.Cells[2,i]:=cres.Recordset.Fields[3].get_value()+' '+cres.Recordset.Fields[4].get_value();
res.Cells[1,i]:=cres.Recordset.Fields[5].get_value();
res.Cells[3,i]:=cres.Recordset.Fields[6].get_value();
cres.Next
end;
getpdat
end;
procedure TForm6.CheckBox1Click(Sender: TObject);
begin
if checkbox1.Checked then
begin
cool.Visible:=true;
why.Visible:=false;
wh.Visible:=false;
wh.Text:='Äîñòàâëåí'
end
else
begin
cool.Visible:=false;
why.Visible:=true;
wh.Visible:=true;
wh.Text:='';
end
end;
procedure TForm6.contrClick(Sender: TObject);
begin
if contr.Checked then
begin
fr.Visible:=true;
force.Visible:=true;
force.Text:=''
end
else
begin
fr.Visible:=false;
force.Visible:=false;
force.Text:='íå ïðèìåíÿëîñü'
end
end;
procedure TForm6.resSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
getpdat
end;
procedure TForm6.FormShow(Sender: TObject);
var t:systemtime; i,j:integer; str:string;
begin
ToolButton4Click(form6);
all.Active:=false;
all.CommandText:='select * from reasons';
all.Active:=true;
wh.Items.Clear;
for i:=1 to all.RecordCount do
begin
wh.Items.Add(all.Recordset.Fields[1].get_value());
all.Next
end;
force.Items.Clear;
all.Active:=false;
all.CommandText:='select * from influence';
all.Active:=true;
for i:=1 to all.RecordCount do
begin
force.Items.Add(all.Recordset.Fields[1].get_value());
all.Next
end;
getsystemtime(t);
str:=inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear);
dat.Date:=strtodate(str);
getresdat
end;
procedure TForm6.datChange(Sender: TObject);
begin
getresdat
end;
procedure TForm6.resKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i:integer;
begin
toolbutton2click(form6);
for i:=1 to peop.RowCount do
peop.Rows[i].Clear;
getpdat
end;
procedure TForm6.resClick(Sender: TObject);
var i:integer;
begin
toolbutton2click(form6);
for i:=1 to peop.RowCount do
peop.Rows[i].Clear;
getpdat
end;
procedure TForm6.ToolButton2Click(Sender: TObject);
begin
checkbox1.Checked:=false;
cool.Visible:=false;
wh.Visible:=true;
wh.Text:='';
contr.Checked:=false;
force.Visible:=false;
force.Text:='íå ïðèìåíÿëîñü';
fr.Visible:=false
end;
procedure TForm6.ToolButton1Click(Sender: TObject);
var t:systemtime; str:string;
begin
getsystemtime(t);
str:=inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear);
cres.Filtered:=false;
cres.Filter:='rregnum='+quotedstr(res.Cells[0,res.Row]);
cres.Filtered:=true;
pm.Filtered:=false;
pm.Filter:='pfname='+quotedstr(peop.Cells[0,peop.Row])+' and pnname='+quotedstr(peop.Cells[1,peop.Row])+' and poname='+quotedstr(peop.Cells[2,peop.Row]);
pm.Filtered:=true;
rea.Active:=true;
rea.Filtered:=false;
rea.Filter:='rtype='+quotedstr(wh.Text);
rea.filtered:=true;
if rea.RecordCount=0 then
begin
ins.CommandText:='insert into reasons (rtype) values('+quotedstr(wh.Text)+')';
ins.Execute;
rea.Active:=false;
rea.Active:=true
end;
inf.Active:=true;
inf.Filtered:=false;
inf.Filter:='itype='+quotedstr(force.Text);
inf.filtered:=true;
if inf.RecordCount=0 then
begin
ins.CommandText:='insert into influence (itype) values('+quotedstr(force.Text)+')';
ins.Execute;
inf.Active:=false;
inf.Active:=true
end;
all.Active:=false;
all.CommandText:='select * from who_when where wwrid='+quotedstr(cres.Recordset.Fields[0].get_value())+' and wwpid='+quotedstr(pm.Recordset.Fields[0].get_value());
all.Active:=true;
if all.RecordCount=0 then
begin
ins.CommandText:='insert into who_when (wwrid,wwpid,wwdate,wwiid,wwwhy)values('+quotedstr(cres.Recordset.Fields[0].get_value())+','+quotedstr(pm.Recordset.Fields[0].get_value())+','+quotedstr(str)+','+quotedstr(inf.Recordset.Fields[0].get_value())+','+quotedstr(rea.Recordset.Fields[0].get_value())+')';
ins.Execute;
if checkbox1.Checked then peop.Cells[4,peop.Row]:='Äà'
else peop.Cells[4,peop.Row]:='Íåò';
peop.Cells[5,peop.Row]:=wh.Text;
peop.Cells[6,peop.Row]:=force.Text;
end;
cres.Filtered:=false;
pm.Filtered:=false;
toolbutton2click(form6)
end;
procedure TForm6.peopClick(Sender: TObject);
begin
toolbutton2click(form6)
end;
procedure TForm6.peopKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
toolbutton2click(form6)
end;
procedure TForm6.ToolButton4Click(Sender: TObject);
begin
edit1.Clear
end;