root/trunk/DataModules/dm_collection.pas

379465
1
(* *****************************************************************************
2
  *
3
  * MyHomeLib
4
  *
5
  * Copyright (C) 2008-2010 Aleksey Penkov
6
  *
7
  * Authors Aleksey Penkov   alex.penkov@gmail.com
8
  *         Nick Rymanov     nrymanov@gmail.com
9
  *
10
  * History
11
  * NickR 02.03.2010    Код переформатирован
  *
12
  ****************************************************************************** *)
13
1
unit dm_collection;
14
unit dm_collection;
2
15
3
interface
16
interface
...
...
3
17
4
uses
18
uses
5
  SysUtils, Classes, ABSMain, DB, unit_globals;
19
  SysUtils,
20
  Classes,
21
  ABSMain,
22
  DB,
23
  unit_Globals;
6
24
7
type
25
type
...
...
18
    tblBooksS: TABSTable;
36
    tblBooksS: TABSTable;
19
    dsSeries: TDataSource;
37
    dsSeries: TDataSource;
20
    dsAuthorsS: TDataSource;
38
    dsAuthorsS: TDataSource;
21
    dsBooksS: TDataSource;        
39
    dsBooksS: TDataSource;
22
    tblAuthorsSID: TAutoIncField;
40
    tblAuthorsSID: TAutoIncField;
23
    tblAuthorsSFamily: TWideStringField;
41
    tblAuthorsSFamily: TWideStringField;
24
    tblAuthorsSName: TWideStringField;
42
    tblAuthorsSName: TWideStringField;
...
...
219
    tblExtraE_Review: TWideMemoField;
237
    tblExtraE_Review: TWideMemoField;
220
    tblExtraE_Cover: TBlobField;
238
    tblExtraE_Cover: TBlobField;
221
    tblExtraE_Data: TWideMemoField;
239
    tblExtraE_Data: TWideMemoField;
240
222
  private
241
  private
223
    FIsFavorites: boolean;
242
    FIsFavorites: Boolean;
224
    FActiveTable: TAbsTable;
243
    FActiveTable: TABSTable;
225
244
226
    { Private declarations }
227
  public
245
  public
228
    procedure GetBookFileName(ID: integer; out AFile, AFolder, AExt: string;
246
    procedure GetBookFileName(ID: Integer; out AFile, AFolder, AExt: string; out ANo: Integer);
229
      out ANo: integer);
230
247
231
    procedure SetActiveTable(Tag: integer);
248
    procedure SetActiveTable(Tag: Integer);
232
    procedure GetCurrentBook(var R: TBookRecord);
249
    procedure GetCurrentBook(var R: TBookRecord);
233
    function GetBookGenres(BookID: Integer; FirstOnly: boolean): String;
250
    function GetBookGenres(BookID: Integer; FirstOnly: Boolean): string;
234
    function GetRootGenre(BookID: Integer): string;
251
    function GetRootGenre(BookID: Integer): string;
235
    function GetGenreCode(BookID: Integer): String;
252
    function GetGenreCode(BookID: Integer): string;
236
253
237
    procedure FieldByName(AID: integer; AField: String; out ARes: String); overload;
254
    procedure FieldByName(AID: Integer; AField: string; out ARes: string); overload;
238
    procedure FieldByName(AID: integer; AField: String; out ARes: integer); overload;
255
    procedure FieldByName(AID: Integer; AField: string; out ARes: Integer); overload;
239
    procedure FieldByName(AID: integer; AField: String; out Ares: boolean); overload;
256
    procedure FieldByName(AID: Integer; AField: string; out ARes: Boolean); overload;
240
257
241
    procedure GetBookFolder(ID: integer; out AFolder: String);
258
    procedure GetBookFolder(ID: Integer; out AFolder: string);
242
    procedure SetLocalStatus(AId: integer; AState: boolean);
259
    procedure SetLocalStatus(AID: Integer; AState: Boolean);
