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\'+dm1.avto.FieldByName('foto_1').AsString);
if copyfileto(pchar(pic1),pchar(st1+'FOTO\'+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\'+dm1.avto.FieldByName('foto_2').AsString);
Продолжение приложения А
if copyfileto(pchar(pic2),pchar(st2+'FOTO\'+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\'+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\'+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
n:=table.FieldByName(name).Value;
table.Next;
end;
gen_id:=n+1;
end;
procedure TFmain.FormShow(Sender: TObject);
begin
flogo.showmodal;
flogo.Free;
Image3.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_1').AsString);
Image4.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_2').AsString);
end;
procedure TFmain.N5Click(Sender: TObject);
begin
close;
end;
procedure TFmain.N14Click(Sender: TObject);
begin
Продолжение приложения А
ColorDialog1.Execute;
DBGrid1.Font.Color:=ColorDialog1.color;
end;
procedure TFmain.N81Click(Sender: TObject);
begin
DBGrid1.Font.Size:=10;
end;
procedure TFmain.N15Click(Sender: TObject);
begin
DBGrid1.Font.Size:=12;
end;
procedure TFmain.N82Click(Sender: TObject);
begin
DBGrid1.Font.Size:=8;
end;
procedure TFmain.N8Click(Sender: TObject);
begin
fvlad.showmodal;
end;
procedure TFmain.N9Click(Sender: TObject);
begin
fsotr.showmodal;
end;
procedure TFmain.N11Click(Sender: TObject);
begin
fadd.showmodal;
end;
procedure TFmain.DBGrid1CellClick(Column: TColumn);
begin
Image3.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_1').AsString);
Image4.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_2').AsString);
end;
procedure TFmain.N12Click(Sender: TObject);
begin
Fedit.showmodal;
end;
procedure TFmain.LMDSpeedButton1Click(Sender: TObject);
begin
if edit1.Text<>'' then begin
if RadioGroup1.ItemIndex=0 then
if dm1.avto.Locate('marka',edit1.Text,[loCaseInsensitive]) then
else MessageBox(Handle,'Нет автомобиля такой марки...','',MB_OK);
if RadioGroup1.ItemIndex=1 then
if dm1.avto.Locate('model',edit1.Text,[loCaseInsensitive]) then
else MessageBox(Handle,'Нет автомобиля такой модели...','',MB_OK);
if RadioGroup1.ItemIndex=2 then
Продолжение приложения А
if dm1.avto.Locate('gos_nom',edit1.Text,[loCaseInsensitive]) then
else MessageBox(Handle,'Нет автомобиля c таким номером...','',MB_OK);
end
else MessageBox(Handle,'Введите значение для поиска!','',MB_OK);
end;
procedure TFmain.LMDSpeedButton3Click(Sender: TObject);
begin
fsotr.showmodal;
end;
procedure TFmain.LMDSpeedButton4Click(Sender: TObject);
begin
fvlad.showmodal;
end;
procedure TFmain.LMDSpeedButton5Click(Sender: TObject);
begin
fadd.showmodal;
end;
procedure TFmain.LMDSpeedButton6Click(Sender: TObject);
begin
Fedit.showmodal;
end;
procedure TFmain.LMDSpeedButton9Click(Sender: TObject);
begin
//close;
Panel9.Visible := not Panel9.Visible;
end;
procedure TFmain.Timer1Timer(Sender: TObject);
begin
Label6.Caption:=TimeToStr(Time);
end;
procedure TFmain.LMDSpeedButton10Click(Sender: TObject);
begin
fquery.showmodal;
end;
procedure TFmain.N7Click(Sender: TObject);
begin
fdel.showmodal;
end;
procedure TFmain.N19Click(Sender: TObject);
begin
fquery.showmodal;
end;
procedure TFmain.LMDSpeedButton7Click(Sender: TObject);
var v:string;
k:integer;
begin
dm1.komplect.Edit;
dm1.avto.Edit;
Продолжение приложения А
v:='KOD_out';
k:=gen_id(dm1.avto_out,v);
dm1.avto_out.Append;
dm1.avto_out.FieldByName('KOD_out').Value:=k;
dm1.avto_out.FieldByName('marka_out').Value:=dm1.avto.FieldByName('marka').Value;
dm1.avto_out.FieldByName('model_out').value:=dm1.avto.FieldByName('model').value;
dm1.avto_out.FieldByName('V_out').value:=dm1.avto.FieldByName('V').value;
dm1.avto_out.FieldByName('cvet_out').value:=dm1.avto.FieldByName('cvet').value;
dm1.avto_out.FieldByName('tipkuz_out').value:=dm1.avto.FieldByName('tip_kuz').value;
dm1.avto_out.FieldByName('cena_out').value:=dm1.avto.FieldByName('cena').value;
dm1.avto_out.FieldByName('date').value:=Date;
if messagedlg('Продать?!',mtconfirmation, [mbYes, mbNo],0)=mrYes then
begin
while not dm1.komplect.Eof do dm1.komplect.Delete;
dm1.avto.Delete;
end;
DeleteFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.FieldByName('foto_1').AsString);
DeleteFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.FieldByName('foto_2').AsString);
//dm1.avto.Post;
//dm1.komplect.Post;
dm1.avto_out.Post;
end;
procedure TFmain.N10Click(Sender: TObject);
begin
LMDSpeedButton7Click(Sender);
end;
procedure TFmain.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
Image3.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_1').AsString);
Image4.Picture.LoadFromFile(ExtractFilePath(Application.Exename)+'FOTO\'+dm1.avto.fieldbyname('FOTO_2').AsString);
end;
procedure TFmain.FormCreate(Sender: TObject);
begin
path:=Application.ExeName;
end;
Продолжение приложения А
procedure TFmain.DBGrid1TitleClick(Column: TColumn);
begin
if Column.Title.Caption='Марка' then
dm1.avto.IndexName:='marka';
if Column.Title.Caption='Объём' then
dm1.avto.IndexName:='V';
if Column.Title.Caption='Тип кузова' then
dm1.avto.IndexName:='tip_kuz';
end;
procedure TFmain.N22Click(Sender: TObject);
begin
FSearch.showmodal;
end;
procedure TFmain.N23Click(Sender: TObject);
begin
FMarka.Showmodal;
end;
procedure TFmain.N17Click(Sender: TObject);
begin
Fabout.ShowModal;
end;
end.
А.8 Модуль формы поиска
unit search;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrls, StdCtrls, Mask, glLabel, ExtCtrls, Grids, DBGrids,
LMDCustomButton, LMDButton, DB, DBTables, RXDBCtrl;
type
TFSearch = class(TForm)
Panel3: TPanel;
glLabel2: TglLabel;
Label8: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
ComboBox1: TComboBox;
Panel4: TPanel;
glLabel3: TglLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
Продолжение приложения А
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Panel1: TPanel;
DBLookupComboBox1: TDBLookupComboBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
CheckBox10: TCheckBox;
CheckBox11: TCheckBox;
CheckBox12: TCheckBox;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
CheckBox13: TCheckBox;
CheckBox14: TCheckBox;
CheckBox15: TCheckBox;
CheckBox16: TCheckBox;
CheckBox17: TCheckBox;
Query1: TQuery;
LMDButton1: TLMDButton;
DataSource1: TDataSource;
RxDBGrid1: TRxDBGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CheckBox9Click(Sender: TObject);
procedure CheckBox10Click(Sender: TObject);
procedure CheckBox11Click(Sender: TObject);
procedure CheckBox12Click(Sender: TObject);
procedure CheckBox4Click(Sender: TObject);
procedure CheckBox5Click(Sender: TObject);
procedure CheckBox6Click(Sender: TObject);
procedure CheckBox7Click(Sender: TObject);
procedure CheckBox8Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure LMDButton1Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FSearch: TFSearch;
implementation
uses dm, edit;
{$R *.dfm}
Продолжение приложения А
procedure TFSearch.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TFSearch.CheckBox9Click(Sender: TObject);
begin
Label8.Enabled:=not Label8.Enabled;
DBLookupComboBox1.Enabled:=not DBLookupComboBox1.Enabled;
end;
procedure TFSearch.CheckBox10Click(Sender: TObject);
begin
Label12.Enabled:=not Label12.Enabled;
ComboBox1.Enabled:=not ComboBox1.Enabled;
end;
procedure TFSearch.CheckBox11Click(Sender: TObject);
begin
Label14.Enabled:=not Label14.Enabled;
Edit1.Enabled:=not Edit1.Enabled;
end;
procedure TFSearch.CheckBox12Click(Sender: TObject);
begin
Label13.Enabled:=not Label13.Enabled;
Edit2.Enabled:=not Edit2.Enabled;
end;
procedure TFSearch.CheckBox4Click(Sender: TObject);
begin
Label1.Enabled:=not Label1.Enabled;
CheckBox17.Enabled:=not CheckBox17.Enabled;
end;
procedure TFSearch.CheckBox5Click(Sender: TObject);
begin
Label2.Enabled:=not Label2.Enabled;
CheckBox16.Enabled:=not CheckBox16.Enabled;
end;
procedure TFSearch.CheckBox6Click(Sender: TObject);
begin
Label3.Enabled:=not Label3.Enabled;
CheckBox15.Enabled:=not CheckBox15.Enabled;
end;
procedure TFSearch.CheckBox7Click(Sender: TObject);
begin
Label4.Enabled:=not Label4.Enabled;
CheckBox14.Enabled:=not CheckBox14.Enabled;
end;
procedure TFSearch.CheckBox8Click(Sender: TObject);
begin
Label5.Enabled:=not Label5.Enabled;
CheckBox13.Enabled:=not CheckBox13.Enabled;
end;
Продолжение приложения А
procedure TFSearch.CheckBox1Click(Sender: TObject);
begin
Label15.Enabled:=not Label15.Enabled;
ComboBox2.Enabled:=not ComboBox2.Enabled;
end;
procedure TFSearch.CheckBox2Click(Sender: TObject);
begin
Label16.Enabled:=not Label16.Enabled;
ComboBox3.Enabled:=not ComboBox3.Enabled;
end;
procedure TFSearch.CheckBox3Click(Sender: TObject);
begin
Label17.Enabled:=not Label17.Enabled;
ComboBox4.Enabled:=not ComboBox4.Enabled;
end;
function BoolToStr(value : boolean):string;
begin
if value then result:='true' else result:='false';
end;
procedure TFSearch.LMDButton1Click(Sender: TObject);
begin
Query1.Close;
Query1.SQL.Clear;
try
Query1.Sql.Add('select a.kod_avto, m.marka, a.model, a.cvet, a.tip_kuz, a.cena, a.v, k.korobka,k.privod ');
Query1.SQL.Add('from avto a, komplect k, marka m ');
Query1.SQL.Add('where ');
if checkBox9.Checked then Query1.SQL.Add('a.marka = '+ Inttostr(DBLookupComboBox1.keyvalue)+' and');
if checkBox10.Checked then Query1.SQL.Add('a.tip_kuz="'+ComboBox1.Text+'" and ');
if checkBox11.Checked then Query1.SQL.Add('a.v<='+Edit1.Text+' and ');
if checkBox12.Checked then Query1.SQL.Add('a.cena<='+Edit2.Text+' and ');
if checkBox4.Checked then Query1.SQL.Add('k.elect_pak = '+BoolToStr(CheckBox17.Checked)+' and ');
if checkBox5.Checked then Query1.SQL.Add('k.kondic = '+BoolToStr(CheckBox16.Checked)+' and ');
if checkBox6.Checked then Query1.SQL.Add('k.music = '+BoolToStr(CheckBox15.Checked)+' and ');
if checkBox7.Checked then Query1.SQL.Add('k.gur = '+BoolToStr(CheckBox14.Checked)+' and ');
if checkBox8.Checked then Query1.SQL.Add('k.abs = '+BoolToStr(CheckBox13.Checked)+' and ');
if checkBox1.Checked then Query1.SQL.Add('k.koleso = "'+ComboBox2.Text+'" and ');
if checkBox2.Checked then Query1.SQL.Add('k.korobka = "'+ComboBox3.Text+'" and ');
if checkBox3.Checked then Query1.SQL.Add('k.privod = "'+ComboBox4.Text+'" and ');
Query1.SQL.Add('a.marka=m.id_marka and a.kod_avto=k.kod_avto');
Query1.Open;
except
Продолжение приложения А
MessageDlg('Введены не все данные',mtWarning,[mbOk],0);
end;
end;
procedure TFSearch.DBGrid1CellClick(Column: TColumn);
begin
if Query1.Active then begin
if dm1.avto.Locate('kod_avto',Query1.FieldByName('kod_avto').AsInteger,[loCaseInsensitive])
then fedit.showmodal;
end;
end;
end.
А.9 Модуль формы менеджеров
unit sotr;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ExtCtrls, LMDControl, LMDBaseControl,
LMDBaseGraphicButton, DB, LMDCustomSpeedButton, LMDSpeedButton, StdCtrls,
Mask, DBTables, DBCtrls, ImgList;
type
TFsotr = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
Panel2: TPanel;
pedit: TPanel;
Panel4: TPanel;
RadioGroup1: TRadioGroup;
Edit1: TEdit;
LMDSpeedButton1: TLMDSpeedButton;
Image1: TImage;
LMDSpeedButton2: TLMDSpeedButton;
LMDSpeedButton3: TLMDSpeedButton;
LMDSpeedButton4: TLMDSpeedButton;
LMDSpeedButton5: TLMDSpeedButton;
pnew: TPanel;
Image2: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
LMDSpeedButton6: TLMDSpeedButton;
Продолжение приложения А
LMDSpeedButton7: TLMDSpeedButton;
LMDSpeedButton8: TLMDSpeedButton;
LMDSpeedButton9: TLMDSpeedButton;
Image3: TImage;
Image4: TImage;
procedure LMDSpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure LMDSpeedButton4Click(Sender: TObject);
procedure LMDSpeedButton5Click(Sender: TObject);
procedure LMDSpeedButton2Click(Sender: TObject);
procedure LMDSpeedButton7Click(Sender: TObject);
procedure LMDSpeedButton9Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure LMDSpeedButton8Click(Sender: TObject);
procedure LMDSpeedButton6Click(Sender: TObject);
procedure LMDSpeedButton3Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit4KeyPress(Sender: TObject; var Key: Char);
procedure Edit5KeyPress(Sender: TObject; var Key: Char);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure Edit7KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Fsotr: TFsotr;
implementation
uses dm;
{$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
n:=table.FieldByName(name).Value;
table.Next;
end;
gen_id:=n+1;
end;
procedure TFsotr.LMDSpeedButton1Click(Sender: TObject);
begin
if edit1.Text<>'' then begin
if RadioGroup1.ItemIndex=0 then
if dm1.sot.Locate('FAM',edit1.Text,[loCaseInsensitive]) then
else MessageBox(Handle,'Нет записи с такой фамилией...','',MB_OK);
if RadioGroup1.ItemIndex=1 then
if dm1.sot.Locate('NAME',edit1.Text,[loCaseInsensitive]) then
Продолжение приложения А
else MessageBox(Handle,'Нет записи с таким именем...','',MB_OK);
end
else MessageBox(Handle,'Введите значение для поиска!','',MB_OK);
end;
procedure TFsotr.FormCreate(Sender: TObject);
begin
dm1.sot.IndexName:='FAM';
RadioGroup1.ItemIndex:=-1;
end;
procedure TFsotr.LMDSpeedButton4Click(Sender: TObject);
begin
if messagedlg('Удалить?!',mtconfirmation, [mbYes, mbNo],0)=mrYes then begin
if dm1.sot.State=dsbrowse then dm1.sot.delete;
end;
end;
procedure TFsotr.LMDSpeedButton5Click(Sender: TObject);
begin
//dm1.sot.Edit;
//dm1.sot.Append;
pedit.Visible:=true;
Edit7.Text:=dm1.sot.fieldbyname('fam').Value;
Edit6.Text:=dm1.sot.fieldbyname('name').Value;
Edit5.Text:=dm1.sot.fieldbyname('oth').Value;
end;
procedure TFsotr.LMDSpeedButton2Click(Sender: TObject);
begin
pnew.Visible:=true;
end;
procedure TFsotr.LMDSpeedButton7Click(Sender: TObject);
begin
pedit.Visible:=false;
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
dm1.sot.Cancel;
end;
procedure TFsotr.LMDSpeedButton9Click(Sender: TObject);
begin
pnew.Visible:=false;
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
dm1.sot.Cancel;
end;
procedure TFsotr.FormActivate(Sender: TObject);
begin
pedit.Visible:=true;
pnew.Visible:=true;
pedit.Visible:=false;
pnew.Visible:=false;
end;
Продолжение приложения А
procedure TFsotr.LMDSpeedButton8Click(Sender: TObject);
var v:string;
k:integer;
begin
if (Edit2.Text='') or (Edit3.Text='') or (Edit4.Text='') then begin
MessageBox(Handle,'Возможно некоторые поля не заполнены!','Внимание',MB_OK);
exit;
end
else begin
v:='KOD_sot';
k:=gen_id(dm1.sot,v);
dm1.sot.Insert;
dm1.sot.FieldByName('KOD_sot').Value:=k;
dm1.sot.FieldByName('FAM').Value:=edit2.text;
dm1.sot.FieldByName('NAME').value:=edit3.Text;
dm1.sot.FieldByName('OTH').value:=edit4.text;
dm1.sot.Post;
pnew.Visible:=false;
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
end;
end;
procedure TFsotr.LMDSpeedButton6Click(Sender: TObject);
begin
if (Edit5.Text='') or (Edit6.Text='') or (Edit7.Text='') then begin
MessageBox(Handle,'Возможно некоторые поля не заполнены!','Внимание',MB_OK);
exit;
end
else begin
dm1.sot.Edit;
dm1.sot.FieldByName('FAM').Value:=edit7.text;
dm1.sot.FieldByName('NAME').value:=edit6.Text;
dm1.sot.FieldByName('OTH').value:=edit5.text;
dm1.sot.Post;
pedit.Visible:=false;
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
end;
end;
procedure TFsotr.LMDSpeedButton3Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
close;
end;
procedure TFsotr.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
case key of
Продолжение приложения А
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
procedure TFsotr.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
procedure TFsotr.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
procedure TFsotr.Edit5KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
procedure TFsotr.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
procedure TFsotr.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'A'..'Z','a'..'z','а'..'я','А'..'Я',#8: key:=key
else key:=#0;
end;
end;
end.
Дата: 2019-05-28, просмотров: 175.