Смекни!
smekni.com

Проектування АІС для обслуговування та ремонту автомобілів (стр. 8 из 8)

sum2: =sum2+DataModule1. IBQuery3. fieldbyname ('syma1'). AsFloat;

DataModule1. IBQuery3. Next;

end;

Edit4. Text: =FloatToStr (sum);

Edit5. Text: =FloatToStr (sum1);

Edit6. Text: =FloatToStr (sum2);

end;

end;

procedure TForm10. FormClose (Sender: TObject; var Action: TCloseAction);

begin

DataModule1. IBQuery3. Close;

end;

procedure TForm10. Button2Click (Sender: TObject);

var

Exc,Colum: OleVariant;

i,jj,j: byte;

begin

if DataModule1. IBQuery3. Active=false

then MessageDlg ('Виконайте запит', mtWarning, mbOKCancel, 0)

else begin

Exc: =CreateOleObject ('Excel. Application');

// Exc. WorkBooks. Open ('D: \Документи\ХПК\мої куpcаки\куpcак - ПАIC\InterBase-паpктика\пpоект\akt. xls');

Exc. Visible: =true;

Exc. Workbooks. Add (-4167);

Exc. Workbooks [1]. WorkSheets [1]. Name: ='Отчёт';

Colum: =Exc. Workbooks [1]. WorkSheets ['Отчёт']. Columns;

Colum. Columns [1]. ColumnWidth: =7;

Colum. Columns [2]. ColumnWidth: =25;

Colum. Columns [3]. ColumnWidth: =10;

Colum. Columns [4]. ColumnWidth: =25;

Colum. Columns [5]. ColumnWidth: =10;

Colum. Columns [6]. ColumnWidth: =7;

Colum. Columns [7]. ColumnWidth: =10;

j: =1;

for i: =0 to DBGrid1. Columns. Count-1 do

begin

Exc. Cells [1,j]: =DBGrid1. Columns [i]. Title. Caption;

Exc. Cells [1,j]. Font. Bold: = True;

Exc. Cells [1,j]. Font. Size: =12;

j: =j+1;

end;

j: =0;

DataModule1. IBQuery3. First;

for i: =1 to DataModule1. IBQuery3. RecordCount do

begin

jj: =1;

begin

for j: =0 to DBGrid1. Columns. Count-1 do

begin

Exc. Cells [i+1,jj]: =DBGrid1. Columns [j]. Field. AsString;

jj: =jj+1;

end;

end;

DataModule1. IBQuery3. Next;

end;

end;

end;

end.

unit UConnect;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls;

type

TfmConnect = class (TForm)

GroupBox1: TGroupBox;

RadioGroup1: TRadioGroup;

Button2: TButton;

Button3: TButton;

OpenDialog1: TOpenDialog;

Label1: TLabel;

Label2: TLabel;

Edit1: TEdit;

Edit2: TEdit;

procedure Button3Click (Sender: TObject);

procedure RadioGroup1Click (Sender: TObject);

procedure Button2Click (Sender: TObject);