243
260
244
    procedure GetStatistics(out AuthorsCount: Integer; out BooksCount: Integer; out SeriesCount: Integer);
261
    procedure GetStatistics(out AuthorsCount: Integer; out BooksCount: Integer; out SeriesCount: Integer);
245
    property ActiveTable: TabsTable read FActiveTable;
262
    property ActiveTable: TABSTable read FActiveTable;
246
263
247
    procedure Clear;
264
    procedure Clear;
248
    procedure SetTableState(State: boolean);
265
    procedure SetTableState(State: Boolean);
249
    function FullName(BookID: Integer): string;
266
    function FullName(BookID: Integer): string;
250
    function AuthorID(BookID: Integer): integer;
267
    function AuthorID(BookID: Integer): Integer;
251
    function FullAuthorsString(BookID: Integer): string;
268
    function FullAuthorsString(BookID: Integer): string;
252
253
  end;
269
  end;
254
270
255
var
271
var
...
...
278
  tblAuthor_Master.Locate('AL_BookID', BookID, []);
294
  tblAuthor_Master.Locate('AL_BookID', BookID, []);
279
  while (not tblAuthor_Master.Eof) and (tblAuthor_MasterAL_BookID.Value = BookID) do
295
  while (not tblAuthor_Master.Eof) and (tblAuthor_MasterAL_BookID.Value = BookID) do
280
  begin
296
  begin
281
    S := trim(tblAuthor_DetailA_Family.Value + ' ' +
297
    { TODO -oNickR : использовать метод TAuthorRecord }
282
                 tblAuthor_DetailA_Name.Value +  ' ' +
298
    S := Trim(tblAuthor_DetailA_Family.Value + ' ' + tblAuthor_DetailA_Name.Value + ' ' + tblAuthor_DetailA_Middle.Value);
283
                 tblAuthor_DetailA_Middle.Value);
284
299
285
    Result := IfThen(Result = '', S, Result + ', ' + S);
300
    Result := IfThen(Result = '', S, Result + ', ' + S);
286
    tblAuthor_Master.Next;
301
    tblAuthor_Master.Next;
...
...
289
304
290
function TDMCollection.FullName(BookID: Integer): string;
305
function TDMCollection.FullName(BookID: Integer): string;
291
begin
306
begin
292
  if BookID <> 0 then tblAuthor_Master.Locate('AL_BookID', BookID, []);
307
  if BookID <> 0 then
293
  Result := trim(tblAuthor_DetailA_Family.Value + ' ' +
308
    tblAuthor_Master.Locate('AL_BookID', BookID, []);
294
                 tblAuthor_DetailA_Name.Value +  ' ' +
309
  { TODO -oNickR : использовать метод TAuthorRecord }
295
                 tblAuthor_DetailA_Middle.Value);
310
  Result := Trim(tblAuthor_DetailA_Family.Value + ' ' + tblAuthor_DetailA_Name.Value + ' ' + tblAuthor_DetailA_Middle.Value);
296
end;
311
end;
297
312
298
procedure TDMCollection.FieldByName(AID: integer; AField: String; out ARes: String);
313
procedure TDMCollection.FieldByName(AID: Integer; AField: String; out ARes: String);
299
begin
314
begin
300
  if AID<> 0 then FActiveTable.Locate('ID', AID, []);
315
  if AID <> 0 then
316
    FActiveTable.Locate('ID', AID, []);
301
  ARes := FActiveTable.FieldByName(AField).AsString;
317
  ARes := FActiveTable.FieldByName(AField).AsString;
302
end;
318
end;
303
319
304
procedure TDMCollection.FieldByName(AID: integer; AField: String; out ARes: integer);
320
procedure TDMCollection.FieldByName(AID: Integer; AField: String; out ARes: Integer);
305
begin
321
begin
306
  if AID<> 0 then FActiveTable.Locate('ID', AID, []);
