Смекни!
smekni.com

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

DBEdit1. Text: =IntToStr (index);

Button1. Enabled: =false;

end;

procedure TForm3. DBNavigator1Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

procedure TForm3. DBNavigator2Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

end.

unit UClientu;

interface

uses

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

Dialogs, ExtCtrls, DBCtrls, StdCtrls, Mask, Grids, DBGrids;

type

TForm4 = class (TForm)

GroupBox1: TGroupBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

DBEdit1: TDBEdit;

DBEdit2: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

DBEdit5: TDBEdit;

GroupBox2: TGroupBox;

DBEdit12: TDBEdit;

DBEdit13: TDBEdit;

DBEdit14: TDBEdit;

Label12: TLabel;

Label13: TLabel;

Label14: TLabel;

Label15: TLabel;

DBEdit15: TDBEdit;

DBNavigator2: TDBNavigator;

Button1: TButton;

DBNavigator1: TDBNavigator;

DBNavigator3: TDBNavigator;

procedure GiveIndex;

procedure Button1Click (Sender: TObject);

procedure DBNavigator3Click (Sender: TObject; Button: TNavigateBtn);

procedure DBNavigator1Click (Sender: TObject; Button: TNavigateBtn);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form4: TForm4;

index,max: Integer;

implementation

uses Unit1;

{$R *. dfm}

procedure TForm4. GiveIndex;

begin

if DataModule1. IBTable3. RecNo<>0 then

begin

DataModule1. IBTable3. First;

max: =DataModule1. IBTable3. FieldByName ('id_clienta'). AsInteger;

while not DataModule1. IBTable3. Eof do begin

if max<DataModule1. IBTable3. fieldByName ('id_clienta'). AsInteger then max: =DataModule1. IBTable3. fieldByName ('id_clienta'). AsInteger;

DataModule1. IBTable3. Next;

end;

index: =max+1;

end else index: =1;

end;

procedure TForm4. Button1Click (Sender: TObject);

begin

GiveIndex;

DataModule1. IBTable3. Insert;

DBEdit1. Text: =IntToStr (index);

Button1. Enabled: =false;

end;

procedure TForm4. DBNavigator3Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

procedure TForm4. DBNavigator1Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

end.

unit UZakaz;

interface

uses

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

Dialogs, ExtCtrls, DBCtrls, StdCtrls, Mask, Grids, DBGrids;

type

TForm5 = class (TForm)

GroupBox1: TGroupBox;

DBEdit1: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

DBEdit5: TDBEdit;

DBEdit6: TDBEdit;

DBEdit7: TDBEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

DBLookupComboBox1: TDBLookupComboBox;

DBEdit2: TDBEdit;

Label8: TLabel;

DBLookupComboBox2: TDBLookupComboBox;

DBLookupComboBox3: TDBLookupComboBox;

Label9: TLabel;

Label10: TLabel;

DBGrid1: TDBGrid;

DBNavigator2: TDBNavigator;

Button1: TButton;

DBNavigator3: TDBNavigator;

Label11: TLabel;

procedure GiveIndex;

procedure Button1Click (Sender: TObject);

procedure DBNavigator2Click (Sender: TObject; Button: TNavigateBtn);

procedure DBNavigator3Click (Sender: TObject; Button: TNavigateBtn);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form5: TForm5;

index,max: Integer;

implementation

uses Unit1;

{$R *. dfm}

procedure TForm5. GiveIndex;

begin

if DataModule1. IBTable5. RecNo<>0 then

begin

DataModule1. IBTable5. First;

max: =DataModule1. IBTable5. FieldByName ('id_zakazy'). AsInteger;

while not DataModule1. IBTable5. Eof do begin

if max<DataModule1. IBTable5. fieldByName ('id_zakazy'). AsInteger then max: =DataModule1. IBTable5. fieldByName ('id_zakazy'). AsInteger;

DataModule1. IBTable5. Next;

end;

index: =max+1;

end else index: =1;

