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

unit aOtvK;

interface

uses

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

Dialogs, StdCtrls, Buttons, ExtCtrls;

type

TFaOtvK = class(TForm) Panel1: TPanel;

Label1: TLabel;

Label2: TLabel; e1: TEdit; BitBtn1: TBitBtn; cb1: TComboBox; e2: TEdit;

e3: TEdit; Label3: TLabel; Label4: TLabel; e4: TEdit; Label5: TLabel; e5: TEdit; Label6: TLabel; e6: TEdit; Label7: TLabel;

procedure cb1KeyPress(Sender: TObject; var Key: Char); procedure cb1Change(Sender: TObject);

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

procedure BitBtn1Click(Sender: TObject);

procedure e1KeyPress(Sender: TObject; var Key: Char); procedure e5KeyPress(Sender: TObject; var Key: Char); procedure e6KeyPress(Sender: TObject; var Key: Char); procedure FormShow(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

FaOtvK: TFaOtvK;

implementation

uses datm;

{$R *.dfm}

procedure TFaOtvK.cb1KeyPress(Sender: TObject; var Key: Char);

begin key:=#0; end;

procedure TFaOtvK.cb1Change(Sender: TObject); begin

if id_z <> '' then begin

dm.com.CommandText:='Update zil SET log_z=FALSE where (id_z='+id_z+')';

dm.com.Execute; id_z:='';

end;

dm.temp.Active:=false;

dm.temp.CommandText:='Select id_z from zil where (([adr_z]&",

. "&[dom_z]&", . "&[kv_z])="'+cb1.text+'") and (log_z=FALSE)';

dm.temp.Active:=true;

if dm.temp.RecordCount=0 then

begin

SHOАMESSAGE(' !'+#13+' '); cb1.Text:='';

id_z:=''; end

else begin

id_z:=dm.temp.fields[0].asstring; dm.com.CommandText:='Update zil SET log_z=TRUE where

(id_z='+id_z+')'; dm.com.Execute; end;

end;

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

begin

e1.Clear;e2.Clear; e3.Clear;e4.Clear;e5.Clear;e6.Clear; cb1.Clear;

if tm=2 then begin

dm.com.CommandText:='Update otvk set log_ok=FALSE where (id_ok='+tmp+')';

dm.com.Execute;

dm.ok.RecNo:=ind;

end;

if id_z<>'' then begin

dm.com.CommandText:='Update zil SET log_z=FALSE where (id_z='+id_z+')';

dm.com.Execute; id_z:='';

end;

dm.ok.Requery();

close;

end;

procedure TFaOtvK.BitBtn1Click(Sender: TObject); var tmpstr:string;

begin

 

 

if (e1.Text='') or (e2.Text='') or

(e3.Text='') or

(e4.Text='') or

(id_z='') then showmessage('

 

')

else

 

 

begin

 

 

try

 

 

if strtoint(e4.Text)<1 then

 

 

begin

 

 

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

 

1');

exit;

 

 

end;

 

 

strtoint(e2.Text);strtoint(e3.Text);

 

 

except

 

 

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

');

 

exit;

 

 

end;

 

 

if length(e2.Text)<4 then

 

 

begin

 

 

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

4

');

exit;

 

 

end;

 

 

if length(e3.Text)<6 then

 

 

begin

 

 

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

6

');

exit;

 

 

end;

 

 

if length(e1.Text)<4 then

 

 

begin

 

 

42

ЭЦЩЬЭЫ:=PМСКЫ('"'+О1.TОбЭ)+'"

!'+#13+'

?';

 

if

 

application.MessageBox(pchar(tmpstr),'

',mb_yesno+m

b_iconquestion)=idno then exit;

 

end;

 

if length(e5.Text)<4 then

 

begin

 

tmpstr:=Pchar('"'+О5.TОбЭ)+'"

!'+#13+'

?';

 

if

 

application.MessageBox(pchar(tmpstr),'

',mb_yesno+m

b_iconquestion)=idno then exit;

 

end;

 

if length(e6.Text)<4 then

 

begin

 

ЭЦЩЬЭЫ:=PМСКЫ('"'+О6.TОбЭ)+'"

!'+#13+'

?';

 

if

 

application.MessageBox(pchar(tmpstr),'

',mb_yesno+m

b_iconquestion)=idno then exit;

 

end;

 

if tm=1 then begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select * from otvk where (id_z_ok='+id_z+') OR ((sp_ok="'+e2.Text+'") and (np_ok="'+e3.Text+'"))';

dm.temp.Active:=true;

if dm.temp.RecordCount>0 then showmessage(' ')

else begin

dm.com.CommandText:='Insert into otvk (fam_ok,ima_ok,ot_ok,sp_ok,np_ok,kz_ok,id_z_ok) values ("'+e1.Text+'","'+e5.Text+'","'+e6.Text+'","'+e2.Text+'","'+e3.Text

+'",'+e4.Text+','+id_z+')';

 

 

 

 

 

dm.com.Execute;

 

 

 

 

 

showmessage('

 

 

');

 

 

 

e1.Clear;e2.Clear;e3.Clear;e4.Clear;

 

 

 

end;

 

 

 

 

 

 

end

 

 

 

 

 

 

else

 

 

 

 

 

 

begin

 

 

 

 

 

 

dm.temp.Active:=false;

 

 

 

 

 

dm.temp.CommandText:='Select

*

from

otvk

where

(id_z_ok='+id_z+')

OR

((sp_ok="'+e2.Text+'")

and

(np_ok="'+e3.Text+'"))';

 

 

 

 

 

dm.temp.Active:=true;

 

 

 

 

 

if

(dm.temp.RecordCount>0)

 

and

(dm.temp.Fields[0].AsString<>tmp)

 

 

 

then

showmessage('

 

 

 

 

')

 

else

 

 

 

 

 

 

begin

 

 

 

 

 

 

dm.com.CommandText:='Update

 

otvk

SET

fam_ok="'+e1.Text+'",sp_ok="'+e2.Text+'",np_ok="'+e3.Text+'",k z_ok="'+e4.Text+'",id_z_ok="'+id_z+'",ima_ok="'+e5.Text+'",ot_ ok="'+e6.Text+'" WHERE (id_ok = '+tmp+')';

dm.com.Execute;

 

showmessage('

');

closequery;

 

end;

 

end;

 

end;

 

end;

 

procedure TFaOtvK.e1KeyPress(Sender: TObject; var Key: Char); begin

if not (Key in [#8, ' '..' ',' '..' ']) then begin

Key := #0; end;

end;

procedure TFaOtvK.e5KeyPress(Sender: TObject; var Key: Char);

begin

if not (Key in [#8, ' '..' ',' '..' ']) then begin

Key := #0; end;

end;

procedure TFaOtvK.e6KeyPress(Sender: TObject; var Key: Char); begin

if not (Key in [#8, ' '..' ',' '..' ']) then begin

Key := #0; end;

end;

procedure TFaOtvK.FormShow(Sender: TObject); begin

if tm=1 then id_z:=''; end;

end.

unit pass;

interface

uses

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

Dialogs, StdCtrls, Buttons, ExtCtrls,inifiles;

type

TFpass = class(TForm) Panel1: TPanel;

cb1: TComboBox; e1: TEdit; BitBtn1: TBitBtn; Label1: TLabel; Label2: TLabel;

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

procedure FormShow(Sender: TObject); procedure BitBtn1Click(Sender: TObject);

procedure cb1KeyPress(Sender: TObject; var Key: Char); private

{Private declarations } public

{Public declarations } end;

var

Fpass: TFpass;

implementation

uses datm, main;

{$R *.dfm}

procedure

TFpass.FormCloseQuery(Sender:

TObject;

var

CanClose: Boolean);

 

 

 

begin

 

 

 

 

 

if

application.MessageBox('

 

 

 

 

?','

',mb_yesno+mb_iconquestion)=idyes then

 

begin dm.ado.Connected:=false; application.Terminate; end

else canclose:=false; end;

procedure TFpass.FormShow(Sender: TObject); var inifile:tinifile;

dbp:string; begin

fpass.Caption:=application.Title;

IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Data\opti ons.ini'); //

43

DBP := IniFile.ReadString('base', 'Path', '');

 

 

fmain.StatusBar1.Panels[0].Text:=cb1.Text+',

'+

IniFile.Free;

 

 

 

 

timetostr(time);

 

 

 

 

 

 

 

//

 

dm.od.InitialDir:=ExtractFilePath(Application.ExeName)+'Data';

if dm.temp.Fields[0].asinteger=0 then

 

try

 

 

 

 

 

begin

 

dm.ADO.Connected:=false;

 

 

 

 

fpass.Hide;

 

 

 

 

 

 

 

fmain.ShowModal;

 

dm.ADO.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;

end

 

Data

Source='+dbp+';Persist

Security

Info=False;Jet

//

 

OLEDB:Database Password="12345"';

 

 

 

 

else

 

dm.ADO.Connected:=true;

 

 

 

 

begin

 

except

 

 

 

 

 

fmain.N3.Visible:=false;

 

if

application.MessageBox('

 

 

 

 

fmain.N4.Visible:=false;

 

 

 

 

!'#13'

 

 

//fmain.N9.Visible:=false;

 

 

 

 

 

 

?','

fpass.Hide;

 

 

',mb_yesno+mb_iconquestion)=idyes then

 

 

fmain.ShowModal;

 

begin

 

 

 

 

end

 

if dm.od.Execute then

 

 

 

 

end;

 

begin

 

 

 

 

end

 

IniFile

 

 

 

:=

else

 

TIniFile.Create(ExtractFilePath(Application.ExeName)+'\Data\opti

begin

 

ons.ini');

 

 

 

 

fmain.N3.Visible:=false;

 

inifile.WriteString('base','path',dm.od.FileName);

 

 

fmain.N4.Visible:=false;

 

IniFile.Free;

 

 

 

 

fmain.N9.Visible:=false;

 

dbp:=dm.od.FileName;

 

 

 

 

fmain.Cd1.Visible:=false;

 

dm.ADO.Connected:=false;

 

 

 

 

fpass.Hide;

 

 

 

 

 

 

 

fmain.ShowModal;

 

dm.ADO.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;

end;

 

Data

Source='+dbp+';Persist

Security

Info=False;Jet

 

 

OLEDB:Database Password="12345"';

 

 

 

 

end;

 

dm.ADO.Connected:=true;

 

 

 

 

end;

 

end

 

 

 

 

 

 

 

else

 

 

 

 

 

procedure TFpass.cb1KeyPress(Sender: TObject; var Key: Char);

begin

 

 

 

 

begin

 

dm.ado.Connected:=false;

 

 

 

 

key:=#0;

 

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

 

');

 

 

end;

 

application.Terminate;

 

 

 

 

 

 

end;

 

 

 

 

end.

 

end

 

 

 

 

 

unit aUslugi;

 

else

 

 

 

 

 

 

 

begin

 

 

 

 

interface

 

dm.ado.Connected:=false;

 

 

 

 

 

 

showmessage('

 

');

 

 

uses

 

application.Terminate;

 

 

 

 

Windows, Messages, SysUtils, Variants, Classes, Graphics,

end;

 

 

 

 

 

Controls, Forms,

 

end;

 

 

 

 

 

Dialogs, StdCtrls, Buttons, ExtCtrls,math;

 

dm.temp.Active:=false;

 

 

 

 

 

 

dm.temp.CommandText:='Select login from pass order by login';

type

 

dm.temp.Active:=true;

 

 

 

 

TFaUslugi = class(TForm)

 

while not dm.temp.Eof do

 

 

 

 

Panel1: TPanel;

 

begin

 

 

 

 

 

Label1: TLabel;

 

cb1.Items.Add(dm.temp.Fields[0].AsString);

 

 

Label2: TLabel;

 

dm.temp.Next;

 

 

 

 

Label3: TLabel;

 

end;

 

 

 

 

 

e1: TEdit;

 

 

 

 

 

 

 

BitBtn1: TBitBtn;

 

 

 

 

 

 

 

cb1: TComboBox;

 

end;

 

 

 

 

 

e2: TEdit;

 

 

 

 

 

 

 

procedure BitBtn1Click(Sender: TObject);

 

procedure TFpass.BitBtn1Click(Sender: TObject);

 

 

procedure cb1Change(Sender: TObject);

 

begin

 

 

 

 

 

procedure FormCloseQuery(Sender: TObject; var CanClose:

ТП МЛ1.TОбЭ='' ЭСОЧ ЬСШаЦОЬЬКРО('

 

 

 

Boolean);

 

 

')

 

 

 

 

procedure cb1KeyPress(Sender: TObject; var Key: Char);

 

else if (e1.Text='') and (cb1.Text<>'

 

') then showmessage('

private

 

 

')

 

 

 

 

{ Private declarations }

 

else

 

 

 

 

 

public

 

begin

 

 

 

 

 

{ Public declarations }

 

if e1.Text<>'' then

 

 

 

 

end;

 

begin

 

 

 

 

 

 

dm.temp.Active:=false;

 

 

 

 

var

 

dm.temp.CommandText:='Select

r

from

pass

where

FaUslugi: TFaUslugi;

 

(login="'+cb1.Text+'") and (pass="'+e1.Text+'")';

 

 

 

 

dm.temp.Active:=true;

 

 

 

 

implementation

 

if dm.temp.RecordCount=0 then showmessage('

 

 

 

 

 

 

 

 

')

 

uses datm;

 

else

 

 

 

 

 

 

 

{$R *.dfm}

begin

procedure TFaUslugi.BitBtn1Click(Sender: TObject);

44

begin

 

 

 

if

(e1.Text='') or (e2.Text='')

or

(cb1.Text='')

then

showmessage('

')

 

 

else

 

 

 

 

begin

 

 

 

try

 

 

 

 

e2.Text:=floattostr(roundto(strtofloat(e2.Text),-2));

 

except

 

 

 

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

 

');

 

exit;

 

 

 

end;

 

 

 

if tm=1 then

 

 

 

begin

 

 

 

dm.temp.Active:=false;

 

 

 

dm.temp.CommandText:='Select

*

from uslugi

where

(nazv_us="'+e1.text+'")';

 

 

 

dm.temp.Active:=true;

 

 

 

if

dm.temp.RecordCount>0 then

showmessage('

 

 

')

 

 

 

else

 

 

 

begin

 

 

 

dm.com.CommandText:='Insert

 

into

uslugi

(nazv_us,tar_us,id_mr_us)

 

 

values

("'+e1.Text+'","'+e2.Text+'",'+id_mr+')';

 

 

dm.com.Execute;

 

 

 

dm.temp.Active:=false;

dm.temp.CommandText:='Select max(id_us) from uslugi'; dm.temp.Active:=true;

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

dm.com.CommandText:='Insert

into

rcen

(id_us_rc,st_rc,data_rc) values ('+tmp+',"'+e2.Text+'",date())';

dm.com.Execute;

 

 

showmessage('

 

');

 

e1.Clear;e2.Clear;

 

 

end;

 

 

 

end

 

 

 

else

 

 

 

begin

 

 

 

dm.temp.Active:=false;

 

 

dm.temp.CommandText:='Select

* from uslugi

where

(nazv_us="'+e1.text+'")';

 

 

dm.temp.Active:=true;

 

 

if

(dm.temp.RecordCount>0)

and

(dm.temp.Fields[0].AsString<>tmp)

 

then

showmessage('

 

')

 

else

 

 

 

begin

 

 

 

dm.com.CommandText:='Update

uslugi

SET

nazv_us="'+e1.Text+'",tar_us="'+e2.Text+'",id_mr_us="'+id_mr+' " WHERE (id_us = '+tmp+')';

dm.com.Execute;

 

 

dm.com.CommandText:='Insert

into

rcen

(id_us_rc,st_rc,data_rc) values ('+tmp+',"'+e2.Text+'",date())';

 

dm.com.Execute;

 

 

showmessage('

');

 

closequery;

 

 

end;

 

 

end;

end;

end;

procedure TFaUslugi.cb1Change(Sender: TObject); begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select id_mr from metr where (nazv_mr="'+cb1.text+'")';

dm.temp.Active:=true; id_mr:=dm.temp.Fields[0].AsString; end;

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

begin e1.Clear;e2.Clear; cb1.Clear;

45

if tm=2 then begin

dm.com.CommandText:='Update uslugi set log_us=FALSE where (id_us='+tmp+')';

dm.com.Execute;

dm.us.RecNo:=ind;

end;

dm.us.Requery();

close;

end;

procedure TFaUslugi.cb1KeyPress(Sender: TObject; var Key: Char);

begin key:=#0; end;

end. unit azil;

interface

uses

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

Dialogs, StdCtrls, Buttons, ExtCtrls,math;

type

TFazil = class(TForm) Panel1: TPanel;

e1: TEdit; e2: TEdit;

BitBtn1: TBitBtn; Label1: TLabel; Label2: TLabel; e3: TEdit; Label3: TLabel; e4: TEdit; Label4: TLabel;

procedure BitBtn1Click(Sender: TObject);

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

private

{Private declarations } public

{Public declarations } end;

var

Fazil: TFazil;

implementation

uses datm;

{$R *.dfm}

procedure TFazil.BitBtn1Click(Sender: TObject); var tmpstr:string;

begin

if (e1.Text='') or (e2.Text='') then showmessage(' ')

else begin try

e2.Text:=floattostr(roundto(strtofloat(e2.Text),-2));

except

 

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

');

exit;

 

end;

 

try

 

if strtoint(e4.Text)<0 then

 

begin

 

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

1');

end;

 

except

 

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

');

exit;

 

end;

 

if length(e1.Text)<6 then

 

begin

 

ЭЦЩЬЭЫ:=PМСКЫ('"'+О1.TОбЭ)+'"

 

!'+#13+'

?';

if

 

application.MessageBox(pchar(tmpstr),'

',mb_yesno+m

b_iconquestion)=idno then exit;

 

end;

if tm=1 then begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select * from zil where (adr_z="'+e1.Text+'") and (dom_z="'+e3.Text+'") and (kv_z='+e4.Text+')';

dm.temp.Active:=true;

if dm.temp.RecordCount>0 then showmessage(' ')

else begin

dm.com.CommandText:='Insert into zil (adr_z,pl_z,dom_z,kv_z) values ("'+e1.Text+'","'+e2.Text+'","'+e3.text+'",'+e4.text+')';

dm.com.Execute;

showmessage(' '); e1.Clear;e2.Clear;

end; end

else begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select * from zil where (adr_z="'+e1.Text+'") and (dom_z="'+e3.Text+'") and (kv_z='+e4.Text+')';

dm.temp.Active:=true;

if (dm.temp.RecordCount>0) and (dm.temp.Fields[0].AsString<>tmp) then showmessage('

')

else begin

dm.com.CommandText:='Update zil SET adr_z="'+e1.Text+'",pl_z="'+e2.Text+'",dom_z="'+e3.text+'",kv_z ="'+e4.text+'" WHERE (id_z = '+tmp+')';

dm.com.Execute;

showmessage(' '); closequery;

end;

end;

end;

end;

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

begin e1.Clear;e2.Clear;e3.Clear;e4.Clear; if tm=2 then

begin

dm.com.CommandText:='Update zil set log_z=FALSE where (id_z='+tmp+')';

dm.com.Execute;

dm.z.RecNo:=ind;

end;

dm.z.Requery();

close;

end;

end. unit chpass;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics,

Controls, Forms,

Dialogs, StdCtrls, Buttons, ExtCtrls; type

TFchpass = class(TForm)

Panel1: TPanel;

cb1: TComboBox; e1: TEdit;

e2: TEdit; e3: TEdit;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

procedure cb1KeyPress(Sender: TObject; var Key: Char); procedure BitBtn2Click(Sender: TObject);

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

procedure BitBtn1Click(Sender: TObject); procedure cb1Change(Sender: TObject); procedure FormShow(Sender: TObject);

private

{Private declarations } public

{Public declarations } end;

var

Fchpass: TFchpass; implementation

uses datm; {$R *.dfm}

procedure TFchpass.cb1KeyPress(Sender: TObject; var Key: Char);

begin key:=#0; end;

procedure TFchpass.BitBtn2Click(Sender: TObject); begin

closequery;

end;

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

begin cb1.Clear;e1.Clear;e2.Clear;e3.Clear; close;

end;

procedure TFchpass.BitBtn1Click(Sender: TObject); begin

46

ТП

МЛ1.TОбЭ='' ЭСОЧ ЬСШаЦОЬЬКРО('

 

')

 

ОХЬО ТП О1.TОбЭ='' ЭСОЧ ЬСШаЦОЬЬКРО('

 

 

')

 

else if e2.TeбЭ='' ЭСОЧ ЬСШаЦОЬЬКРО('

')

ОХЬО ТП О3.TОбЭ='' ЭСОЧ ЬСШаЦОЬЬКРО('

 

 

')

 

ОХЬО

ТП О2.TОбЭ<>О3.TОбЭ ЭСОЧ

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

 

 

')

else begin

dm.temp.Active:=false;

dm.temp.CommandText:='select * from pass where (login="'+cb1.Text+'") and (pass="'+e1.Text+'")';

dm.temp.Active:=true;

if dm.temp.RecordCount>0 then begin

dm.com.Commandtext:='Update pass

Set pass="'+e2.Text+'"

where (login = "'+cb1.Text+'")';

 

 

dm.com.Execute;

 

 

showmessage('

');

 

closequery;

 

 

end

 

 

else

 

 

begin

 

 

showmessage('

 

');

end;

 

 

end;

end;

procedure TFchpass.cb1Change(Sender: TObject); begin

e1.Clear;

dm.temp.Active:=false;

dm.temp.CommandText:='select * from pass where (login="'+cb1.Text+'")';

dm.temp.Active:=true;

if cb1.Text<>' ' then begin

e1.Text:=dm.temp.FieldByName('pass').AsString; end

end;

procedure TFchpass.FormShow(Sender: TObject); begin

dm.temp.Active:=false;

dm.temp.CommandText:='Select login from pass WHERE (r<>9) order by login';

dm.temp.Active:=true;

while not dm.temp.Eof do begin

cb1.Items.Add(dm.temp.Fields[0].AsString);

dm.temp.Next;

end;

end;

end. unit main; interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics,

Controls, Forms,

Dialogs, ComCtrls, ExtCtrls,jpeg,inifiles, Menus; type

TFmain = class(TForm)

StatusBar1: TStatusBar;

Image1: TImage;

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

Cd1: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N10: TMenuItem;

Cdtltybz1: TMenuItem;

N11: TMenuItem;

N12: TMenuItem;

N13: TMenuItem;

N14: TMenuItem;

N15: TMenuItem;

N16: TMenuItem;

Image2: TImage;

procedure FormShow(Sender: TObject);

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

procedure N2Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N6Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N8Click(Sender: TObject); procedure N10Click(Sender: TObject); function data(data:tdatetime):string; procedure N12Click(Sender: TObject); procedure N11Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N15Click(Sender: TObject); procedure N16Click(Sender: TObject);

47

private

{Private declarations } public

{Public declarations } end;

var

Fmain: TFmain;

implementation

uses datm, chpass, Zil, OtvK, Uslugi, oplata, oplP, OplN, ot1, ot2, ot3;

{$R *.dfm}

procedure TFmain.FormShow(Sender: TObject); begin

if fileexists(ExtractFilePath(Application.ExeName)+'Data\photo.jpg') then

begin

image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeNa

me)+'Data\photo.jpg');

end;

fmain.Caption:=application.Title;

end;

procedure

TFmain.FormCloseQuery(Sender:

TObject;

var

CanClose: Boolean);

 

 

 

begin

 

 

 

 

 

if

application.MessageBox('

 

 

 

 

?','

',mb_yesno+mb_iconquestion)=idyes then

 

begin dm.ado.Connected:=false; application.Terminate; end

else canclose:=false; end;

procedure TFmain.N2Click(Sender: TObject); begin

closequery;

end;

procedure TFmain.N3Click(Sender: TObject); var inifile:tinifile;

dbp:string; begin

IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Data\opti ons.ini'); //

DBP := IniFile.ReadString('base', 'Path', '');

IniFile.Free;

copyfile(pchar(DBP),pchar(ExtractFilePath(Application.ExeName

)+'Data\ \base_'+datetostr(date)+'_'+stringreplace(timetostr(ti me),':','.',[rfReplaceAll, rfIgnoreCase])+'.mdb'),true);

if

fileexists(ExtractFilePath(Application.ExeName)+'Data\ \bas

e_'+datetostr(date)+'_'+stringreplace(timetostr(time),':','.',[rfReplac

eAll, rfIgnoreCase])+'.mdb') =true then showmessage('

 

')

 

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

');

end;

procedure TFmain.N5Click(Sender: TObject); begin

fchpass.Caption:=n5.Caption;

fchpass.ShowModal;

end;

procedure TFmain.N6Click(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;

fzil.Caption:=n6.Caption;

fzil.ShowModal;

end;

procedure TFmain.N7Click(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;

fOtvK.Caption:=n7.Caption;

fOtvK.ShowModal;

end;

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;

48

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;

49

procedure TFmain.N14Click(Sender: TObject); begin

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);

',mb_yesno+mb_iconquestion)=idyes then

procedure Button3Click(Sender: TObject); procedure dtp1Change(Sender: TObject);

private

{Private declarations } public

{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+' ?','

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; 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;

50

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'; 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]&"

51

"&[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;

 

 

 

 

 

 

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