322
  if AID <> 0 then
323
    FActiveTable.Locate('ID', AID, []);
307
  ARes := FActiveTable.FieldByName(AField).AsInteger;
324
  ARes := FActiveTable.FieldByName(AField).AsInteger;
308
end;
325
end;
309
326
310
function TDMCollection.AuthorID(BookID: Integer): integer;
327
function TDMCollection.AuthorID(BookID: Integer): Integer;
311
begin
328
begin
312
  if BookID <> 0 then tblAuthor_Master.Locate('AL_BookID', BookID, []);
329
  if BookID <> 0 then
330
    tblAuthor_Master.Locate('AL_BookID', BookID, []);
313
  Result := tblAuthor_MasterAL_AuthID.Value;
331
  Result := tblAuthor_MasterAL_AuthID.Value;
314
end;
332
end;
315
333
...
...
317
begin
335
begin
318
  SetTableState(False);
336
  SetTableState(False);
319
337
320
//  tblAuthors.EmptyTable;
338
  // tblAuthors.EmptyTable;
321
  tblAuthor_List.EmptyTable;
339
  tblAuthor_List.EmptyTable;
322
//  tblSeries.EmptyTable;
340
  // tblSeries.EmptyTable;
323
  tblBooksA.EmptyTable;
341
  tblBooksA.EmptyTable;
324
  tblBooksS.EmptyTable;
342
  tblBooksS.EmptyTable;
325
  tblGenres.EmptyTable;
343
  tblGenres.EmptyTable;
...
...
334
  SetTableState(True);
352
  SetTableState(True);
335
end;
353
end;
336
354
337
procedure TDMCollection.FieldByName(AID: integer; AField: String; out Ares: boolean);
355
procedure TDMCollection.FieldByName(AID: Integer; AField: String; out ARes: Boolean);
338
begin
356
begin
339
  if AID <> 0 then FActiveTable.Locate('ID', AID, []);
357
  if AID <> 0 then
358
    FActiveTable.Locate('ID', AID, []);
340
  ARes := FActiveTable.FieldByName(AField).AsBoolean;
359
  ARes := FActiveTable.FieldByName(AField).AsBoolean;
341
end;
360
end;
342
361
343
procedure TDMCollection.GetBookFileName(ID: integer; out AFile:string;
362
procedure TDMCollection.GetBookFileName(ID: Integer; out AFile: string; out AFolder: string; out AExt: string; out ANo: Integer);
344
                                  out AFolder: string; out AExt: string;
345
                                  out ANo:integer);
346
begin
363
begin
347
  FActiveTable.Locate('ID', ID, []);
364
  FActiveTable.Locate('ID', ID, []);
348
  AExt := FActiveTable.FieldByName('Ext').AsString;
365
  AExt := FActiveTable.FieldByName('Ext').AsString;
349
  AFile := FActiveTable.FieldByName('FileName').AsString;
366
  AFile := FActiveTable.FieldByName('FileName').AsString;
350
367
351
  if ExtractFileExt(AFile) <> ZIP_EXTENSION   then  // могут быть проблемы!
368
  if ExtractFileExt(AFile) <> ZIP_EXTENSION then // могут быть проблемы!
352
     AFile := AFile + AExt;
369
    AFile := AFile + AExt;
353
370
354
  AFolder := FActiveTable.FieldByName('Folder').AsString;
371
  AFolder := FActiveTable.FieldByName('Folder').AsString;
355
  ANo := FActiveTable.FieldByName('InsideNo').AsInteger;
372
  ANo := FActiveTable.FieldByName('InsideNo').AsInteger;
356
end;
373
end;
357
374
358
function TDMCollection.GetBookGenres(BookID: Integer; FirstOnly: boolean): String;
375
function TDMCollection.GetBookGenres(BookID: Integer; FirstOnly: Boolean): String;
359
var
376
var
360
  s: String;
377
  S: String;
361
  i: integer;
