Скачиваний:
9
Добавлен:
17.06.2023
Размер:
2.44 Mб
Скачать

procedure TFmain.N8Click(Sender: TObject);

 

begin

 

dm.us.Active:=false;

 

dm.us.CommandText:='select id_us,nazv_us,tar_us,nazv_mr from metR,uslugi where (id_mr=id_mr_us)';

 

dm.us.Active:=true;

 

fuslugi.Caption:=n8.Caption;

 

fuslugi.ShowModal;

 

end;

 

procedure TFmain.N10Click(Sender: TObject);

 

begin

 

foplata.dtp1.date:=date;

 

dm.op.Active:=false;

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&", . "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=false) and (month(datar_op)=month(date())) and (year(datar_op)=year(date())) '+

'group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&", . "&[dom_z]&", . "&[kv_z]),datar_op'; dm.op.Active:=true;

foplata.Caption:=n10.Caption;

foplata.ShowModal;

end;

function TFmain.data (data:tdatetime):string; var g,m,d:word;

begin decodedate(data,g,m,d);

result:=''+currtostr(m)+'/'+currtostr(d)+'/'+currtostr(g)+'';

end;

procedure TFmain.N12Click(Sender: TObject);

 

begin

 

dm.opp.Active:=false;

 

dm.opp.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&", . "&[dom_z]&",

. "&[kv_z]) as

adr,dataop_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=true) group by id_op,([fam_ok]&" "&[ima_ ok]&" "&[ot_ok]

),([adr_z]&", . "&[dom_z]&", . "&[kv_z]),dataop_op';

 

 

dm.opp.Active:=true;

 

 

foplp.Caption:=n12.Caption;

 

 

foplp.ShowModal;

 

 

end;

 

 

procedure TFmain.N11Click(Sender: TObject);

 

 

begin

 

 

dm.opn.Active:=false;

 

 

dm.opn.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=false) group by

id_op,([fam_ok]&" "&[ima_ok]&"

"&[ot_ok] ),([adr_z]&", . "&[dom_z]&", . "&[kv_z]),datar_op';

 

 

dm.opn.Active:=true;

 

 

fopln.Caption:=n11.Caption;

 

 

fopln.ShowModal;

 

 

end;

procedure TFmain.N14Click(Sender: TObject); begin

52

fot1.Caption:=n14.Caption;

fot1.dtp1.date:=date;

fot1.ShowModal;

end;

procedure TFmain.N15Click(Sender: TObject); begin

fot2.Caption:=n15.Caption;

fot2.dtp1.date:=date;

fot2.dtp2.date:=date;

fot2.ShowModal;

end;

procedure TFmain.N16Click(Sender: TObject); begin

fot3.Caption:=n16.Caption;

fot3.se1.Value:=1;

fot3.ShowModal;

end;

end. unit oplata; interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, ExtCtrls, StdCtrls, Buttons, ComCtrls,dateutils,math;

type

TFoplata = class(TForm) Panel1: TPanel; DBGrid1: TDBGrid; GroupBox1: TGroupBox; dtp1: TDateTimePicker; BitBtn1: TBitBtn; GroupBox2: TGroupBox; Label1: TLabel;

BitBtn4: TBitBtn; e1: TEdit; Label2: TLabel; e2: TEdit;

GroupBox3: TGroupBox;

GroupBox4: TGroupBox;

BitBtn2: TBitBtn;

Button1: TButton;

Button2: TButton;

Button3: TButton;

procedure BitBtn1Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject);

procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure Button3Click(Sender: TObject);

procedure dtp1Change(Sender: TObject); private

{ Private declarations } public

53

{ Public declarations } end;

var

Foplata: TFoplata; implementation

uses datm, Pozicii, main; {$R *.dfm}

procedure TFoplata.BitBtn1Click(Sender: TObject); var

pl,summa,tar:real;

kz:integer;

summ:string; begin

if dayof(dtp1.Date)<>daysinmonth(dtp1.Date) then begin

