Смекни!
smekni.com

АРМ мененджер автосалона А моторс (стр. 12 из 14)

komplectELECT_PAK: TBooleanField;

komplectABS: TBooleanField;

komplectGUR: TBooleanField;

komplectKONDIC: TBooleanField;

komplectINFO: TMemoField;

komplectDEFEKT: TMemoField;

komplectKOROBKA: TStringField;

komplectPRIVOD: TStringField;

avto_outKOD_OUT: TFloatField;

avto_outDATE: TDateField;

avto_outMARKA_OUT: TStringField;

avto_outMODEL_OUT: TStringField;

avto_outV_OUT: TStringField;

avto_outCVET_OUT: TStringField;

avto_outTIPKUZ_OUT: TStringField;

avto_outCENA_OUT: TFloatField;

dsmarka: TDataSource;

marka: TTable;

markaID_MARKA: TSmallintField;

markaMARKA: TStringField;

vlad: TTable;

vladKOD_VLAD: TFloatField;

vladFAM: TStringField;

vladNAME: TStringField;

vladOTH: TStringField;

vladADRES: TStringField;

vladMAIL: TStringField;

vladTEL: TFloatField;

vladSOT: TFloatField;

t1: TTable;

t1KOD_AVTO: TFloatField;

t1KOD_VLAD: TFloatField;

t1MARKA: TSmallintField;

t1MODEL: TStringField;

t1GOS_NOM: TStringField;

t1CVET: TStringField;

t1TIP_KUZ: TStringField;

t1FOTO_1: TStringField;

t1FOTO_2: TStringField;

Продолжение приложения А

t1CENA: TFloatField;

t1hoz: TStringField;

t1V: TStringField;

t1MMarka: TStringField;

avto: TTable;

avtoKOD_AVTO: TFloatField;

avtoKOD_VLAD: TFloatField;

avtoMARKA: TSmallintField;

avtoMODEL: TStringField;

avtoGOS_NOM: TStringField;

avtoCVET: TStringField;

avtoTIP_KUZ: TStringField;

avtoFOTO_1: TStringField;

avtoFOTO_2: TStringField;

avtoCENA: TFloatField;

avtoV: TFloatField;

avtohoz: TStringField;

avtoMMarka: TStringField;

procedure DataModuleCreate(Sender: TObject);

procedure avtoAfterScroll(DataSet: TDataSet);

procedure markaBeforeInsert(DataSet: TDataSet);

procedure markaAfterInsert(DataSet: TDataSet);

private

{ Private declarations }

public

{ Public declarations }

end;

var

dm1: Tdm1;

id : integer;

implementation

uses main;

{$R *.dfm}

procedure Tdm1.DataModuleCreate(Sender: TObject);

begin

avto.Close;

avto.Open;

komplect.Close;

komplect.Open;

avto_in.Close;

avto_in.Open;

avto_out.Close;

avto_out.Open;

vlad.Close;

vlad.Open;

sot.Close;

sot.Open;

end;

procedure Tdm1.avtoAfterScroll(DataSet: TDataSet);

begin

try