378
  i: Integer;
362
begin
379
begin
363
  i := 0;
380
  i := 0;
364
  tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
381
  tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
365
  while (not tblBooks_Genre_List.Eof) and (tblBooks_Genre_ListGL_BookID.Value = BookID) do
382
  while (not tblBooks_Genre_List.Eof) and (tblBooks_Genre_ListGL_BookID.Value = BookID) do
366
  begin
383
  begin
367
    if FirstOnly and (i > 0) then Break;
384
    if FirstOnly and (i > 0) then
385
      Break;
368
    if not tblBooks_GenresG_Alias.IsNull then
386
    if not tblBooks_GenresG_Alias.IsNull then
369
      s := s + tblBooks_GenresG_Alias.Value + ' / ';
387
      S := S + tblBooks_GenresG_Alias.Value + ' / ';
370
    tblBooks_Genre_List.Next;
388
    tblBooks_Genre_List.Next;
371
    inc(i);
389
    inc(i);
372
  end;
390
  end;
373
  Delete(S, Length(S) - 2, 3);
391
  Delete(S, Length(S) - 2, 3);
374
  Result := s;
392
  Result := S;
375
end;
393
end;
376
394
377
procedure TDMCollection.GetCurrentBook(var R: TBookRecord);
395
procedure TDMCollection.GetCurrentBook(var R: TBookRecord);
378
var
396
var
379
  BookID: Integer;
397
  BookID: Integer;
380
begin
398
begin
381
  BookID := ActiveTable.FieldByname('ID').Value;
399
  BookID := ActiveTable.FieldByName('ID').Value;
400
382
  R.Clear;
401
  R.Clear;
383
  R.Title := ActiveTable.FieldByname('Title').AsWideString;
402
  R.Title := ActiveTable.FieldByName('Title').AsWideString;
384
  R.Series := IfThen(ActiveTable.FieldByname('SerID').IsNull,
403
  R.Series := IfThen(ActiveTable.FieldByName('SerID').IsNull, NO_SERIES_TITLE, ActiveTable.FieldByName('Series').AsWideString);
385
                     NO_SERIES_TITLE,
404
  R.SeqNumber := ActiveTable.FieldByName('SeqNumber').AsInteger;
386
                     ActiveTable.FieldByname('Series').AsWideString);
405
  R.Folder := ActiveTable.FieldByName('Folder').AsWideString;
387
  R.SeqNumber := ActiveTable.FieldByname('SeqNumber').AsInteger;
406
  R.FileName := ActiveTable.FieldByName('FileName').AsWideString;
388
  R.Folder := ActiveTable.FieldByname('Folder').AsWideString;
407
  R.FileExt := ActiveTable.FieldByName('Ext').AsWideString;
389
  R.FileName := ActiveTable.FieldByname('FileName').AsWideString;
408
  R.Size := ActiveTable.FieldByName('Size').AsInteger;
390
  R.FileExt := ActiveTable.FieldByname('Ext').AsWideString;
409
  R.InsideNo := ActiveTable.FieldByName('InsideNo').AsInteger;
391
  R.Size := ActiveTable.FieldByname('Size').AsInteger;
410
  R.Local := ActiveTable.FieldByName('Local').AsBoolean;
392
  R.InsideNo := ActiveTable.FieldByname('InsideNo').AsInteger;
411
  R.Date := ActiveTable.FieldByName('Date').AsDateTime;
393
  R.Date := ActiveTable.FieldByname('Date').AsDateTime;
412
  R.Lang := ActiveTable.FieldByName('Lang').AsWideString;
394
  R.Lang := ActiveTable.FieldByname('Lang').AsWideString;
413
  if not FIsFavorites then
395
  R.KeyWords := ActiveTable.FieldByname('KeyWords').AsWideString;
414
    R.KeyWords := ActiveTable.FieldByName('KeyWords').AsWideString;