ЬСШаЦОЬЬКРО('

 

 

 

');

 

 

exit;

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

if dtp1.Date>=date then

 

 

 

 

 

begin

 

 

 

 

 

 

 

ЬСШаЦОЬЬКРО('

 

 

 

 

');

 

exit;

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

dm.temp.Active:=false;

 

 

 

 

 

dm.temp.CommandText:='Select

id_op

from

oplata

where

(month(datar_op)='+inttostr(monthof(dtp1.Date))+')and

(year(datar_op)='+inttostr(yearof(dtp1.Date))+')';

 

 

 

 

dm.temp.Active:=true;

 

 

 

 

 

if dm.temp.RecordCount>0 then

 

 

 

 

 

begin

 

 

 

 

 

 

 

if

application.MessageBox('

 

 

 

 

'+#13+'

 

?','

',mb_yesno+mb_iconquestion)=idyes then

 

 

 

begin

dm.com.CommandText:='Delete * from oplata where (month(datar_op)='+inttostr(monthof(dtp1.Date))+')and (year(datar_op)='+inttostr(yearof(dtp1.Date))+')';

dm.com.execute; end

else exit; end;

dm.temp.Active:=false;

dm.temp.CommandText:='select id_ok,kz_ok,pl_z from otvk,zil where (id_z=id_z_ok)'; dm.temp.Active:=true;

While not dm.temp.Eof do begin pl:=dm.temp.Fields[2].AsFloat;

kz:=dm.temp.Fields[1].AsInteger; id_ok:=dm.temp.Fields[0].asstring;

dm.com.CommandText:='Insert into oplata (id_ok_op,datar_op) values ('+id_ok+',"'+datetostr(dtp1.Date)+'")'; dm.com.Execute;

dm.temp2.Active:=false;

dm.temp2.CommandText:='select max(id_op) from oplata'; dm.temp2.Active:=true; id_op:=dm.temp2.fields[0].AsString;

54

dm.temp2.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.temp2.CommandText:='select id_us,tar_us,id_mr_us from uslugi';

 

 

 

 

 

 

 

dm.temp2.Active:=true;

 

 

 

 

 

 

 

 

 

 

while not dm.temp2.Eof do

 

 

 

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

 

 

id_us:=dm.temp2.Fields[0].asstring;

 

 

 

 

 

 

 

 

 

id_mr:=dm.temp2.Fields[2].asstring;

 

 

 

 

 

 

 

 

 

tar:=dm.temp2.Fields[1].AsFloat;

 

 

 

 

 

 

 

 

 

if id_mr='1' then summ:=floattostr(roundto(tar*kz,-2))

 

 

 

 

 

 

 

 

else if id_mr='2' then summ:=floattostr(roundto(pl*tar,-2))

 

 

 

 

 

 

 

 

//else if id_mr='3' then summ:=floattostr(tar)

 

 

 

 

 

 

 

 

else if id_mr='5' then summ:=floattostr(roundto(pl*tar,-2))

 

 

 

 

 

 

 

 

else summ:='0';

 

 

 

 

 

 

 

 

 

 

 

dm.com.CommandText:='Insert into pozicii (id_us_pos,id_op_pos,st_pos) values ('+id_us+','+id_op+',"'+summ+'")';

 

 

 

dm.com.Execute;

 

 

 

 

 

 

 

 

 

 

dm.temp2.Next;

 

 

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

 

 

dm.temp.Next;

 

 

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z])

as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) '+

 

 

 

 

'group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&",

. "&[dom_z]&", . "&[kv_z]),datar_op';

 

 

 

 

dm.op.Active:=true;

 

 

 

 

 

 

 

 

 

 

showmessage('

,'+#13+'

: '+datetostr(dtp1.Date) );

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.BitBtn4Click(Sender: TObject);

 

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

 

 

//foplata.dtp1.date:=date;

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z])

as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) and

(([adr_z]&",

 

.

"&[dom_z]&",

. "&[kv_z])

like "%'+e2.Text+'%") and (([fam_ok]&"

"&[ima_ok]&" "&[ot_ok]

) like

"%'+e1.Text+'%") group

 

by

id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]),datar_op';

 

 

 

 

 