end;

procedure TForm5. Button1Click (Sender: TObject);

begin

GiveIndex;

DataModule1. IBTable5. Insert;

DBEdit1. Text: =IntToStr (index);

Button1. Enabled: =false;

end;

procedure TForm5. DBNavigator2Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

procedure TForm5. DBNavigator3Click (Sender: TObject; Button: TNavigateBtn);

begin

Button1. Enabled: =true;

end;

end.

unit UShow;

interface

uses

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

Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, Mask;

type

TForm6 = class (TForm)

GroupBox1: TGroupBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

DBEdit1: TDBEdit;

DBEdit2: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

DBEdit5: TDBEdit;

DBGrid1: TDBGrid;

DBNavigator1: TDBNavigator;

DBGrid2: TDBGrid;

DBNavigator2: TDBNavigator;

GroupBox2: TGroupBox;

GroupBox3: TGroupBox;

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form6: TForm6;

implementation

uses Unit1;

{$R *. dfm}

end.

unit UZaputPoslyg;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids, ComCtrls;

type

TForm7 = class (TForm)

DBGrid1: TDBGrid;

Button1: TButton;

GroupBox1: TGroupBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Picker1: TDateTimePicker;

Picker2: TDateTimePicker;

GroupBox2: TGroupBox;

Edit1: TEdit;

Label5: TLabel;

procedure Button1Click (Sender: TObject);

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

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form7: TForm7;

sum: real;

i: integer;

implementation

uses Unit1;

{$R *. dfm}

procedure TForm7. Button1Click (Sender: TObject);

var dat1,dat2: TDate;

begin

dat1: =Picker1. Date;

dat2: =Picker2. Date;

DataModule1. IBQuery1. Close;

DataModule1. IBQuery1. SQL. Clear;

DataModule1. IBQuery1. SQL. Add ('select poslyga, price_poslygu');

DataModule1. IBQuery1. SQL. Add ('from zakaz, poslygu');

DataModule1. IBQuery1. SQL. Add ('where poslygu. id_poslygu=zakaz. id_poslygu');

DataModule1. IBQuery1. SQL. Add ('and data_oplatu between'+Label1. Caption+DateToStr (dat1) +Label1. Caption+'and'+Label1. Caption+DateToStr (dat2) +Label1. Caption);

DataModule1. IBQuery1. Open;

sum: =0;

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

begin

sum: =sum+DataModule1. IBQuery1. fieldbyname ('price_poslygu'). AsFloat;

DataModule1. IBQuery1. Next;

end;

Edit1. Text: =FloatToStr (sum);

end;

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

begin

DataModule1. IBQuery1. Close;

end;

end.

unit UZaputZapchastun;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids, ComCtrls;

type

TForm8 = class (TForm)

GroupBox1: TGroupBox;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

DBGrid1: TDBGrid;

Button1: TButton;

Label1: TLabel;

Picker1: TDateTimePicker;

Picker2: TDateTimePicker;

GroupBox2: TGroupBox;

Edit1: TEdit;

Label5: TLabel;

procedure Button1Click (Sender: TObject);

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

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form8: TForm8;

sum: real;

i: integer;

implementation

uses Unit1, UPrint;

{$R *. dfm}

procedure TForm8. Button1Click (Sender: TObject);

var dat1,dat2: TDate;

begin

dat1: =Picker1. Date;

dat2: =Picker2. Date;

DataModule1. IBQuery1. Close;

DataModule1. IBQuery1. SQL. Clear; // поле F_1

DataModule1. IBQuery1. SQL. Add ('select name_zapchastun as name, price_zapchastun as price, count_zapchastun as kount, price_zapchastun*count_zapchastun');

DataModule1. IBQuery1. SQL. Add ('from zakaz, zapchastunu');

DataModule1. IBQuery1. SQL. Add ('where zapchastunu. id_zapchastun=zakaz. id_zapchastun');