396
  R.Code := ActiveTable.FieldByname('Code').AsInteger;
415
  R.Code := ActiveTable.FieldByName('Code').AsInteger;
397
416
398
  if tblExtra.Locate('E_BookID', BookID, []) then
417
  if tblExtra.Locate('E_BookID', BookID, []) then
399
    R.Annotation := tblExtraE_Annotation.Value;
418
    R.Annotation := tblExtraE_Annotation.Value;
400
419
401
  if ActiveTable.FieldByname('LibID').AsInteger <> 0 then
420
  if ActiveTable.FieldByName('LibID').AsInteger <> 0 then
402
    R.LibID := ActiveTable.FieldByname('LibID').AsInteger
421
    R.LibID := ActiveTable.FieldByName('LibID').AsInteger
403
  else
422
  else
404
    R.LibID := BookID;
423
    R.LibID := BookID;
405
424
406
  if not FIsFavorites  then
425
  if not FIsFavorites then
407
  begin
426
  begin
408
    tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
427
    tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
428
    tblGenres.Locate('G_Code', tblBooks_GenresG_ParentCode.Value, []);
429
    R.RootGenre.Alias := tblGenresG_Alias.Value;
430
409
    while (not tblBooks_Genre_List.Eof) and (tblBooks_Genre_ListGL_BookID.AsInteger = BookID) do
431
    while (not tblBooks_Genre_List.Eof) and (tblBooks_Genre_ListGL_BookID.AsInteger = BookID) do
410
    begin
432
    begin
411
      R.AddGenreFB2(
433
      R.AddGenreFB2(
412
        tblBooks_GenresG_Code.AsWideString,
434
        tblBooks_GenresG_Code.AsWideString,
413
        tblBooks_GenresG_FB2Code.AsWideString,
435
        tblBooks_GenresG_FB2Code.AsWideString,
414
        tblBooks_GenresG_Alias.AsWideString
436
        tblBooks_GenresG_Alias.AsWideString
415
        );
437
      );
416
438
417
      tblBooks_Genre_List.Next;
439
      tblBooks_Genre_List.Next;
418
    end;
440
    end;
419
441
420
  (****************************************************************************
442
    (* ***************************************************************************
421
   * Попробовал использовать Query для получения информации об авторах книги.
443
      * Попробовал использовать Query для получения информации об авторах книги.
422
   * По совершенно необъяснимым для меня причинам это работало ОЧЕНЬ медленно.
444
      * По совершенно необъяснимым для меня причинам это работало ОЧЕНЬ медленно.
423
   * Возможно, стоит исследовать этот вопрос дополнительно.
445
      * Возможно, стоит исследовать этот вопрос дополнительно.
424
   *
446
      *
425
   * select A1."Family", A1."Name", A1."Middle"
447
      * select A1."Family", A1."Name", A1."Middle"
426
   * from "Author_List" A2 inner join "Authors" A1 on (A2."AuthID" = A1."ID")
448
      * from "Author_List" A2 inner join "Authors" A1 on (A2."AuthID" = A1."ID")
427
   * where (A2."BookID" = :BookID)
449
      * where (A2."BookID" = :BookID)
428
   *
450
      *
429
   *)
451
      *)
430
452
431
    tblAuthor_Master.Locate('AL_BookID', BookID, []);
453
    tblAuthor_Master.Locate('AL_BookID', BookID, []);
432
    while (not tblAuthor_Master.Eof) and (tblAuthor_MasterAL_BookID.Value = BookID) do
454
    while (not tblAuthor_Master.Eof) and (tblAuthor_MasterAL_BookID.Value = BookID) do
...
...
435
        tblAuthor_DetailA_Family.AsWideString,
457
        tblAuthor_DetailA_Family.AsWideString,
436
        tblAuthor_DetailA_Name.AsWideString,
458
        tblAuthor_DetailA_Name.AsWideString,
437
        tblAuthor_DetailA_Middle.AsWideString