Fmain.Image3.Picture.LoadFromFile(ExtractFilePath(path)+'FOTO\'+dm1.avto.fieldbyname('FOTO_1').AsString);

Продолжение приложения А

except

Fmain.Image3.picture:=nil;

end;

try

Fmain.Image4.Picture.LoadFromFile(ExtractFilePath(path)+'FOTO\'+dm1.avto.fieldbyname('FOTO_2').AsString);

except

Fmain.Image4.picture:=nil;

end;

end;

procedure Tdm1.markaBeforeInsert(DataSet: TDataSet);

begin

id:=0;

Marka.First;

while not Marka.Eof do begin

if Marka.FieldByName('Id_marka').asinteger > id

then id := Marka.FieldByName('Id_marka').asinteger;

Marka.Next;

end;

id:=id+1;

end;

procedure Tdm1.markaAfterInsert(DataSet: TDataSet);

begin

Marka.FieldByName('id_marka').asinteger:=id;

end;

end.

А.5 Модуль формы «Редактирование данных»

unit edit;

interface

uses

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

Dialogs, ExtCtrls, LMDControl, LMDBaseControl, LMDBaseGraphicButton,

LMDCustomSpeedButton, LMDSpeedButton, StdCtrls, RxGIF, glLabel, Mask,

ToolEdit, DBCtrls,IDGlobal, ExtDlgs, Grids, DBGrids;

type

TFedit = class(TForm)

Panel3: TPanel;

glLabel2: TglLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Label14: TLabel;

Image1: TImage;

ComboBox1: TComboBox;

Panel4: TPanel;

glLabel3: TglLabel;

Label15: TLabel;

Продолжение приложения А

Label16: TLabel;

Label17: TLabel;

Label18: TLabel;

Label19: TLabel;

ComboBox2: TComboBox;

ComboBox3: TComboBox;

ComboBox4: TComboBox;

Panel1: TPanel;

glLabel4: TglLabel;

LMDSpeedButton8: TLMDSpeedButton;

LMDSpeedButton9: TLMDSpeedButton;

Image4: TImage;

Image5: TImage;

Panel5: TPanel;

LMDSpeedButton10: TLMDSpeedButton;

LMDSpeedButton12: TLMDSpeedButton;

DBEdit2: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

DBEdit5: TDBEdit;

DBEdit6: TDBEdit;

DBMemo1: TDBMemo;

DBMemo2: TDBMemo;

DBCheckBox1: TDBCheckBox;

DBCheckBox2: TDBCheckBox;

DBCheckBox3: TDBCheckBox;

DBCheckBox4: TDBCheckBox;

DBCheckBox5: TDBCheckBox;

DBCheckBox6: TDBCheckBox;

DBCheckBox7: TDBCheckBox;

DBCheckBox8: TDBCheckBox;

OpenPictureDialog1: TOpenPictureDialog;

OpenPictureDialog2: TOpenPictureDialog;

Image3: TImage;

DBLookupComboBox1: TDBLookupComboBox;

procedure LMDSpeedButton12Click(Sender: TObject);

procedure LMDSpeedButton10Click(Sender: TObject);

procedure LMDSpeedButton8Click(Sender: TObject);

procedure LMDSpeedButton9Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

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

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

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

private

{ Private declarations }

public

{ Public declarations }

end;

var

Fedit: TFedit;

pic1,pic2:string;

pole1,pole2,pole1_1,pole2_2:string;

y,t:integer;

implementation

uses dm, DB;

{$R *.dfm}

Продолжение приложения А

procedure TFedit.LMDSpeedButton12Click(Sender: TObject);

begin

close;

end;

procedure TFedit.LMDSpeedButton10Click(Sender: TObject);

var st1,q1,st2,q2:string;

i,u,k2:integer;

begin

dm1.avto.Edit;

dm1.komplect.Edit;

dm1.avto.FieldByName('TIP_KUZ').Value:=ComboBox1.text;

dm1.komplect.FieldByName('KOLESO').value:=ComboBox2.text;

dm1.komplect.FieldByName('KOROBKA').value:=ComboBox3.text;

dm1.komplect.FieldByName('PRIVOD').value:=ComboBox4.text;

k2:=dm1.avto.fieldbyname('KOD_avto').Value;

if (pic1<>'') then begin

pole1_1:='';

pole1:='';

pole1:=dm1.avto.fieldbyname('FOTO_1').AsString;

for y:=1 to length(pole1) do

if pole1[y]='.' then pole1_1:=copy(pole1,1,y-1);

st1:='';

q1:='';

for i:=length(pic1) downto 1 do

if pic1[i]<>'.' then insert(pic1[i],q1,0) else break;

st1:=ExtractFilePath(Application.Exename);

ForceDirectories(st1+'FOTO');

if dm1.avto.FieldByName('foto_1').AsString<>'' then

DeleteFile(st1+'FOTO&bsol;'+dm1.avto.FieldByName('foto_1').AsString);

if copyfileto(pchar(pic1),pchar(st1+'FOTO&bsol;'+pole1_1+ '.'+q1)) then

else begin

MessageBox(Handle,'Невозможно скопировать файл!','Внимание',MB_OK);

exit;

end;

dm1.avto.FieldByName('foto_1').AsString:=pole1_1 + '.'+q1;

end;

if (pic2<>'') then begin

pole2_2:='';

pole2:='';

pole2:=dm1.avto.fieldbyname('FOTO_2').AsString;

for t:=1 to length(pole2) do

if pole2[t]='.' then pole2_2:=copy(pole2,1,t-1);

st2:='';

q2:='';

for u:=length(pic2) downto 1 do

if pic2[u]<>'.' then insert(pic2[u],q2,0) else break;

st2:=ExtractFilePath(Application.Exename);

ForceDirectories(st2+'FOTO');

if dm1.avto.FieldByName('foto_2').AsString<>'' then

DeleteFile(st2+'FOTO&bsol;'+dm1.avto.FieldByName('foto_2').AsString);

Продолжение приложения А

if copyfileto(pchar(pic2),pchar(st2+'FOTO&bsol;'+pole2_2+ '.'+q2)) then

else begin

MessageBox(Handle,'Невозможно скопировать файл!','Внимание',MB_OK);

exit;

end;

dm1.avto.FieldByName('foto_2').AsString:=pole2_2 + '.'+q2;

end;

dm1.avto.Post;

// dm1.komplect.Post;

end;

procedure TFedit.LMDSpeedButton8Click(Sender: TObject);

begin

OpenPictureDialog1.Execute;

pic1:=OpenPictureDialog1.FileName;

if pic1<>'' then Image4.Picture.LoadFromFile(pic1)

else begin

MessageBox(Handle,'Фотография кузова не выбрана!','',MB_OK);

exit;

end;

end;

procedure TFedit.LMDSpeedButton9Click(Sender: TObject);

begin

OpenPictureDialog2.Execute;

pic2:=OpenPictureDialog2.FileName;

if pic2<>'' then Image5.Picture.LoadFromFile(pic2)

else begin

MessageBox(Handle,'Фотография салона не выбрана!','',MB_OK);

exit;

end;

end;

procedure TFedit.FormActivate(Sender: TObject);

begin

if (dm1.avto.fieldbyname('FOTO_1').Value<>'') then

Image4.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO&bsol;'+dm1.avto.fieldbyname('FOTO_1').AsString)

else MessageBox(Handle,'Фотографии кузова НЕТ!','',MB_OK);

if (dm1.avto.fieldbyname('FOTO_2').Value<>'') then

Image5.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO&bsol;'+dm1.avto.fieldbyname('FOTO_2').AsString)

else MessageBox(Handle,'Фотографии салона НЕТ!','',MB_OK);

end;

procedure TFedit.DBEdit6KeyPress(Sender: TObject; var Key: Char);

begin

case key of

'0'..'9',#8: key:=key

else key:=#0;

end;

end;

procedure TFedit.DBEdit1KeyPress(Sender: TObject; var Key: Char);

begin

Продолжение приложения А

case key of

'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key

else key:=#0;

end;

end;

procedure TFedit.DBEdit3KeyPress(Sender: TObject; var Key: Char);

begin

case key of

'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key

else key:=#0;

end;

end;

end.

А.6 Модуль заставки

unit logo;

interface

uses

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

Dialogs, ExtCtrls, StdCtrls, ComCtrls, RxGIF;

type

TFlogo = class(TForm)

Timer1: TTimer;

Image1: TImage;

ProgressBar1: TProgressBar;

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

procedure Timer1Timer(Sender: TObject);

procedure FormActivate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Flogo: TFlogo;

i : integer;

implementation

{$R *.dfm}

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

begin

if i=100 then

Action:=caFree

else

Action := caNone;

end;

procedure TFlogo.Timer1Timer(Sender: TObject);

begin

i:=i+1;

Продолжение приложения А

ProgressBar1.Position:=i;

if i=100 then begin

Timer1.Enabled:=false;

close;

end;

end;

procedure TFlogo.FormActivate(Sender: TObject);

begin

i:=0;

end;

end.

А.7 Модуль главной формы

unit main;

interface

uses

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

Dialogs, ComCtrls, Menus, Grids, DBGrids, Buttons, LMDSpeedButton,

StdCtrls, XPMan, LMDBaseGraphicButton, LMDCustomSpeedButton, LMDControl,

LMDBaseControl, DBCtrls, ImgList, LMDBaseGraphicControl,

LMDGraphicControl, LMDBaseMeter, LMDCustomProgress,

ExtCtrls, DBTables, DB, LMDLEDCustomLabel, LMDLEDLabel,IDGlobal;

type

TFmain = class(TForm)

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N11: TMenuItem;

N10: TMenuItem;

N12: TMenuItem;

N13: TMenuItem;

N14: TMenuItem;

N15: TMenuItem;

N81: TMenuItem;

N82: TMenuItem;

N16: TMenuItem;

N17: TMenuItem;

ColorDialog1: TColorDialog;

XPManifest1: TXPManifest;

ImageList1: TImageList;

Panel1: TPanel;

DBGrid2: TDBGrid;

DBGrid1: TDBGrid;

DBGrid3: TDBGrid;

Timer1: TTimer;

N7: TMenuItem;

Продолжение приложения А

N18: TMenuItem;

N19: TMenuItem;

N20: TMenuItem;

Panel9: TPanel;

Panel6: TPanel;

Image3: TImage;

Image4: TImage;

Panel5: TPanel;

DBText1: TDBText;

DBText2: TDBText;

DBText3: TDBText;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

DBCheckBox1: TDBCheckBox;

DBCheckBox2: TDBCheckBox;

DBCheckBox3: TDBCheckBox;

DBCheckBox4: TDBCheckBox;

DBCheckBox5: TDBCheckBox;

DBCheckBox6: TDBCheckBox;

DBCheckBox7: TDBCheckBox;

DBCheckBox8: TDBCheckBox;

DBMemo1: TDBMemo;

DBMemo2: TDBMemo;

Panel2: TPanel;

RadioGroup1: TRadioGroup;

Panel7: TPanel;

Panel10: TPanel;

LMDSpeedButton3: TLMDSpeedButton;

LMDSpeedButton4: TLMDSpeedButton;

LMDSpeedButton5: TLMDSpeedButton;

LMDSpeedButton6: TLMDSpeedButton;

LMDSpeedButton7: TLMDSpeedButton;

LMDSpeedButton8: TLMDSpeedButton;

Edit1: TEdit;

LMDSpeedButton1: TLMDSpeedButton;

Label7: TLabel;

Label6: TLabel;

N21: TMenuItem;

N22: TMenuItem;

N23: TMenuItem;

procedure FormShow(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N14Click(Sender: TObject);

procedure N81Click(Sender: TObject);

procedure N15Click(Sender: TObject);

procedure N82Click(Sender: TObject);

procedure N8Click(Sender: TObject);

procedure N9Click(Sender: TObject);

procedure N11Click(Sender: TObject);

procedure DBGrid1CellClick(Column: TColumn);

procedure N12Click(Sender: TObject);

procedure LMDSpeedButton1Click(Sender: TObject);

procedure LMDSpeedButton3Click(Sender: TObject);

procedure LMDSpeedButton4Click(Sender: TObject);

procedure LMDSpeedButton5Click(Sender: TObject);

procedure LMDSpeedButton6Click(Sender: TObject);

Продолжение приложения А

procedure LMDSpeedButton9Click(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure LMDSpeedButton10Click(Sender: TObject);

procedure N7Click(Sender: TObject);

procedure N19Click(Sender: TObject);

procedure LMDSpeedButton7Click(Sender: TObject);

procedure N10Click(Sender: TObject);

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

procedure FormCreate(Sender: TObject);

procedure DBGrid1TitleClick(Column: TColumn);

procedure N22Click(Sender: TObject);

procedure N23Click(Sender: TObject);

procedure N17Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Fmain: TFmain;

path : string;

implementation

uses logo, dm, vladel, sotr, add, edit, del, query, search, marka, about;

{$R *.dfm}

function gen_id(table:TTable; var name:string):integer;

var n:integer;

begin

table.First;

n:=table.FieldByName(name).asinteger;

while not table.Eof do begin

if table.FieldByName(name).Value>n then