unit StandardLib;

interface

uses
  Classes, Connections, ZhAPI, StandardBillsDm;

type
  TStandardLib = class
  private
    FLibConnection: TCommonConnection;
    FStandardBillsData: TStandardBillsData;

    function GetFileName: string;
    function GetLibName: string;
  public
    constructor Create;
    destructor Destroy; override;

    procedure Open(const AFileName: string);

    property FileName: string read GetFileName;
    property LibName: string read GetLibName;

    property StandardBillsData: TStandardBillsData read FStandardBillsData;
  end;

implementation

{ TStandardLib }

constructor TStandardLib.Create;
begin
  FLibConnection := TCommonConnection.Create;
  FStandardBillsData := TStandardBillsData.Create(FLibConnection.Connection);
end;

destructor TStandardLib.Destroy;
begin
  FStandardBillsData.Free;
  FLibConnection.Free;
  inherited;
end;

function TStandardLib.GetFileName: string;
begin
  Result := FLibConnection.FileName;
end;

function TStandardLib.GetLibName: string;
begin
  Result := ExtractSimpleFileName(FileName);
end;

procedure TStandardLib.Open(const AFileName: string);
begin
  FLibConnection.Open(AFileName);
  FStandardBillsData.Open(FLibConnection.Connection);
end;

end.