procedure FormShow (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmConnect: TfmConnect;

tfl: TextFile;

implementation

uses Unit1, UAvto;

{$R *. dfm}

procedure TfmConnect. Button3Click (Sender: TObject);

begin

if (Edit2. Text='') then MessageDlg ('Вкажiть шлях! ', mtWarning, [mbOk], 0) else

begin

if RadioGroup1. ItemIndex=0 then

begin

DataModule1. IBDatabase1. DatabaseName: =Edit2. Text;

end

else

begin

DataModule1. IBDatabase1. DatabaseName: =Edit1. Text+': '+Edit2. Text;

end;

DataModule1. IBDatabase1. Connected: =true;

DataModule1. IBTable1. Open;

DataModule1. IBTable2. Open;

DataModule1. IBTable3. Open;

DataModule1. IBTable4. Open;

DataModule1. IBTable5. Open;

DataModule1. Avto. Open;

DataModule1. Poslygu. Open;

DataModule1. Zapchastunu. Open;

Form1. N4. Enabled: =true;

Form1. N7. Enabled: =true;

Form1. N13. Enabled: =true;

Form1. N15. Enabled: =true;

Form1. N23. Enabled: =true;

Form1. N6. Enabled: =true;

Form1. N2. Enabled: =false;

Form1. N17. Enabled: =false;

AssignFile (tfl,ExtractFileDir (Application. ExeName) +'/connect. db');

Rewrite (tfl);

writeln (tfl,Edit1. Text);

writeln (tfl,Edit2. Text);

if RadioGroup1. ItemIndex=0 then writeln (tfl,'0') else writeln (tfl,'1');

CloseFile (tfl);

Form1. GroupBox1. Visible: =true;

fmConnect. Close;

end;

end;

procedure TfmConnect. RadioGroup1Click (Sender: TObject);

begin

if RadioGroup1. ItemIndex=0 then

begin

Label1. Enabled: =false;

Edit1. Enabled: =FALSE;

end

else

begin

Label1. Enabled: =true;

Edit1. Enabled: =true;

end;

end;

procedure TfmConnect. Button2Click (Sender: TObject);

begin

OpenDialog1. Execute;

Edit2. Text: =OpenDialog1. FileName;

end;

procedure TfmConnect. FormShow (Sender: TObject);

begin

AssignFile (tfl,ExtractFileDir (Application. ExeName) +'/connect. db');

Reset (tfl);

readln (tfl,str1);

readln (tfl,str2);

readln (tfl,str3);

if str3='0' then RadioGroup1. ItemIndex: =0 else RadioGroup1. ItemIndex: =1;

Edit1. Text: =str1;

Edit2. Text: =str2;

CloseFile (tfl);

end;

end.

unit UPassword2;

interface

uses

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

Dialogs, StdCtrls, Mask;

type

TForm12 = class (TForm)

MaskEdit1: TMaskEdit;

Label1: TLabel;

Button1: TButton;

Button2: TButton;

procedure Button1Click (Sender: TObject);

procedure Button2Click (Sender: TObject);

procedure FormShow (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

PWchar=record

C: string [1];

end;

var

Form12: TForm12;

pass: boolean;

password: string;

PSWDChar: array [1. .36] of PWchar;

f2: file of PWchar;

implementation

uses UAvto, UZminaPassword;

{$R *. dfm}

procedure TForm12. Button1Click (Sender: TObject);

begin

if MaskEdit1. Text=Form1. Label2. Caption then

begin

Form1. N3. Enabled: =true;

Form1. N8. Enabled: =true;

Close;

end

else

ShowMessage ('Невipно введено паpоль. ');

end;

procedure TForm12. Button2Click (Sender: TObject);

begin

Close;

end;

procedure TForm12. FormShow (Sender: TObject);

var i: byte;

chk: byte;

begin

password: ='';

MaskEdit1. Text: ='';

chk: =2;

AssignFile (f2,ExtractFileDir (Application. ExeName) +'/info. ini');

Reset (f2);

for i: =1 to 36 do begin

Read (f2,PSWDChar [i]);

if (chk=i) {and (PSWDChar [i]. C<>'') } then begin

password: =password+PSWDChar [i]. C;

chk: =chk+3;

end;

end;

CloseFile (f2);

Form1. Label2. Caption: =password;

end;

end.

unit UZminaPassword;

interface

uses

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

Dialogs, StdCtrls, Mask;

const

Chars='~ЙЦУКЕНГШЩЗХЪФЫВАПPОЛДЖЭЯЧCМИТЬБЮЁ,. ! йцукенгшщзхъфывапpолджэячcмитьбюёqwertyuiop [] &bsol;; lkjhgfdsazxcvbnm,. /1234567890-=`~! @#$%^&* () _+<>?: |}{MNBVCXZLKJHGFDSAPOIUYTREWQ';

type

TForm13 = class (TForm)

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

MaskEdit1: TMaskEdit;

MaskEdit2: TMaskEdit;

MaskEdit3: TMaskEdit;

Button1: TButton;

Button2: TButton;

procedure Button1Click (Sender: TObject);

procedure Button2Click (Sender: TObject);

procedure FormShow (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

PWchar=record

C: string [1];

end;

var

Form13: TForm13;

password: string;

PSWDChar: array [1. .36] of PWchar;

f2: file of PWchar;

implementation

uses UAvto, UPassword2;

{$R *. dfm}

procedure TForm13. Button1Click (Sender: TObject);

var l,r, i: byte;

begin

r: =0;

i: =0;

if MaskEdit1. Text=password then

begin

if MaskEdit2. Text=MaskEdit3. Text then

begin

password: =MaskEdit2. Text;

Form1. Label2. Caption: =password;

l: =length (password);

while i<=33 do begin

inc (r);

inc (i);

PSWDChar [i]. C: =copy (Chars,random (162),1);

inc (i);

if i<l*3 then PSWDChar [i]. C: =copy (password,r,1)

else PSWDChar [i]. C: ='';

inc (i);

PSWDChar [i]. C: =copy (Chars,random (162),1);

end;

assignfile (f2,ExtractFileDir (Application. ExeName) +'/info. ini');

rewrite (f2);

for i: =1 to 36 do begin

Write (f2,PSWDChar [i]);

end;

CloseFile (f2);

Form1. Label2. Caption: =password;

Close;

end

else ShowMessage ('Паpолi не cпiвпадають. ');

end

else ShowMessage ('Невipно введено паpоль. ');

end;

procedure TForm13. Button2Click (Sender: TObject);

begin

Close;

end;

procedure TForm13. FormShow (Sender: TObject);

var i: byte;

chk: byte;

begin

MaskEdit1. Text: ='';

MaskEdit2. Text: ='';

MaskEdit3. Text: ='';

password: ='';

chk: =2;

AssignFile (f2,ExtractFileDir (Application. ExeName) +'/info. ini');

Reset (f2);

for i: =1 to 36 do begin

Read (f2,PSWDChar [i]);

if (chk=i) and (PSWDChar [i]. C<>'') then begin

password: =password+PSWDChar [i]. C;

chk: =chk+3;

end;

end;

CloseFile (f2);

Form1. Label2. Caption: =password;

end;

end