DataModule1. IBQuery1. SQL. Add ('and data_oplatu between'+Label1. Caption+DateToStr (dat1) +Label1. Caption+'and'+Label1. Caption+DateToStr (dat2) +Label1. Caption);

DataModule1. IBQuery1. Open;

sum: =0;

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

begin

sum: =sum+DataModule1. IBQuery1. fieldbyname ('F_1'). AsFloat;

DataModule1. IBQuery1. Next;

end;

Edit1. Text: =FloatToStr (sum);

end;

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

begin

DataModule1. IBQuery1. Close;

end;

end.

unit UPrint;

interface

uses

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

Dialogs, QRCtrls, QuickRpt, ExtCtrls;

type

TfmPrint = class (TForm)

QuickRep1: TQuickRep;

QRBand1: TQRBand;

QRBand2: TQRBand;

QRSubDetail1: TQRSubDetail;

QRLabel1: TQRLabel;

QRLabel2: TQRLabel;

QRLabel3: TQRLabel;

QRLabel4: TQRLabel;

QRLabel5: TQRLabel;

QRLabel6: TQRLabel;

QRLabel7: TQRLabel;

QRLabel8: TQRLabel;

QRLabel9: TQRLabel;

QRLabel10: TQRLabel;

QRLabel11: TQRLabel;

QRLabel12: TQRLabel;

QRLabel13: TQRLabel;

QRDBText1: TQRDBText;

QRDBText2: TQRDBText;

QRDBText3: TQRDBText;

QRDBText4: TQRDBText;

QRDBText5: TQRDBText;

QRDBText6: TQRDBText;

QRDBText7: TQRDBText;

QRBand3: TQRBand;

QRLabel14: TQRLabel;

QRSysData1: TQRSysData;

QRLabel15: TQRLabel;

QRLabel17: TQRLabel;

QRLabel16: TQRLabel;

QRLabel18: TQRLabel;

QRSysData2: TQRSysData;

QRLabel19: TQRLabel;

private

{ Private declarations }

public

{ Public declarations }

end;

var

fmPrint: TfmPrint;

implementation

uses UZaputPoslyg, Unit1, UZvit1;

{$R *. dfm}

end.

unit UZvit1;

interface

uses

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

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

type

TForm9 = class (TForm)

GroupBox1: TGroupBox;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

DBGrid1: TDBGrid;

Button1: TButton;

Button2: TButton;

Label1: TLabel;

Edit3: TEdit;

Label5: TLabel;

Label6: TLabel;

Edit4: TEdit;

Label7: TLabel;

Label8: TLabel;

Edit5: TEdit;

Label9: TLabel;

Panel1: TPanel;

Button3: TButton;

Picker1: TDateTimePicker;

Picker2: TDateTimePicker;

procedure Button1Click (Sender: TObject);

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

procedure Button2Click (Sender: TObject);

