home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
chap24
/
music
/
search.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-20
|
5KB
|
187 lines
unit Search;
{ Program copyright (c) 1995 by Charles Calvert }
{ Project Name: MUSIC }
{
The local interbase provides what pdox/db files can't:
1) Full native ANSI SQL support
2) Fast joins
3) Referential integrity
4) Seamless scalability/Interoperability with larger servers
5) Integrated data dictionary
6) Multiversioning
7) Stored procedures
8) Multidimensional arrays
9) Unlimited blob sizes
10) Descending indices
11) High-performance optimizer with sparse bitmap technology
12) Transaction support with immediate rollback/commit
}
interface
uses
WinTypes, WinProcs, Classes,
Graphics, Forms, Controls,
Buttons, StdCtrls, DB,
DBTables, Grids, DBGrids,
ExtCtrls, SrchStr, Messages,
Editor;
const
wm_Switch = wm_User + 0;
type
TNextMove = (nmShowSearch, nmShowEdit, nmClose);
TSearcher = class(TForm)
Bevel1: TBevel;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Query1: TQuery;
SubCat: TGroupBox;
rbJJ: TRadioButton;
rbRR: TRadioButton;
rbSS: TRadioButton;
rbPC: TRadioButton;
rbCS: TRadioButton;
rbFJ: TRadioButton;
rbCM: TRadioButton;
rbFB: TRadioButton;
rbNA: TRadioButton;
rbRB: TRadioButton;
MainCat: TGroupBox;
rbJ: TRadioButton;
rbP: TRadioButton;
rbR: TRadioButton;
rbF: TRadioButton;
rbC: TRadioButton;
rbG: TRadioButton;
rbE: TRadioButton;
rbB: TRadioButton;
Ok: TBitBtn;
BSearch: TBitBtn;
Switch: TBitBtn;
NSearch: TBitBtn;
CSearch: TBitBtn;
procedure rbJClick(Sender: TObject);
procedure rbJJClick(Sender: TObject);
procedure BSearchClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NSearchClick(Sender: TObject);
procedure SwitchClick(Sender: TObject);
procedure CSearchClick(Sender: TObject);
private
FMusicType: String;
FSubType: String;
procedure SetQueryType(QType: TQueryType);
procedure wmSwitch(var Msg: TMessage); message wm_Switch;
end;
var
Searcher: TSearcher;
implementation
{$R *.DFM}
procedure TSearcher.rbJClick(Sender: TObject);
begin
if Sender = rbJ then FMusicType := 'J'
else if Sender = rbP then FMusicType := 'P'
else if Sender = rbR then FMusicType := 'R'
else if Sender = rbF then FMusicType := 'F'
else if Sender = rbC then FMusicType := 'C'
else if Sender = rbE then FMusicType := 'E'
else if Sender = rbB then FMusicType := 'B'
else if Sender = rbG then FMusicType := 'G';
end;
procedure TSearcher.rbJJClick(Sender: TObject);
begin
if Sender = rbJJ then FSubType := 'JJ'
else if Sender = rbRR then FSubType := 'RR'
else if Sender = rbSS then FSubType := 'SS'
else if Sender = rbPC then FSubType := 'PC'
else if Sender = rbCS then FSubType := 'CS'
else if Sender = rbFJ then FSubType := 'FJ'
else if Sender = rbCM then FSubType := 'CM'
else if Sender = rbNA then FSubType := 'NA'
else if Sender = rbRB then FSubType := 'RB'
else if Sender = rbFB then FSubType := 'FB';
end;
procedure TSearcher.SetQueryType(QType: TQueryType);
var
S: string;
begin
case QType of
qtFirst: S := 'select * from MusicList where First like :First';
qtLastGroup: S := 'select * from MusicList where LastGroup like :LastGroup';
qtAlbum: S := 'select * from MusicList where Album like :Album';
qtStockNo: S := 'select * from MusicList where StockNo like :StockNo';
end;
Query1.SQL.Clear;
Query1.SQL.Add(S);
end;
procedure TSearcher.BSearchClick(Sender: TObject);
begin
Query1.Close;
SetQueryType(qtStockNo);
Query1.Params[0].AsString := FMusicType + '-' + FSubType + '%';
Query1.Open;
end;
procedure TSearcher.FormCreate(Sender: TObject);
begin
rbJ.Checked := True;
rbJJ.Checked := True;
FMusicType := 'J';
FSubType := 'JJ';
end;
procedure TSearcher.NSearchClick(Sender: TObject);
var
S: string;
QType: TQueryType;
begin
if SearchStr.GetSearchStr(QType, S) then begin
Query1.Close;
SetQueryType(QType);
Query1.Params[0].AsString := S + '%';
Query1.Open;
end;
end;
procedure TSearcher.SwitchClick(Sender: TObject);
begin
Query1.Close;
Hide;
PostMessage(Handle, wm_Switch, (Sender as TBitBtn).Tag, 0);
end;
procedure TSearcher.wmSwitch(var Msg: TMessage);
begin
case TNextMove(Msg.WParam) of
nmShowSearch: Searcher.Show;
nmShowEdit: begin
EditMusic.Table1.Open;
EditMusic.Show;
end;
nmClose: Searcher.Close;
end;
end;
procedure TSearcher.CSearchClick(Sender: TObject);
begin
Query1.Close;
SetQueryType(qtStockNo);
Query1.Params[0].AsString := FMusicType + '%';
Query1.Open;
end;
end.