-
Notifications
You must be signed in to change notification settings - Fork 2
/
ReqLyrUnit.pas
executable file
·780 lines (707 loc) · 20.5 KB
/
ReqLyrUnit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
unit ReqLyrUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, DB, ADODB, ExtCtrls, DBCtrls, Grids;
type
TReqLyrForm = class(TForm)
BandEdit: TEdit;
ReqLyrMemo: TMemo;
BandBox: TCheckBox;
AlbumBox: TCheckBox;
AlbumEdit: TEdit;
LyrBox: TCheckBox;
LyrEdit: TRichEdit;
SongsBox: TComboBox;
sb: TStatusBar;
Button1: TButton;
ReqBtn: TButton;
Button3: TButton;
MusCon: TADOConnection;
musds: TADODataSet;
SongBox: TCheckBox;
SongTitleEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
tBandEdit: TEdit;
tAlbumEdit: TEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
ruchars: TStringGrid;
enchars: TStringGrid;
Label4: TLabel;
Label5: TLabel;
TextMemo: TMemo;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
SongsLBox: TComboBox;
BandsLBox: TComboBox;
AlbumsLBox: TComboBox;
procedure LyrBoxClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ReqBtnClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure SongBoxClick(Sender: TObject);
procedure AlbumBoxClick(Sender: TObject);
procedure BandBoxClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure SongsBoxSelect(Sender: TObject);
procedure ReqBtnKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ReqBtnKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure rucharsSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure encharsSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure BandsLBoxSelect(Sender: TObject);
procedure AlbumsLBoxSelect(Sender: TObject);
procedure SongsLBoxSelect(Sender: TObject);
private
{ Private declarations }
procedure InitDB;
procedure DoRequest;
public
{ Public declarations }
procedure ClearInput;
procedure GetBands;
procedure GetAlbums;
procedure GetSongs;
end;
const
{$IFDEF _DEMO_}
basefile = 'demo.mdb';
{$ELSE}
basefile = 'music.mdb';
{$ENDIF}
var
basepath,dbpath : string;
Curln,CurLang,CurChar,CurBandName,CurBand,CurAlbum,CurSong : string;
reqs : boolean;
shifted : boolean = false;
const RuCh = '*?Z#ÀÁÂÃÄÅÆÇÈÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÝÞß';
EnCh = '*#ABCDEFGHIJKLMNOPQRSTUVWXYZ';
procedure RequestLyrics(BandName,AlbumName,SongTitle : string);
implementation uses main;
function LZs(s : string; n : integer; ch : char) : string;
begin
Result := s;
while length(Result) < n do Result := ch+Result;
end;
function LZ(i,n : integer; ch : char) : string;
begin
Result := inttostr(i);
while length(Result) < n do Result := ch+Result;
end;
procedure RequestLyrics(BandName,AlbumName,SongTitle : string);
var f : boolean;
begin
f := false;
with TReqLyrForm.Create(MainForm) do
begin
if BandName <> '' then
begin
BandEdit.Text := BandName;
// BandCombo.Text := BandName;
BandBox.Checked := true;
f := true;
end;
if AlbumName <> '' then
begin
AlbumEdit.Text := AlbumName;
AlbumBox.Checked := true;
f := true;
end;
if SongTitle <> '' then
begin
SongTitleEdit.Text := SongTitle;
SongBox.Checked := true;
f := true;
end;
Show;
if f then ReqBtn.Click;
end;
end;
{$R *.dfm}
procedure TReqLyrForm.LyrBoxClick(Sender: TObject);
begin
ReqLyrMemo.Visible := LyrBox.Checked;
end;
procedure TReqLyrForm.FormCreate(Sender: TObject);
var i : integer;
begin
shifted := false;
BandsLBox.Visible := false;
AlbumsLBox.Visible := false;
SongsLBox.Visible := false;
TextMemo.Visible := false;
PageControl1.ActivePageIndex := 0;
ruchars.BorderStyle := bsNone;
enchars.BorderStyle := bsNone;
ClearInput;
for i := 0 to length(ruch)-1 do
begin
ruchars.Cells[i mod 7,i div 7] := ruch[i+1];
end;
for i := 0 to length(ench)-1 do
begin
enchars.Cells[i mod 7,i div 7] := ench[i+1];
end;
InitDB;
end;
procedure TReqLyrForm.GetAlbums;
var s,cmd : string;
num,i : integer;
begin
cmd := 'SELECT * FROM Albums ';
// cmd := cmd + CurLang;
cmd := cmd + ' WHERE BandID LIKE '''+CurBand+'''';
cmd := cmd + ' ORDER BY Year,AlbumName';
if musds.Active then musds.Close;
musds.CommandText := cmd;
musds.Open;
with AlbumsLBox.Items do
begin
Clear;
Add('');
num := musds.RecordCount;
for i := 1 to num do
begin
s := musds.FieldByName('Year').AsString;
if s <> '' then s := '('+s+') ';
s := s + musds.FieldByName('AlbumName').AsString+' ('+musds.FieldByName('ID').AsString+')';
Add(s);
musds.Next;
end;
AlbumsLBox.ItemIndex := 0;
end;
musds.Close;
end;
procedure TReqLyrForm.GetBands;
var cmd : string;
num,i : integer;
begin
cmd := 'SELECT * FROM Bands ';
if CurChar = '?' then
begin
cmd := cmd + 'WHERE BandName = ''?''';
{if LyrBandsBox.Checked then }cmd := cmd + ' AND (NumLyr > 0) ';
end else
begin
cmd := cmd + CurLang;
{if LyrBandsBox.Checked then }cmd := cmd + ' AND (NumLyr > 0) ';
if CurChar <> '*' then
begin
cmd := cmd + ' AND (';
if CurChar = '#' then
begin
cmd := cmd + ' (BandName BETWEEN ''0%'' AND ''9%'') )';
end else
if (CurChar = 'A')and(curln = 'ru') then // A .. Z
begin
cmd := cmd + ' ( (BandName BETWEEN ''A%'' AND ''Z%'') OR (BandName LIKE ''Z%'') ) )';
end else
(*
'*AZ#þàá ö ä å ôãõ é êëìíîïÿðñòóæâü ù ÷ú';
*)
if CurChar = 'ö' then
begin
cmd := cmd + 'BandName LIKE ''ö_%'')';
end else
if CurChar = 'å' then
begin
cmd := cmd + 'BandName LIKE ''å_%'')';
end else
if CurChar = 'é' then
begin
cmd := cmd + 'BandName LIKE ''é_%'')';
end else
if CurChar = 'ù' then
begin
cmd := cmd + 'BandName LIKE ''ù_%'')';
end else
begin
cmd := cmd + 'BandName LIKE '''+CurChar+'%'')';
end;
end else
begin
// cmd := cmd + ' WHERE BandName = ''%''';
end;
// cmd := 'SELECT * FROM Bands'#13+'WHERE BandName LIKE ''H%''';
end;
cmd := cmd + ' ORDER BY BandName';
if musds.Active then musds.Close;
musds.CommandText := cmd;
musds.Open;
with BandsLBox.Items do
begin
Clear;
// musds.First;
num := musds.RecordCount;
for i := 1 to num do
begin
Add(musds.FieldByName('BandName').AsString + ' ('+musds.FieldByName('ID').AsString+')');
musds.Next;
end;
BandsLBox.ItemIndex := 0;
end;
musds.Close;
end;
procedure TReqLyrForm.InitDB;
begin
basepath := extractfilepath(application.ExeName);
dbpath := basepath+'db\';
if not fileexists(dbpath+basefile) then
begin
dbpath := '\db\';
if not fileexists(dbpath+basefile) then dbpath := '';
end;
MusCon.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+dbpath+basefile+';Persist Security Info=False';
musds.CommandType := cmdText;
musds.Connection := MusCon;
end;
procedure TReqLyrForm.DoRequest;
var rbnd,ralb,rtit,rlyr,albumid,cmd,bandid,s : string;
i,num : integer;
fl,found : boolean;
begin
if reqs then exit;
reqs := true;
with lyredit.Lines do
begin
Application.ProcessMessages;
found := false;
if BandBox.Checked then rbnd := trim(BandEdit.Text) else rbnd := '';
// if BandBox.Checked then rbnd := trim(BandCombo.Text) else rbnd := '';
if AlbumBox.Checked then ralb := trim(AlbumEdit.Text) else ralb := '';
if SongBox.Checked then rtit := trim(SongTitleEdit.Text) else rtit := '';
if LyrBox.Checked then rlyr := (ReqLyrMemo.Text) else rlyr := '';
albumid := '';
bandid := '';
tBandEdit.Visible := false;
tAlbumEdit.Visible := false;
Label1.Visible := false;
Label2.Visible := false;
Label3.Visible := false;
if shifted then LyrEdit.Visible := true else LyrEdit.Visible := false;
SongsBox.Visible := false;
LyrEdit.Text := '';
SongsBox.Items.Clear;
SongsBox.Text := '';
if shifted then LyrEdit.Lines.Add('Çàïðîñ (Band = "'+rbnd+'" Album = "'+ralb+'" Song = "'+rtit+'" Lyr = "'+rlyr+'"');
sb.Panels[0].Text := 'Connecting to Music DB...';
if shifted then LyrEdit.Lines.Add('Connecting to Music DB...');
Application.ProcessMessages;
if not MusCon.Connected then MusCon.Open;
if MusCon.Connected then
begin
if shifted then LyrEdit.Lines.Add('ok');
sb.Panels[0].Text := 'ok';
Application.ProcessMessages;
if musds.Active then musds.Close;
if rbnd <> '' then
begin
if shifted then LyrEdit.Lines.Add('Looking up BandID...');
sb.Panels[0].Text := 'Looking up BandID...';
Application.ProcessMessages;
cmd := 'SELECT * FROM Bands WHERE BandName LIKE '''+MakeSQLStr(rbnd)+'''';
if shifted then LyrEdit.Lines.Add('SQLcmd: "'+cmd+'"');
musds.CommandType := cmdText;
musds.CommandText := cmd;
musds.Connection := MusCon;
musds.Open;
Application.ProcessMessages;
num := musds.RecordCount;
if num > 0 then
begin
bandid := musds.FieldByName('ID').AsString;
sb.Panels[0].Text := 'ok ('+bandid+')';
if shifted then LyrEdit.Lines.Add('ok BandID: "'+bandid+'"');
Application.ProcessMessages;
end else
begin
if shifted then LyrEdit.Lines.Add('failed');
sb.Panels[0].Text := 'failed';
// exit;
bandid := '';
bandbox.Checked := false;
albumid := '';
albumbox.Checked := false;
end;
Application.ProcessMessages;
musds.Close;
end;
if (ralb <> '')and(bandid <> '') then
begin
sb.Panels[0].Text := 'Looking up AlbumID...';
if shifted then LyrEdit.Lines.Add('Looking up AlbumID...');
Application.ProcessMessages;
cmd := 'SELECT * FROM Albums WHERE BandID LIKE '''+bandid+''' AND AlbumName LIKE '''+makesqlstr(ralb)+'''';
if shifted then LyrEdit.Lines.Add('SQLcmd: "'+cmd+'"');
musds.CommandText := cmd;
musds.Open;
num := musds.RecordCount;
if num > 0 then
begin
albumid := musds.FieldByName('ID').AsString;
if shifted then LyrEdit.Lines.Add('ok ('+albumid+')');
sb.Panels[0].Text := 'ok ('+albumid+')';
Application.ProcessMessages;
end else
begin
if shifted then LyrEdit.Lines.Add('failed');
sb.Panels[0].Text := 'failed';
// exit;
albumid := '';
albumbox.Checked := false;
end;
Application.ProcessMessages;
musds.Close;
end;
sb.Panels[0].Text := 'Looking up Lyrics...';
if shifted then LyrEdit.Lines.Add('Looking up Lyrics...');
Application.ProcessMessages;
cmd := 'SELECT * FROM Lyrics';
// cmd := 'SELECT DISTINCT * FROM Lyrics';
if (bandid <> '')or(albumid <> '')or(rtit <> '')or(rlyr <> '') then
begin
fl := false;
cmd := cmd + ' WHERE ';
// BandID LIKE '''+bandid+''' AND AlbumID LIKE '''+albumid+''' AND SongName LIKE '''+makesqlstr(rtit)+'''';
if bandid <> '' then
begin
cmd := cmd + ' BandID LIKE '''+BandID+''' ';
fl := true;
end;
if albumid <> '' then
begin
if fl then cmd := cmd + ' AND ' else fl := true;
cmd := cmd + ' AlbumID LIKE '''+AlbumID+''' ';
end;
if rtit <> '' then
begin
if fl then cmd := cmd + ' AND ' else fl := true;
cmd := cmd + ' SongName LIKE '''+MakeSQLstr(rtit)+''' ';
end;
if rlyr <> '' then
begin
if fl then cmd := cmd + ' AND ' {else fl := true};
cmd := cmd + ' Text LIKE ''%'+MakeSQLstr(rlyr)+'%'' ';
end;
end;
if shifted then LyrEdit.Lines.Add('SQLcmd: "'+cmd+'"');
musds.CommandText := cmd;
musds.Open;
Application.ProcessMessages;
num := musds.RecordCount;
if num > 0 then
begin
found := true;
if shifted then LyrEdit.Lines.Add('ok, found '+inttostr(num)+' song(s)');
sb.Panels[0].Text := 'ok, found '+inttostr(num)+' song(s)';
Application.ProcessMessages;
end else
begin
if shifted then LyrEdit.Lines.Add('failed');
end;
Application.ProcessMessages;
if found then
begin
// num := musds.RecordCount;
for i := 1 to num do
begin
s := musds.FieldByName('SongName').AsString;
s := s + ' ('+musds.FieldByName('ID').AsString+')';
SongsBox.Items.Add(s);
musds.Next;
end;
LyrEdit.Visible := false;
SongsBox.Visible := true;
Application.ProcessMessages;
SongsBox.ItemIndex := 0;
SongsBox.OnSelect(Self);
end else
begin
sb.Panels[0].Text := 'no songs found :*(';
if shifted then LyrEdit.Lines.Add('no songs found :*(');
Application.ProcessMessages;
end;
musds.Close;
Application.ProcessMessages;
end else
begin
if shifted then LyrEdit.Lines.Add('Error!');
sb.Panels[0].Text := 'Error!';
end;
end;
end;
procedure TReqLyrForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MusCon.Connected then MusCon.Open;
Action := caFree;
end;
procedure TReqLyrForm.ReqBtnClick(Sender: TObject);
begin
DoRequest;
reqs := false;
end;
procedure TReqLyrForm.Button1Click(Sender: TObject);
begin
if reqs then exit;
ClearInput;
end;
procedure TReqLyrForm.ClearInput;
begin
cursong := '';
LyrEdit.Text := '';
LyrEdit.Visible := false;
SongsBox.Items.Clear;
SongsBox.Visible := false;
ReqLyrMemo.Text := '';
ReqLyrMemo.Visible := false;
LyrBox.Checked := false;
SongTitleEdit.Text := '';
SongTitleEdit.Visible := false;
SongBox.Checked := false;
AlbumBox.Checked := false;
AlbumEdit.Text := '';
AlbumEdit.Visible := false;
BandBox.Checked := false;
BandEdit.Text := '';
// BandCombo.Text := '';
BandEdit.Visible := false;
// BandCombo.Visible := false;
tBandEdit.Text := '';
tAlbumEdit.Text := '';
tBandEdit.Visible := false;
tAlbumEdit.Visible := false;
Label1.Visible := false;
Label2.Visible := false;
Label3.Visible := false;
end;
procedure TReqLyrForm.SongBoxClick(Sender: TObject);
begin
SongTitleEdit.Visible := SongBox.Checked;
end;
procedure TReqLyrForm.AlbumBoxClick(Sender: TObject);
begin
AlbumEdit.Visible := AlbumBox.Checked;
end;
procedure TReqLyrForm.BandBoxClick(Sender: TObject);
begin
BandEdit.Visible := BandBox.Checked;
// BandCombo.Visible := BandBox.Checked;
end;
procedure TReqLyrForm.Button3Click(Sender: TObject);
begin
if reqs then exit;
Close;
end;
procedure TReqLyrForm.SongsBoxSelect(Sender: TObject);
var i : integer;
ta,tb,cmd : string;
begin
tBandEdit.Text := '';
tAlbumEdit.Text := '';
CurSong := SongsBox.Text;
i := length(CurSong);
while (i > 0)and(CurSong[i] <> '(') do dec(i);
CurSong := Copy(CurSong,i+1,length(CurSong));
CurSong := Copy(CurSong,1,pos(')',CurSong)-1);
cmd := 'SELECT * FROM Lyrics ';
cmd := cmd + ' WHERE (ID LIKE '''+CurSong+''')';
// cmd := cmd + ' ORDER BY AlbumID,SongName';
if musds.Active then musds.Close;
musds.CommandType := cmdText;
musds.CommandText := cmd;
musds.Connection := MusCon;
musds.Open;
if musds.RecordCount > 0 then
begin
LyrEdit.Lines.Clear;
LyrEdit.Text := musds.FieldByName('Text').AsString;
tb := musds.FieldByName('BandID').AsString;
ta := musds.FieldByName('AlbumID').AsString;
end;
musds.Close;
cmd := 'SELECT * FROM Albums WHERE ID LIKE '''+ta+'''';
musds.CommandText := cmd;
musds.Open;
if musds.RecordCount > 0 then
begin
ta := musds.FieldByName('AlbumName').AsString;
end;
musds.Close;
tAlbumEdit.Text := ta;
Label1.Visible := true;
tAlbumEdit.Visible := true;
Application.ProcessMessages;
cmd := 'SELECT * FROM Bands WHERE ID LIKE '''+tb+'''';
musds.CommandText := cmd;
musds.Open;
if musds.RecordCount > 0 then
begin
tb := musds.FieldByName('BandName').AsString;
end;
musds.Close;
tBandEdit.Text := tb;
tBandEdit.Visible := true;
Label2.Visible := true;
LyrEdit.Visible := true;
Label3.Visible := true;
Application.ProcessMessages;
end;
procedure TReqLyrForm.ReqBtnKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_CONTROL then shifted := true;
end;
procedure TReqLyrForm.ReqBtnKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
shifted := false;
end;
procedure TReqLyrForm.rucharsSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
curln := 'ru';
CurLang := ' WHERE ( Lang LIKE ''ru'' ) ';
CurChar := trim(ruchars.Cells[acol,arow]);
if (CurChar = '') then CurChar := '*' else
begin
CurChar := CurChar[1];
if CurChar[1] = ' ' then CurChar := '*';
end;
GetBands;
enchars.BorderStyle := bsNone;
ruchars.BorderStyle := bsSingle;
BandsLBox.Visible := true;
AlbumsLBox.Visible := false;
SongsLBox.Visible := false;
TextMemo.Visible := false;
end;
procedure TReqLyrForm.encharsSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
curln := 'fo';
CurLang := ' WHERE ( (Lang NOT LIKE ''ru'') OR (Lang IS NULL) ) ';
CurChar := trim(enchars.Cells[acol,arow]);
if (CurChar = '') then CurChar := '*' else
begin
CurChar := CurChar[1];
if CurChar[1] = ' ' then CurChar := '*';
end;
GetBands;
ruchars.BorderStyle := bsNone;
enchars.BorderStyle := bsSingle;
BandsLBox.Visible := true;
AlbumsLBox.Visible := false;
SongsLBox.Visible := false;
TextMemo.Visible := false;
end;
procedure TReqLyrForm.BandsLBoxSelect(Sender: TObject);
var i : integer;
begin
CurBand := BandsLBox.Text;
i := length(CurBand);
while (i > 0)and(CurBand[i] <> '(') do dec(i);
CurBandName := Trim(Copy(CurBand,1,i-1));
CurBand := Copy(CurBand,i+1,length(CurBand));
CurBand := Trim(Copy(CurBand,1,pos(')',CurBand)-1));
GetAlbums;
// BandsLBox.Visible := true;
AlbumsLBox.Visible := true;
SongsLBox.Visible := false;
TextMemo.Visible := false;
AlbumsLBox.ItemIndex := 0;
Application.ProcessMessages;
AlbumsLBox.OnSelect(Self);
{
AlbumBox.Visible := true;
NewAlbumBtn.Visible := true;
SongBox.Visible := false;
textredit.Visible := false;
NewAlbumBtn.Visible := true;
NewSongBtn.Visible := false;
SaveBtn.Visible := false;
CurTrackEdit.Visible := false;
Application.ProcessMessages;
AlbumBox.ItemIndex := 0;
AlbumBox.OnSelect(Self);
}
end;
procedure TReqLyrForm.AlbumsLBoxSelect(Sender: TObject);
var i : integer;
begin
CurAlbum := AlbumsLBox.Text;
i := length(CurAlbum);
while (i > 0)and(CurAlbum[i] <> '(') do dec(i);
CurAlbum := Copy(CurAlbum,i+1,length(CurAlbum));
CurAlbum := Copy(CurAlbum,1,pos(')',CurAlbum)-1);
GetSongs;
SongsLBox.Visible := true;
textmemo.Visible := false;
end;
procedure TReqLyrForm.GetSongs;
var s,cmd : string;
num,i : integer;
begin
cmd := 'SELECT * FROM Lyrics ';
if CurAlbum <> '' then
begin
cmd := cmd + ' WHERE (BandID LIKE '''+CurBand+''') AND (AlbumID LIKE '''+CurAlbum+''')';
end else
begin
cmd := cmd + ' WHERE (BandID LIKE '''+CurBand+''') AND ((AlbumID LIKE '''') OR (AlbumID IS NULL))';
cmd := cmd + ' ORDER BY AlbumID,SongName';
end;
if musds.Active then musds.Close;
musds.CommandText := cmd;
musds.Open;
with SongsLBox.Items do
begin
Clear;
num := musds.RecordCount;
for i := 1 to num do
begin
s := musds.FieldByName('Track').AsString;
if length(s) > 2 then s := 'xx. ' else
begin
if s <> '' then s := LZs(s,2,'0') + '. ';
end;
Add(s + musds.FieldByName('SongName').AsString+' ('+musds.FieldByName('ID').AsString+')');
musds.Next;
end;
SongsLBox.ItemIndex := 0;
end;
musds.Close;
end;
procedure TReqLyrForm.SongsLBoxSelect(Sender: TObject);
var cmd : string;
i : integer;
begin
CurSong := SongsLBox.Text;
i := length(CurSong);
while (i > 0)and(CurSong[i] <> '(') do dec(i);
CurSong := Copy(CurSong,i+1,length(CurSong));
CurSong := Copy(CurSong,1,pos(')',CurSong)-1);
cmd := 'SELECT * FROM Lyrics ';
cmd := cmd + ' WHERE (ID LIKE '''+CurSong+''')';
// cmd := cmd + ' ORDER BY AlbumID,SongName';
if musds.Active then musds.Close;
musds.CommandText := cmd;
musds.Open;
if musds.RecordCount > 0 then
begin
TextMemo.Lines.Clear;
TextMemo.Text := musds.FieldByName('Text').AsString;
end;
musds.Close;
textmemo.Visible := true;
end;
end.