procedure Button3Click (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form9: TForm9;

i: integer;

sum: real;

dat1,dat2: TDate;

implementation

uses Unit1, UPrint, DB;

{$R *. dfm}

procedure TForm9. Button1Click (Sender: TObject);

begin

dat1: =Picker1. Date;

dat2: =Picker2. Date;

DataModule1. IBQuery2. Close;

DataModule1. IBQuery2. SQL. Clear;

DataModule1. IBQuery2. SQL. Add ('select id_zakazy, poslyga as poslyga, price_poslygu as price, name_zapchastun as zapchastunu, price_zapchastun as price, count_zapchastun as kount, (price_poslygu+price_zapchastun*count_zapchastun) as syma');

DataModule1. IBQuery2. SQL. Add ('from zakaz, poslygu, zapchastunu');

DataModule1. IBQuery2. SQL. Add ('where zapchastunu. id_zapchastun=zakaz. id_zapchastun and poslygu. id_poslygu=zakaz. id_poslygu');

DataModule1. IBQuery2. SQL. Add ('and data_oplatu between'+Label1. Caption+DateToStr (dat1) +Label1. Caption+'and'+Label1. Caption+DateToStr (dat2) +Label1. Caption);

DataModule1. IBQuery2. Open;

sum: =0;

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

begin

sum: =sum+DataModule1. IBQuery2. fieldbyname ('syma'). AsFloat;

DataModule1. IBQuery2. Next;

end;

Edit3. Text: =FloatToStr (sum);

end;

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

begin

DataModule1. IBQuery2. Close;

Edit3. Text: ='';

Edit5. Text: ='';

end;

procedure TForm9. Button2Click (Sender: TObject);

begin

if DataModule1. IBQuery2. Active=false

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

else begin

fmPrint: =TfmPrint. Create (Self);

fmPrint. QRLabel4. Caption: =DateToStr (Picker1. Date);

fmPrint. QRLabel6. Caption: =DateToStr (Picker2. Date);

fmPrint. QRLabel17. Caption: =Form9. Edit3. Text+' гpн. ';

fmPrint. QRLabel18. Caption: =Form9. Edit5. Text+' гpн. ';

fmPrint. QuickRep1. Preview;

fmPrint. Free;

end;

end;

procedure TForm9. Button3Click (Sender: TObject);

begin

if DataModule1. IBQuery2. Active=false

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

else begin

Edit5. Text: =FloatToStr (StrToFloat (Edit3. Text) *StrToFloat ('0,'+Edit4. Text));

end;

end;

end.

unit UZvit2;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, ComObj;

type

TForm10 = class (TForm)

GroupBox1: TGroupBox;

Label2: TLabel;

Label4: TLabel;

DBGrid1: TDBGrid;

Button1: TButton;

Edit1: TEdit;

Edit2: TEdit;

Button2: TButton;

Label1: TLabel;

Label3: TLabel;

Edit3: TEdit;

Panel1: TPanel;

Label5: TLabel;

Edit4: TEdit;

Edit5: TEdit;

Label6: TLabel;

Edit6: TEdit;

Label7: TLabel;

procedure Button1Click (Sender: TObject);

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

procedure Button2Click (Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form10: TForm10;

sum,sum1,sum2: real;

i: integer;

implementation

uses Unit1, UPrint1;

{$R *. dfm}

procedure TForm10. Button1Click (Sender: TObject);

begin

if (Edit1. Text='') or (Edit2. Text='') or (Edit3. Text='') then MessageDlg ('Введiть значення в поля', mtWarning, [mbOk], 0) else

begin

DataModule1. IBQuery3. Close;

DataModule1. IBQuery3. SQL. Clear;

DataModule1. IBQuery3. SQL. Add ('select id_zakazy, poslyga as poslyga, price_poslygu as price, name_zapchastun as zapchastunu, price_zapchastun as price, count_zapchastun as kount, (price_zapchastun*count_zapchastun) as syma1, (price_poslygu+price_zapchastun*count_zapchastun) as syma');

DataModule1. IBQuery3. SQL. Add ('from zakaz, poslygu, zapchastunu, avto, clientu');

DataModule1. IBQuery3. SQL. Add ('where zapchastunu. id_zapchastun=zakaz. id_zapchastun and poslygu. id_poslygu=zakaz. id_poslygu');

DataModule1. IBQuery3. SQL. Add ('and avto. nomer_reestracii=zakaz. id_avto and clientu. id_clienta=avto. id_clienta');

DataModule1. IBQuery3. SQL. Add ('and first_name='+Label1. Caption+Edit1. Text+Label1. Caption+'and nomer_reestracii='+Label1. Caption+Edit2. Text+Label1. Caption+'and marka='+Label1. Caption+Edit3. Text+Label1. Caption);

DataModule1. IBQuery3. Open;

sum: =0;

sum1: =0;

sum2: =0;

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

begin

sum: =sum+DataModule1. IBQuery3. fieldbyname ('syma'). AsFloat;

sum1: =sum1+DataModule1. IBQuery3. fieldbyname ('price'). AsFloat;