Курсовые работы / ПРИС П _29
.pdfend. unit OplN; interface
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; |
|
||||
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 '+
52
'where |
(id_z=id_z_ok) |
and |
(id_ok=id_ok_op) |
and |
FТЧНTОбЭ:='#1'; // |
|
|
|
|
|||
(id_op=id_op_pos) and (fact_op=false) and |
(([adr_z]&", . |
RОЩХКМОАТЭС:=НЦ.ШЩЧ.FТОХНЬД0Ж.AЬSЭЫТЧР; // |
|
|||||||||
"&[dom_z]&", |
. "&[kv_z]) like "%'+e2.Text+'%") and |
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
||||||||||
(([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ) like "%'+e1.Text+'%") |
tyParam, |
EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
||||||||||
group |
by |
id_op,([fam_ok]&" "&[ima_ok]&" "&[ot_ok] |
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
|||||||||
),([adr_z]&", |
. "&[dom_z]&", |
. "&[kv_z]),datar_op |
ORDER |
ptyParam,EmptyParam,EmptyParam); |
|
|
||||||
BY sum(st_pos)'; |
|
|
|
|
dm.temp.Active:=false; |
|
|
|
|
|||
dm.opn.Active:=true; |
|
|
|
|
dm.temp.CommandText:='Select pl_z,kz_ok from zil,otvk,oplata |
|||||||
end; |
|
|
|
|
|
|
WHERE |
(id_z=id_z_ok) |
and |
(id_ok=id_ok_op) |
and |
|
procedure TFOplN.BitBtn3Click(Sender: TObject); |
|
(id_op='+tmp+')'; |
|
|
|
|
||||||
var |
|
|
|
|
|
|
dm.temp.Active:=true; |
|
|
|
|
|
Template,NewTemplate,FindText, |
|
|
NewStr, |
kz:=dm.temp.Fields[1].AsString;pl:=dm.temp.fields[0].AsString; |
||||||||
Replace,ReplaceWith:OleVariant; |
|
|
|
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
||||
LinkToFile,SaveWithDocument,Range:OleVariant; |
|
FТЧНTОбЭ:='#2'; // |
|
|
|
|
||||||
Table1: Table; |
|
|
|
|
RОЩХКМОАТЭС:=НЦ.ШЩЧ.ПТОХНЛвЧКЦО('КНЫ').AЬSЭЫТЧР; // |
|
||||||
i: integer; |
|
|
|
|
|
|
|
|
|
|
|
|
flag:boolean; |
|
|
|
|
|
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
||||||
Reg: TRegistry; |
|
|
|
|
tyParam, |
EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
||||||
kz,pl:string; |
|
|
|
|
|
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
||||||
begin |
|
|
|
|
|
|
ptyParam,EmptyParam,EmptyParam); |
|
|
|||
if dm.opn.Fields[0].AsString='' then exit; |
|
|
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
|||||
tmp:=dm.opn.Fields[0].AsString; |
|
|
|
FindTexЭ:='#3'; // |
|
|
|
|
||||
// |
, |
|
АШЫН |
|
|
RОЩХКМОАТЭС:=ЩХ; // |
|
|
|
|
||
Reg := TRegistry.Create; |
|
|
|
|
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
|||||||
Reg.RootKey := HKEY_CLASSES_ROOT; |
|
|
tyParam, |
EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
||||||||
flag:=reg.KeyExists('Word.Application'); |
|
|
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
|||||||||
reg.Free; |
|
|
|
|
|
ptyParam,EmptyParam,EmptyParam); |
|
|
||||
//flag:=true; |
|
|
|
|
|
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
||
if flag=false then |
|
|
|
|
FТЧНTОбЭ:='#4'; // |
|
|
|
|
|||
begin |
|
|
|
|
|
|
RОЩХКМОАТЭС:=Фг; // |
|
|
|
|
|
application.MessageBox('Word |
|
|
|
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
||||||||
|
',' |
',mb_ok+mb_iconstop); |
|
|
tyParam, |
EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
||||||
exit; |
|
|
|
|
|
|
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
|||||
end; |
|
|
|
|
|
|
ptyParam,EmptyParam,EmptyParam); |
|
|
|||
WordApplication1.Connect; // |
|
|
|
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
||||
// |
|
otchet.dot |
Word |
|
|
FТЧНTОбЭ:='#5'; // |
|
|
|
|
||
|
|
|
|
|
|
|
ReplaceWith:=dm.opn.fieldbyname('fio_ok').AsString; // |
|
||||
Template:=ExtractFilePath(Application.EXEName)+'\Data\ |
|
|
|
|
|
|
||||||
\ |
|
.dot'; // |
|
|
|
|
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
|||||
|
|
|
|
|
|
|
tyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
|||||
WordApplication1.Documents.Add(Template,EmptyParam,Empty |
|
|
|
|
|
|
||||||
Param,EmptyParam);// |
|
|
|
|
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
|||||||
|
|
|
|
|
|
|
ptyParam,EmptyParam,EmptyParam); |
|
|
|||
WordDocument1.ConnectTo(WordApplication1.ActiveDocument) |
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
|||||||
; // |
|
|
WordDocument1 |
c |
|
FТЧНTОбЭ:='#7'; // |
|
|
|
|
||
|
( |
. . |
|
|
) |
|
RОЩХКМОАТЭС:=НЦ.ШЩЧ.ПТОХНЛвЧКЦО('НКЭКЫИШЩ').AЬSЭЫТЧР; |
// |
||||
// |
|
|
|
|
|
|
|
|
|
|
|
|
TКЛХО1:=АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(1); // |
|
|
WordDocument1.Range.Find.Execute(FindText,EmptyParam,Emp |
|||||||||
TКЛХО1 |
|
|
|
|
|
|
tyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam, |
|||||
//WordDocument1.Tables - |
|
|
( |
|
|
|
|
|
|
|||
TКЛХОЬ), |
АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(Т) - i- |
|
|
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em |
||||||||
RОЩХКМО:=ЭЫЮО; // |
, |
|
|
|
ptyParam,EmptyParam,EmptyParam); |
|
|
53
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,Emp tyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,ReplaceWith,Replace,EmptyParam,Em
ptyParam,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)
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;
54
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(); |
|
|
|
|
|
||
end; |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
procedure TFoplP.BitBtn4Click(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) 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]),dataop_op'; |
|
|
|
|
||
dm.opp.Active:=true; |
|
|
|
|
||
end; |
|
|
|
|
|
|
procedure TFoplP.Button1Click(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) |
and (([adr_z]&", |
. |
55
"&[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]) ,dataop_op order by |
|||
dataop_op'; |
|
|
|
|
|
dm.opp.Active:=true; |
|
|
|
||
end; |
|
|
|
|
|
procedure TFoplP.Button2Click(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) 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]),dataop_op order by |
||||||
sum(st_pos)'; |
|
|
|
|
|
|
|
dm.opp.Active:=true; |
|
|
|
|
|
||
end; |
|
|
|
|
|
|
|
procedure |
TFoplP.FormCloseQuery(Sender: |
TObject; |
var |
||||
CanClose: Boolean); |
|
|
|
|
|
||
begin |
|
|
|
|
|
|
|
dm.opp.Active:=false; |
|
|
|
|
|
||
e1.Clear;e2.Clear; |
|
|
|
|
|
||
end; |
|
|
|
|
|
|
|
procedure TFoplP.Button3Click(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; |
|
|
|
|
|
||
end; |
|
|
|
|
|
|
|
end. unit ot1; |
|
|
|
|
|
|
|
interface |
|
|
|
|
|
|
|
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls; type
TFot1 = class(TForm)
Panel1: TPanel;
dtp1: TDateTimePicker;
Label1: TLabel;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
var
Fot1: TFot1; implementation uses datm, main; {$R *.dfm}
procedure TFot1.BitBtn1Click(Sender: TObject); begin
dm.temp.Active:=false;
dm.temp.CommandText:='Select sum(st_pos) from pozicii,oplata where (id_op=id_op_pos) and (datar_op<=#'+fmain.data(dtp1.Date)+'#) and ((dataop_op>#'+fmain.data(dtp1.Date)+'#) OR (dataop_op is Null))';
dm.temp.Active:=true;
showmessage(' : ' + dm.temp.Fields[0].AsString);
end;
end. unit ot2; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls; type
TFot2 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
dtp1: TDateTimePicker; BitBtn1: TBitBtn; Label2: TLabel;
dtp2: TDateTimePicker;
procedure BitBtn1Click(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
var
Fot2: TFot2; implementation uses datm, main; {$R *.dfm}
function ReplaceStr(Str, SubStr, Replace: string): string;
д |
ж |
var i:Integer; begin Result:= ''; repeat
i:=Pos(SubStr, Str); if i > 0 then begin
Result:=Result+Copy(Str,1,I-1)+Replace;
Str:=Copy(Str,i+Length(SubStr),MaxInt); end else Result:=Result+Str;
until i<=0; end;
procedure TFot2.BitBtn1Click(Sender: TObject); begin
dm.temp.Active:=false;
dm.temp.CommandText:='Select max(st_rc) from rcen where (data_rc BETWEEN #'+fmain.data(dtp1.Date)+'# and #'+fmain.data(dtp2.Date)+'#) ';
dm.temp.Active:=true;
tmp:=dm.temp.Fields[0].AsString; if trim(tmp)='' then
begin dm.temp.Active:=false;
dm.temp.CommandText:='Select max(st_rc) from rcen where (data_rc <= #'+fmain.data(dtp1.Date)+'# )';
dm.temp.Active:=true;
tmp:=dm.temp.Fields[0].AsString;
end;
if trim(tmp)='' then begin
ЬСШаЦОЬЬКРО(' ');
exit;
end;
tmp:=ReplaceStr(tmp,',','.');
dm.temp.Active:=false;
dm.temp.CommandText:='Select nazv_us from uslugi,rcen where (id_us=id_us_rc) and (st_rc='+tmp+') and ((data_rc BETWEEN #'+fmain.data(dtp1.Date)+'# and #'+fmain.data(dtp2.Date)+'#) OR (data_rc <= #'+fmain.data(dtp1.Date)+'# ))'; dm.temp.Active:=true;
showmessage(' : ' + dm.temp.Fields[0].AsString);
end;
end. unit ot3; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls, Spin, Buttons, ExtCtrls,dateutils, WordXP,
OleServer,registry;
56
type
TFot3 = class(TForm) Panel1: TPanel; Label1: TLabel; BitBtn1: TBitBtn; se1: TSpinEdit; Label2: TLabel;
WordApplication1: TWordApplication; WordDocument1: TWordDocument; procedure BitBtn1Click(Sender: TObject);
private
{Private declarations } public
{Public declarations } end;
var
Fot3: TFot3;
implementation
uses datm, main;
{$R *.dfm}
procedure TFot3.BitBtn1Click(Sender: TObject); var data:tdatetime;
Template,NewTemplate,FindText, |
NewStr, |
||
Replace,ReplaceWith:OleVariant; |
|
||
LinkToFile,SaveWithDocument,Range:OleVariant; |
|
||
Table1: Table; |
|
|
|
i: integer; |
|
|
|
flag:boolean; |
|
|
|
Reg: TRegistry; |
|
|
|
begin |
|
|
|
// |
, |
Word |
|
Reg := TRegistry.Create; |
|
||
Reg.RootKey := HKEY_CLASSES_ROOT; |
|
||
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,Empty
Param,EmptyParam);//
WordDocument1.ConnectTo(WordApplication1.ActiveDocument)
; // |
WordDocument1 |
c |
( . . |
|
) |
// |
|
|
TКЛХО1:=АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(1); // |
|
|
TКЛХО1 |
|
|
//WordDocument1.Tables - |
|
( |
TКЛХОЬ), АШЫНDШМЮЦОЧЭ1.TКЛХОЬ.IЭОЦ(Т) - i-
data:=incday(date,-se1.Value); dm.temp.Active:=false;
dm.temp.CommandText:='Select ([fam_ok]&" "&[ima_ok]&"
"&[ot_ok] ) as fio_ok,([sp_ok]&"-"&[np_ok]) as pasp,([adr_z]&",
. "&[dom_z]&", . "&[kv_z]) as adr from zil,otvk,pozicii,oplata
'+ |
|
|
|
|
'where |
(id_z=id_z_ok) |
and |
(id_ok=id_ok_op) |
and |
(id_op=id_op_pos) and (fact_op=FALSE) and (datar_op between date() and #'+fmain.data(data)+'#) GROUP BY ([fam_ok]&" "&[ima_ok]&" "&[ot_ok] ),([sp_ok]&"-"&[np_ok]),([adr_z]&", . "&[dom_z]&", . "&[kv_z])';
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; Table1.Cell(i, 2).Range.Text := dm.temp.Fields[1].AsString; Table1.Cell(i, 3).Range.Text := dm.temp.Fields[2].AsString; inc(i);dm.temp.next;
end; |
|
Table1.Rows.Item(i).Delete; |
|
WordApplication1.Visible:=true; // |
MS |
Word |
|
WordApplication1.Disconnect; // |
|
end; |
|
end. unit OtvK; interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls; type
TFOtvK = class(TForm)
Panel1: TPanel;
Label1: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
e1: TEdit; BitBtn4: TBitBtn; BitBtn5: TBitBtn;
57
DBGrid1: TDBGrid;
Label2: TLabel;
Button1: TButton;
procedure BitBtn5Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
var
FOtvK: TFOtvK;
implementation
uses datm, aOtvK;
{$R *.dfm}
procedure TFOtvK.BitBtn5Click(Sender: TObject); begin
dm.ok.Active:=false;
dm.ok.CommandText:='Select id_ok,fam_ok,ima_ok,ot_ok,sp_ok,np_ok,kz_ok,log_ok,([adr_z]&
", . "&[dom_z]&", . "&[kv_z]) as adr from OtvK,zil WHERE (id_z=id_z_ok) ORDER BY kz_ok';
dm.ok.Active:=true;
end;
procedure TFOtvK.BitBtn4Click(Sender: TObject); begin
if e1.Text<>'' then
begin dm.ok.Active:=false;
dm.ok.CommandText:='Select
id_ok,fam_ok,ima_ok,ot_ok,sp_ok,np_ok,kz_ok,log_ok,([adr_z]&
", . "&[dom_z]&", |
. "&[kv_z]) as adr from OtvK,zil WHERE |
(id_z=id_z_ok)and |
(([sp_ok]&"-"&[np_ok]) = "'+e1.Text+'") |
ORDER BY kz_ok'; |
|
dm.ok.Active:=true; |
|
end |
|
else |
|
begin |
|
dm.ok.Active:=false;
dm.ok.CommandText:='Select id_ok,fam_ok,ima_ok,ot_ok,sp_ok,np_ok,kz_ok,log_ok,([adr_z]& ", . "&[dom_z]&", . "&[kv_z]) as adr from OtvK,zil WHERE (id_z=id_z_ok) ORDER BY kz_ok';
dm.ok.Active:=true; end
end;
58
procedure TFOtvK.BitBtn1Click(Sender: TObject); begin
faOtvK.Caption:=bitbtn1.Caption;
faOtvK.cb1.Clear;
dm.temp.Active:=false;
dm.temp.CommandText:='Select ([adr_z]&", . "&[dom_z]&", . "&[kv_z]) from zil order by adr_z';
dm.temp.Active:=true; while not dm.temp.Eof do
begin faOtvK.cb1.Items.Add(dm.temp.Fields[0].AsString); dm.temp.Next;
end;
tm:=1;
faOtvK.ShowModal;
end;
procedure TFOtvK.BitBtn2Click(Sender: TObject); begin
if dm.ok.Fields[0].AsString='' then exit;
tm:=2;ind:=dm.ok.RecNo;
faotvk.Caption:=bitbtn2.Caption;
tmp:=dm.ok.Fields[0].AsString;
dm.temp.Active:=false;
dm.temp.CommandText:='Select log_ok from otvk where id_ok='+tmp+'';
dm.temp.Active:=true;
if dm.temp.Fields[0].AsBoolean=false then begin
faOtvK.cb1.Clear;
dm.temp.Active:=false;
dm.temp.CommandText:='Select ([adr_z]&", . "&[dom_z]&",
. "&[kv_z]) from zil order by adr_z'; dm.temp.Active:=true;
while not dm.temp.Eof do begin
faOtvK.cb1.Items.Add(dm.temp.Fields[0].AsString);
dm.temp.Next;
end; faotvk.cb1.Text:=dm.ok.fieldbyname('adr').AsString; faotvk.e1.Text:=dm.ok.fieldbyname('fam_ok').AsString; faotvk.e5.Text:=dm.ok.fieldbyname('ima_ok').AsString; faotvk.e6.Text:=dm.ok.fieldbyname('ot_ok').AsString; faotvk.e2.Text:=dm.ok.fieldbyname('sp_ok').AsString; faotvk.e3.Text:=dm.ok.fieldbyname('np_ok').AsString; faotvk.e4.Text:=dm.ok.fieldbyname('kz_ok').AsString; faotvk.cb1Change(sender);
dm.com.CommandText:='Update otvk SET log_ok=TRUE WHERE (id_ok='+tmp+')';
dm.com.Execute;
faotvk.ShowModal; end
else |
|
|
|
|
begin |
|
|
|
|
ЬСШаЦОЬЬКРО(' |
|
') |
|
|
end; |
|
|
|
|
end; |
|
|
|
|
procedure TFOtvK.BitBtn3Click(Sender: TObject); |
|
|||
begin |
|
|
|
|
if dm.ok.Fields[0].AsString='' then exit; |
|
|
|
|
tmp:=dm.ok.Fields[0].AsString; |
|
|
|
|
dm.temp.Active:=false; |
|
|
|
|
dm.temp.CommandText:='Select log_ok |
from |
otvk |
where |
|
id_ok='+tmp+''; |
|
|
|
|
dm.temp.Active:=true; |
|
|
|
|
if dm.temp.Fields[0].AsBoolean=false then |
|
|
|
|
begin |
|
|
|
|
if |
application.MessageBox(' |
|
|
|
?',' |
',mb_yesno+mb_iconquestion)=idyes then |
|||
begin |
|
|
|
|
dm.com.CommandText:='DELETE * |
from |
otvk WHERE |
||
(id_ok='+tmp+')'; |
|
|
|
|
dm.com.Execute; |
|
|
|
|
dm.ok.Requery(); |
|
|
|
|
end; |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
begin |
|
|
|
|
ЬСШаЦОЬЬКРО(' |
|
') |
|
|
end; |
|
|
|
|
end; |
|
|
|
|
procedure |
TFOtvK.FormCloseQuery(Sender: |
TObject; |
var |
CanClose: Boolean); begin dm.ok.Active:=false; e1.Clear;
end;
procedure TFOtvK.Button1Click(Sender: TObject); begin
dm.ok.Active:=false;
dm.ok.CommandText:='Select id_ok,fam_ok,ima_ok,ot_ok,sp_ok,np_ok,kz_ok,log_ok,([adr_z]& ", . "&[dom_z]&", . "&[kv_z]) as adr from OtvK,zil WHERE (id_z=id_z_ok) ORDER BY fam_ok,ima_ok,ot_ok'; dm.ok.Active:=true;
end;
end. unit Pozicii; interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, Grids, DBGrids; type
TFPozicii = class(TForm)
DBGrid1: TDBGrid; private
{Private declarations } public
{Public declarations } end;
var
FPozicii: TFPozicii; implementation
uses datm; {$R *.dfm} end. unit Uslugi; interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls; type
TFUslugi = class(TForm)
Panel1: TPanel;
Label1: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
e1: TEdit;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
DBGrid1: TDBGrid;
Button1: TButton;
procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure BitBtn5Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
var
FUslugi: TFUslugi; implementation
uses datm, aUslugi; {$R *.dfm}
procedure TFUslugi.BitBtn1Click(Sender: TObject); begin
fauslugi.Caption:=bitbtn1.Caption;
tm:=1;
fauslugi.cb1.Clear;
59
dm.temp.Active:=false;
dm.temp.CommandText:='Select nazv_mr from metr order by nazv_mr';
dm.temp.Active:=true; while not dm.temp.Eof do
begin fauslugi.cb1.Items.Add(dm.temp.Fields[0].AsString); dm.temp.Next;
end;
fauslugi.ShowModal;
end;
procedure TFUslugi.BitBtn2Click(Sender: TObject); begin
if dm.us.Fields[0].AsString='' then exit; tm:=2;ind:=dm.us.RecNo; fauslugi.Caption:=bitbtn2.Caption; tmp:=dm.us.Fields[0].AsString; dm.temp.Active:=false;
dm.temp.CommandText:='Select log_us from uslugi where id_us='+tmp+'';
dm.temp.Active:=true;
if dm.temp.Fields[0].AsBoolean=false then begin
fauslugi.cb1.Clear;
dm.temp.Active:=false;
dm.temp.CommandText:='Select nazv_mr from metr order by nazv_mr';
dm.temp.Active:=true; while not dm.temp.Eof do
begin fauslugi.cb1.Items.Add(dm.temp.Fields[0].AsString); dm.temp.Next;
end; fauslugi.cb1.Text:=dm.us.fieldbyname('nazv_mr').AsString; fauslugi.e1.Text:=dm.us.fieldbyname('nazv_us').AsString; fauslugi.e2.Text:=dm.us.fieldbyname('tar_us').AsString; fauslugi.cb1Change(sender);
dm.com.CommandText:='Update uslugi SET log_us=TRUE WHERE (id_us='+tmp+')';
dm.com.Execute;
fauslugi.ShowModal; end
else begin
ЬСШаЦОЬЬКРО(' |
') |
end;
end;
procedure TFUslugi.BitBtn3Click(Sender: TObject); begin
if dm.us.Fields[0].AsString='' then exit; tmp:=dm.us.Fields[0].AsString; dm.temp.Active:=false;
dm.temp.CommandText:='Select log_us from uslugi where id_us='+tmp+'';
dm.temp.Active:=true;
if dm.temp.Fields[0].AsBoolean=false then begin
if
?',' begin
dm.com.CommandText:='DELETE * from uslugi WHERE (id_us='+tmp+')';
dm.com.Execute;
dm.us.Requery();
end; end
else begin
ЬСШаЦОЬЬКРО(' |
') |
end;
end;
procedure TFUslugi.BitBtn4Click(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) and (nazv_us like "%'+e1.Text+'%")';
dm.us.Active:=true;
end;
procedure TFUslugi.BitBtn5Click(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) and (nazv_us like "%'+e1.Text+'%") order by tar_us';
dm.us.Active:=true;
end;
procedure TFUslugi.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin dm.us.Active:=false; e1.Clear;
end;
procedure TFUslugi.Button1Click(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;
end;
end. unit Zil; interface uses
60
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, ExtCtrls;
type TFZil = class(TForm) |
|
|
Panel1: TPanel; |
DBGrid1: TDBGrid |
BitBtn1: TBitBtn; |
BitBtn2: TBitBtn; |
|
|
BitBtn3: TBitBtn; |
Label1: TLabel; |
|
e1: TEdit; BitBtn4: TBitBtn; BitBtn5: TBitBtn; Button1: TButton;
procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); procedure BitBtn3Click(Sender: TObject); procedure BitBtn4Click(Sender: TObject); procedure BitBtn5Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
varFZil: TFZil;
implementation uses datm, azil; {$R *.dfm}
procedure TFZil.BitBtn1Click(Sender: TObject);begin fazil.Caption:=bitbtn1.Caption;
tm:=1;
fazil.ShowModal;
end;procedure TFZil.BitBtn2Click(Sender: TObject); begin
if dm.z.Fields[0].AsString='' then exit; tm:=2;ind:=dm.z.RecNo; fazil.Caption:=bitbtn2.Caption; tmp:=dm.z.Fields[0].AsString; dm.temp.Active:=false;
dm.temp.CommandText:='Select log_z from zil where id_z='+tmp+'';
dm.temp.Active:=true;
if dm.temp.Fields[0].AsBoolean=false then begin
fazil.e1.Text:=dm.z.fieldbyname('adr_z').AsString; fazil.e2.Text:=dm.z.fieldbyname('pl_z').AsString; fazil.e3.Text:=dm.z.fieldbyname('dom_z').AsString; fazil.e4.Text:=dm.z.fieldbyname('kv_z').AsString; dm.com.CommandText:='Update zil SET log_z=TRUE WHERE
(id_z='+tmp+')'; dm.com.Execute; fazil.ShowModal; end
else begin
ЬСШаЦОЬЬКРО(' |
|
|
') |
|
|
end; |
|
|
|
|
|
end; |
|
|
|
|
|
procedure TFZil.BitBtn3Click(Sender: TObject); |
|
|
|||
begin |
|
|
|
|
|
if dm.z.Fields[0].AsString='' then exit; |
|
|
|
||
tmp:=dm.z.Fields[0].AsString; |
|
|
|
|
|
dm.temp.Active:=false; |
|
|
|
|
|
dm.temp.CommandText:='Select |
log_z |
from |
zil |
where |
|
id_z='+tmp+''; |
|
|
|
|
|
dm.temp.Active:=true; |
|
|
|
|
|
if dm.temp.Fields[0].AsBoolean=false then |
|
|
|
||
begin |
|
|
|
|
|
if |
application.MessageBox(' |
|
|
|
|
?',' |
',mb_yesno+mb_iconquestion)=idyes then |
||||
begin |
|
|
|
|
|
dm.com.CommandText:='DELETE * |
from |
zil |
WHERE |
||
(id_z='+tmp+')'; |
|
|
|
|
|
dm.com.Execute; |
|
|
|
|
|
dm.z.Requery(); |
|
|
|
|
|
end; |
|
|
|
|
|
end |
|
|
|
|
|
else |
|
|
|
|
|
begin |
|
|
|
|
|
ЬСШаЦОЬЬКРО(' |
|
|
') |
|
end;
end;
procedure TFZil.BitBtn4Click(Sender: TObject); begin
dm.z.Active:=false;
dm.z.CommandText:='Select id_z,adr_z,pl_z,log_z,dom_z,kv_z from zil WHERE (adr_z like "%'+e1.Text+'%") ORDER BY kv_z';dm.z.Active:=true;end;
procedure TFZil.BitBtn5Click(Sender: TObject);begin dm.z.Active:=false;
dm.z.CommandText:='Select id_z,adr_z,pl_z,log_z,dom_z,kv_z from zil WHERE (adr_z like "%'+e1.Text+'%") ORDER BYkv_z'; dm.z.Active:=true;
end;procedure TFZil.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin dm.z.Active:=false; e1.Clear;
end;
procedure TFZil.Button1Click(Sender: TObject); begin
dm.z.Active:=false;
dm.z.CommandText:='Select id_z,adr_z,pl_z,log_z,dom_z,kv_z from zil ORDER BY adr_z';
dm.z.Active:=true;
end;
end.
61