459
        tblAuthor_DetailA_Middle.AsWideString
438
        );
460
      );
439
461
440
      tblAuthor_Master.Next;
462
      tblAuthor_Master.Next;
441
    end
463
    end
442
  end // not Favorites
464
  end // not Favorites
443
  else
465
  else
444
  begin
466
  begin
445
    R.AddGenreFB2('','',ActiveTable.FieldByname('Genres').AsWideString);
467
    R.AddGenreFB2('', '', ActiveTable.FieldByName('Genres').AsWideString);
446
    R.AddAuthor(ActiveTable.FieldByname('FullName').AsWideString,'','');
468
    R.AddAuthor(ActiveTable.FieldByName('FullName').AsWideString, '', '');
447
  end;
469
  end;
448
end;
470
end;
449
471
...
...
454
end;
476
end;
455
477
456
function TDMCollection.GetRootGenre(BookID: Integer): string;
478
function TDMCollection.GetRootGenre(BookID: Integer): string;
457
var
458
  Code: integer;
459
begin
479
begin
460
  tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
480
  tblBooks_Genre_List.Locate('GL_BookID', BookID, []);
461
  tblGenres.Locate('G_Code', tblBooks_GenresG_ParentCode.Value, []);
481
  tblGenres.Locate('G_Code', tblBooks_GenresG_ParentCode.Value, []);
...
...
464
484
465
procedure TDMCollection.GetStatistics(out AuthorsCount: Integer; out BooksCount: Integer; out SeriesCount: Integer);
485
procedure TDMCollection.GetStatistics(out AuthorsCount: Integer; out BooksCount: Integer; out SeriesCount: Integer);
466
var
486
var
467
  FilterStateA: boolean;
487
  FilterStateA: Boolean;
468
  FilterStringA: string;
488
  FilterStringA: string;
469
  FilterStateS: boolean;
489
  FilterStateS: Boolean;
470
490
471
  BM1: TBookMark;
491
  BM1: TBookMark;
472
begin
492
begin
473
  (****************************************************************************
493
  (* ***************************************************************************
474
   *
494
    *
475
   * Более предпочтительно использовать 3 простых запроса,
495
    * Более предпочтительно использовать 3 простых запроса,
476
   * но пока оставим как есть
   *
496
    * но пока оставим как есть
    *
477
   ****************************************************************************)
497
    *************************************************************************** *)
478
498
479
  BM1 := DMCollection.tblAuthors.GetBookmark;
499
  BM1 := DMCollection.tblAuthors.GetBookmark;
480
  try
500
  try
...
...
484
504
485
    FilterStateS := DMCollection.tblSeries.Filtered;
505
    FilterStateS := DMCollection.tblSeries.Filtered;
486
506
487
488
    DMCollection.tblAuthors.Filtered := False;
507
    DMCollection.tblAuthors.Filtered := False;
489
    DMCollection.tblSeries.Filtered  := False;
508
    DMCollection.tblSeries.Filtered := False;
490
509
491
    AuthorsCount := DMCollection.tblAuthors.RecordCount;
510
    AuthorsCount := DMCollection.tblAuthors.RecordCount;
492
    BooksCount := DMCollection.tblBooks.RecordCount;
511
    BooksCount := DMCollection.tblBooks.RecordCount;
...
...
494
513
495
    DMCollection.tblAuthors.Filter := FilterStringA;
514
    DMCollection.tblAuthors.Filter := FilterStringA;
496
    DMCollection.tblAuthors.Filtered := FilterStateA;
515
    DMCollection.tblAuthors.Filtered := FilterStateA;
497
    DMCollection.tblSeries.Filtered  := FilterStateS;
516
    DMCollection.tblSeries.Filtered := FilterStateS;
498
517
499
    DMCollection.tblAuthors.GotoBookmark(BM1);
518
    DMCollection.tblAuthors.GotoBookmark(BM1);
500
  finally