dm.op.Active:=true;

 

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.Button1Click(Sender: TObject);

 

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z])

as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) and

(([adr_z]&",

 

.

"&[dom_z]&",

. "&[kv_z])

like "%'+e2.Text+'%") and (([fam_ok]&"

"&[ima_ok]&" "&[ot_ok]

) like

"%'+e1.Text+'%") group

 

by

id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]),datar_op ORDER BY datar_op';

 

 

 

55

dm.op.Active:=true;

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.Button2Click(Sender: TObject);

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) and

(([adr_z]&",

.

"&[dom_z]&",

. "&[kv_z])

like "%'+e2.Text+'%") and (([fam_ok]&"

"&[ima_ok]&" "&[ot_ok]

) like

"%'+e1.Text+'%") group

by

id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&", . "&[dom_z]&",

. "&[kv_z]),datar_op ORDER BY

sum(st_pos)';

 

dm.op.Active:=true;

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.BitBtn2Click(Sender: TObject);

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

if dm.op.Fields[0].AsString='' then exit; tmp:=dm.op.Fields[0].AsString; dm.pos.Active:=false;

dm.pos.CommandText:='Select id_pos,nazv_us,nazv_mr,st_pos from pozicii,uslugi,metr where (id_mr=id_mr_us) and (id_us=id_us_pos) and (id_op_pos='+tmp+')';

dm.pos.Active:=true;

 

 

 

 

 

 

 

 

 

fpozicii.Caption:=bitbtn2.Caption;

 

 

 

 

 

 

 

 

 

fpozicii.ShowModal;

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

e1.Clear;e2.Clear;

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.Button3Click(Sender: TObject);

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) '+

 

 

 

'group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]),datar_op';

 

 

 

dm.op.Active:=true;

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

procedure TFoplata.dtp1Change(Sender: TObject);

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

dm.op.Active:=false;

 

 

 

 

 

 

 

 

 

dm.op.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

 

 

 

 

 

'where

(id_z=id_z_ok)

and

(id_ok=id_ok_op)

and

(id_op=id_op_pos)

and

(fact_op=false)

and

(month(datar_op)=month(#'+fmain.data(dtp1.Date)+'#)) and (year(datar_op)=year(#'+fmain.data(dtp1.Date)+'#)) '+

 

 

 

'group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]),datar_op';

 

 

 

dm.op.Active:=true;

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

 

end. unit OplN; interface

56

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls, WordXP, OleServer,registry;

type

TFOplN = class(TForm)

Panel1: TPanel;

GroupBox2: TGroupBox;

Label1: TLabel;

Label2: TLabel;

BitBtn4: TBitBtn;

e1: TEdit;

e2: TEdit; BitBtn2: TBitBtn;

GroupBox4: TGroupBox;

Button1: TButton;

Button2: TButton;

BitBtn1: TBitBtn;

DBGrid1: TDBGrid;

BitBtn3: TBitBtn;

WordApplication1: TWordApplication;

WordDocument1: TWordDocument;

Button3: TButton;

procedure BitBtn2Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

FOplN: TFOplN; implementation

uses datm, Pozicii, main; {$R *.dfm}

procedure TFOplN.BitBtn2Click(Sender: TObject); begin

if dm.opn.Fields[0].AsString='' then exit; tmp:=dm.opn.Fields[0].AsString; dm.pos.Active:=false;

dm.pos.CommandText:='Select id_pos,nazv_us,nazv_mr,st_pos from pozicii,uslugi,metr where (id_mr=id_mr_us) and (id_us=id_us_pos) and (id_op_pos='+tmp+')';

dm.pos.Active:=true;

fpozicii.Caption:=bitbtn2.Caption;

fpozicii.ShowModal;

end;

procedure TFOplN.BitBtn1Click(Sender: TObject); begin

if dm.opn.Fields[0].AsString='' then exit;

57

tmp:=dm.opn.Fields[0].AsString;

 

 

 

if application.MessageBox('

?','

',mb_yesno+mb_iconquestion)=idyes then

 

begin

 

 

 

dm.com.CommandText:='Update oplata set fact_op=TRUE,dataop_op=date() where (id_op='+tmp+')';

 

dm.com.Execute;

 

 

 

dm.opn.Requery();

 

 

 

end;

 

 

 

end;

 

 

 

procedure TFOplN.BitBtn4Click(Sender: TObject);

 

 

 

begin

 

 

 

dm.opn.Active:=false;

 

 

 

dm.opn.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&"

"&[ot_ok] ) as fio_ok,([adr_z]&", . "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=false) and (adr_z like "%'+e2.Text+'%") and (([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) like "%'+e1.Text+'%") group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([adr_z]&", . "&[dom_z]&", .

"&[kv_z]),datar_op';

 

 

dm.opn.Active:=true;

 

 

end;

 

 

procedure TFOplN.Button1Click(Sender: TObject);

 

 

begin

 

 

dm.opn.Active:=false;

 

 

dm.opn.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=false) group by

id_op,([fam_ok]&" "&[ima_ok]&"

"&[ot_ok] ),([adr_z]&", . "&[dom_z]&", . "&[kv_z]),datar_op ORDER BY datar_op';

 

 

dm.opn.Active:=true;

 

 

end;

 

 

procedure TFOplN.Button2Click(Sender: TObject);

 

 

begin

 

 

dm.opn.Active:=false;

 

 

dm.opn.CommandText:='Select id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) as fio_ok,([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) as

adr,datar_op,sum(st_pos) as summa from oplata,pozicii,otvk,zil '+

 

 

'where (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op=id_op_pos) and (fact_op=false) and (([adr_z]&",

. "&[dom_z]&",

. "&[kv_z]) like

"%'+e2.Text+'%") and (([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) like "%'+e1.Text+'%") group by id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok]

),([adr_z]&", . "&[dom_z]&", . "&[kv_z]),datar_op ORDER BY sum(st_pos)'; dm.opn.Active:=true;

end;

procedure TFOplN.BitBtn3Click(Sender: TObject); var

Template,NewTemplate,FindText, NewStr, Replace,ReplaceWith:OleVariant;

LinkToFile,SaveWithDocument,Range:OleVariant;

Table1: Table; i: integer; flag:boolean; Reg: TRegistry; kz,pl:string;

begin

if dm.opn.Fields[0].AsString='' then exit;

tmp:=dm.opn.Fields[0].AsString;

 

//

,

АШЫН

Reg := TRegistry.Create;

Reg.RootKey := HKEY_CLASSES_ROOT;

58

flag:=reg.KeyExists('Word.Application');

 

 

 

 

reg.Free;

 

 

 

 

 

 

//flag:=true;

 

 

 

 

 

 

if flag=false then

 

 

 

 

 

 

begin

 

 

 

 

 

 

application.MessageBox('Word

','

',mb_ok+mb_iconstop);

 

exit;

 

 

 

 

 

 

end;

 

 

 

 

 

 

WordApplication1.Connect; //

 

 

 

 

 

//

otchet.dot

Word

 

 

 

 

Template:=ExtractFilePath(Application.EXEName)+'\Data\

\

.dot'; //

 

WordApplication1.Documents.Add(Template,EmptyParam,EmptyParam,EmptyParam);//

 

WordDocument1.ConnectTo(WordApplication1.ActiveDocument); //

WordDocument1 c

( . .

 

 

)

 

 

 

 

//

 

 

 

 

 

 

TКЛХО1:=АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(1); //

 

TКЛХО1

 

 

//WordDocument1.Tables -

 

(

TКЛХОЬ),

АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(Т) - i-

 

RОЩХКМО:=ЭЫЮО; //

,

 

 

 

 

 

FТЧНTОбЭ:='#1'; //

 

 

 

 

 

 

RОЩХКМОАТЭС:=НЦ.ШЩЧ.FТОХНЬД0Ж.AЬSЭЫТЧР; //

 

 

 

 

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

dm.temp.Active:=false;

dm.temp.CommandText:='Select pl_z,kz_ok from zil,otvk,oplata WHERE (id_z=id_z_ok) and (id_ok=id_ok_op) and (id_op='+tmp+')';

dm.temp.Active:=true;

kz:=dm.temp.Fields[1].AsString;pl:=dm.temp.fields[0].AsString;

RОЩХКМО:=ЭЫЮО; // ,

FindTОбЭ:='#2'; //

RОЩХКМОАТЭС:=НЦ.ШЩЧ.ПТОХНЛвЧКЦО('КНЫ').AЬSЭЫТЧР; //

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

RОЩХКМО:=ЭЫЮО; // ,

FТЧНTОбЭ:='#3'; //

RОЩХКМОАТЭС:=ЩХ; //

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

RОЩХКМО:=ЭЫЮО; //

,

 

 

FТЧНTОбЭ:='#4'; //

 

 

 

RОЩХКМОАТЭС:=Фг; //

 

 

 

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

RОЩХКМО:=ЭЫЮО; //

,

 

 

FТЧНTОбЭ:='#5'; //

 

 

 

ReplaceWith:=dm.opn.fieldbyname('fio_ok').AsString;

//

 

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

RОЩХКМО:=ЭЫЮО; // , FТЧНTОбЭ:='#7'; //

RОЩХКМОАТЭС:=НЦ.ШЩЧ.ПТОХНЛвЧКЦО('НКЭКЫИШЩ').AЬSЭЫТЧР; //

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

59

dm.temp.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.temp.CommandText:='Select id_ok_op from oplata where (id_op='+tmp+')';

 

 

 

 

 

 

dm.temp.Active:=true;

 

 

 

 

 

 

 

 

 

 

id_ok:=dm.temp.fields[0].asstring;

 

 

 

 

 

 

 

 

 

 

dm.temp.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.temp.CommandText:='Select

nazv_us,tar_us,nazv_mr,st_pos,id_us

from

pozicii,uslugi,metr

where

(id_mr=id_mr_us)

and

(id_us=id_us_pos) and (id_op_pos='+tmp+')';

 

 

 

 

 

 

 

 

 

dm.temp.Active:=true;

 

 

 

 

 

 

 

 

 

 

i:=2;

 

 

 

 

 

 

 

 

 

 

While (not dm.temp.Eof)do

 

 

 

 

 

 

 

 

 

 

begin

 

 

 

 

 

 

 

 

 

 

Table1.Rows.Add(EmptyParam);

 

 

 

 

 

 

 

 

 

 

Table1.Cell(i, 1).Range.Text := dm.temp.Fields[0].AsString;

 

 

 

 

 

 

 

 

dm.temp2.Active:=false;

 

 

 

 

 

 

 

 

 

 

dm.temp2.CommandText:='Select

sum(st_pos)

from

pozicii,oplata

where

(id_op=id_op_pos)

and

(datar_op

<

#'+fmain.data(dm.opn.fieldbyname('datar_op').AsDateTime)+'#)

and

(id_us_pos='+dm.temp.fieldbyname('id_us').AsString+')

and

(id_ok_op='+id_ok+') and (dataop_op is NULL)';

 

 

 

 

 

 

 

 

 

dm.temp2.Active:=true;

 

 

 

 

 

 

 

 

 

 

Table1.Cell(i, 2).Range.Text := dm.temp2.Fields[0].AsString;

 

 

 

 

 

 

 

 

Table1.Cell(i, 3).Range.Text := dm.temp.Fields[1].AsString;

 

 

 

 

 

 

 

 

Table1.Cell(i, 4).Range.Text := dm.temp.Fields[2].AsString;

 

 

 

 

 

 

 

 

if dm.temp.Fields[3].AsString='0' then Table1.Cell(i, 5).Range.Text :='' else Table1.Cell(i, 5).Range.Text := dm.temp.Fields[3].AsString;

if (dm.temp.Fields[3].asfloat + dm.temp2.Fields[0].asfloat)=0 then Table1.Cell(i, 6).Range.Text:='' else Table1.Cell(i, 6).Range.Text :=

floattostr(dm.temp.Fields[3].asfloat + dm.temp2.Fields[0].asfloat);

 

 

 

 

 

 

inc(i);dm.temp.next;

 

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

dm.temp2.Active:=false;

 

 

 

 

 

 

 

 

dm.temp2.CommandText:='Select

sum(st_pos)

from

pozicii,oplata

where

(id_op=id_op_pos)

and

(datar_op

<=

#'+fmain.data(dm.opn.fieldbyname('datar_op').AsDateTime)+'#) and (id_ok_op='+id_ok+') and (dataop_op is NULL)';

 

 

 

dm.temp2.Active:=true;

 

 

 

 

 

 

 

 

 

Replace:=true; //

,

 

 

 

 

 

 

 

 

FindText:='#6'; //

 

 

 

 

 

 

 

 

 

ReplaceWith:=dm.temp2.fields[0].AsString; //

 

 

 

 

 

 

 

WordDocument1.Range.Find.Execute(FindText,EmptyParam,EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,

 

EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,EmptyParam,EmptyParam,EmptyParam);

 

 

 

{dm.temp.Active:=false;

 

 

 

 

 

 

 

 

 

dm.temp.CommandText:='Select datar_op,sum(st_pos)

from

pozicii,uslugi,metr where

(id_mr=id_mr_us) and

(id_us=id_us_pos)

and

(id_op_pos='+tmp+') and (id_op=id_op_pos) and () group by datar_op';

 

 

 

 

 

dm.temp.Active:=true;}

 

 

 

 

 

 

 

 

 

Table1.Rows.Item(i).Delete;

 

 

 

 

 

 

 

 

WordApplication1.Visible:=true; //

 

MS Word

 

 

 

 

 

WordApplication1.Disconnect; //

 

 

 

 

 

 

 

 

end;

 

 

 

 

 

 

 

 

 

end. unit oplP;

 

 

 

 

 

 

 

 

 

interface

 

 

 

 

 

 

 

 

 

uses

 

 

 

 

 

 

 

 

 

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, StdCtrls, Buttons, ComCtrls, ExtCtrls;

type

TFoplP = class(TForm)

60

Panel1: TPanel;

GroupBox2: TGroupBox;

Label1: TLabel;

Label2: TLabel;

BitBtn4: TBitBtn;

e1: TEdit;

e2: TEdit; DBGrid1: TDBGrid; BitBtn2: TBitBtn;

GroupBox4: TGroupBox;

Button1: TButton;

Button2: TButton;

BitBtn1: TBitBtn;

Button3: TButton;

procedure BitBtn2Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject);

procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure Button3Click(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

FoplP: TFoplP;

implementation

uses datm, Pozicii;

{$R *.dfm}

procedure TFoplP.BitBtn2Click(Sender: TObject); begin

if dm.opp.Fields[0].AsString='' then exit; tmp:=dm.opp.Fields[0].AsString; dm.pos.Active:=false;

dm.pos.CommandText:='Select id_pos,nazv_us,nazv_mr,st_pos from pozicii,uslugi,metr where (id_mr=id_mr_us) and (id_us=id_us_pos) and (id_op_pos='+tmp+')';

dm.pos.Active:=true;

 

 

fpozicii.Caption:=bitbtn2.Caption;

 

 

fpozicii.ShowModal;

 

 

end;

 

 

procedure TFoplP.BitBtn1Click(Sender: TObject);

 

 

begin

 

 

if dm.opp.Fields[0].AsString='' then exit;

 

 

tmp:=dm.opp.Fields[0].AsString;

 

 

if application.MessageBox('

?','

',mb_yesno+mb_iconquestion)=idyes then

begin

 

 

dm.com.CommandText:='Update oplata set fact_op=FALSE,dataop_op=null where (id_op='+tmp+')'; dm.com.Execute;

dm.opp.Requery();

61

Соседние файлы в папке Курсовые работы