519
  finally
...
...
502
  end;
521
  end;
503
end;
522
end;
504
523
505
procedure TDMCollection.SetActiveTable(Tag: integer);
524
procedure TDMCollection.SetActiveTable(Tag: Integer);
506
begin
525
begin
507
  if Tag = PAGE_FAVORITES then
526
  if Tag = PAGE_FAVORITES then
508
  begin
527
  begin
...
...
516
  end;
535
  end;
517
end;
536
end;
518
537
519
procedure TDMCollection.GetBookFolder(ID: integer; out AFolder: String);
538
procedure TDMCollection.GetBookFolder(ID: Integer; out AFolder: String);
520
begin
539
begin
521
  FActiveTable.Locate('ID', ID, []);
540
  FActiveTable.Locate('ID', ID, []);
522
  if FActiveTable.Name = 'tblBooks' then
541
  if FActiveTable.Name = 'tblBooks' then
...
...
525
    AFolder := FActiveTable.FieldByName('Folder').AsString;
544
    AFolder := FActiveTable.FieldByName('Folder').AsString;
526
end;
545
end;
527
546
528
procedure TDMCollection.SetLocalStatus(AId: integer; AState: boolean);
547
procedure TDMCollection.SetLocalStatus(AID: Integer; AState: Boolean);
529
begin
548
begin
530
  if Aid <> 0 then
549
  if AID <> 0 then
531
  if  FActiveTable.Locate('ID',AId,[]) then
550
    if FActiveTable.Locate('ID', AID, []) then
532
  begin
551
    begin
533
    FActiveTable.Edit;
552
      FActiveTable.Edit;
534
    FActiveTable.FieldByName('Local').AsBoolean := AState;
553
      FActiveTable.FieldByName('Local').AsBoolean := AState;
535
    FActiveTable.Post;
554
      FActiveTable.Post;
536
555
537
    if FActiveTable.Name = 'tblGrouppedBooks' then
556
      if FActiveTable.Name = 'tblGrouppedBooks' then
538
      if dmCollection.tblBooks.Locate('ID', FActiveTable.FieldByName('OuterID').AsInteger,[]) then
557
        if DMCollection.tblBooks.Locate('ID', FActiveTable.FieldByName('OuterID').AsInteger, []) then
539
      begin
558
        begin
540
        dmCollection.tblBooks.Edit;
559
          DMCollection.tblBooks.Edit;
541
        dmCollection.tblBooksLocal.Value := AState;
560
          DMCollection.tblBooksLocal.Value := AState;
542
        dmCollection.tblBooks.Post;
561
          DMCollection.tblBooks.Post;
543
      end;
562
        end;
544
563
545
    //
564
      //
546
    // обновим информацию о книге в главном окне программы
565
      // обновим информацию о книге в главном окне программы
547
    //
566
      //
548
    PostMessage(
567
      PostMessage(Application.MainFormHandle, WM_MHL_DOWNLOAD_COMPLETE, AID, Integer(LongBool(AState)));
549
      Application.MainFormHandle,
568
    end;
550
      WM_MHL_DOWNLOAD_COMPLETE,
551
      AId,
552
      Integer(LongBool(AState))
553
      );
554
555
  end;
556
end;
569
end;
557
570
558
procedure TDMCollection.SetTableState(State: boolean);
571
procedure TDMCollection.SetTableState(State: Boolean);
559
begin
572
begin
560
  tblAuthors.Active := State;
573
  tblAuthors.Active := State;
561
  tblAuthor_List.Active := State;
574
  tblAuthor_List.Active := State;
...
...
573
  tblExtra.Active := State;
586
  tblExtra.Active := State;
574
  tblAuthor_Master.Active := State;
587
  tblAuthor_Master.Active := State;
575
  tblAuthor_Detail.Active := State;
588
  tblAuthor_Detail.Active := State;
576
577
end;
589
end;
578
590
579
end.
591
end.