Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#29

AW: Sortieren im Clientdataset nach ID(autoinc)

  Alt 9. Dez 2013, 18:29
Dabei könnte das Leben so einfach sein
Delphi-Quellcode:

program dp_177583;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  SysUtils,
  TypInfo,
  uAppPath in 'uAppPath.pas';

procedure OutputPath;
  begin
    Writeln( AppPath.Data );
    Writeln( AppPath.Konten );
    Writeln( AppPath.Mitgliedsausweis );
    Writeln( AppPath.Schreiben );
    Writeln( AppPath.Kassenbuch );
    Writeln( AppPath.Handkasse );
  end;

procedure Main;
  var
    LLocation : TAppDataLocation;
  begin
    for LLocation := low( TAppDataLocation ) to high( TAppDataLocation ) do
      begin
        AppPath.Location := LLocation;
        Writeln;
        Writeln( 'AppPath.Location=', GetEnumName( TypeInfo( TAppDataLocation ), Integer( LLocation ) ) );
        Writeln;
        OutputPath;
      end;
  end;

begin
  try

    Main;

  except
    on E : Exception do
      Writeln( E.ClassName, ': ', E.Message );
  end;

  ReadLn;

end.
mit
Delphi-Quellcode:
unit uAppPath;

interface

  type
    TAppDataLocation = ( adlUser, adlCommon, adlPortable );

    TAppPath = class
    private
      FLocation : TAppDataLocation;
    public
      function Data : string;
      function Kassenbuch : string; overload;
      function Kassenbuch( const ADate : TDateTime ) : string; overload;
      function Konten : string;
      function Mitgliedsausweis : string;
      function Schreiben : string;
      function Handkasse : string; overload;
      function Handkasse( const ADate : TDateTime ) : string; overload;

      property Location : TAppDataLocation read FLocation write FLocation;
    end;

  function AppPath : TAppPath;

implementation

  uses
    Windows,
    ShellApi,
    ShlObj,
    SysUtils;

  var
    _AppPath : TAppPath;

  function AppPath : TAppPath;
    begin
      if not Assigned( _AppPath )
      then
        begin
          _AppPath := TAppPath.Create;
        end;
      Result := _AppPath;
    end;

  function GetKnownFolder( const FolderID : TGUID ) : string;
    var
      LPath : PChar;
    begin
      if SHGetKnownFolderPath( FolderID, 0, 0, LPath ) >= 0
      then
        Result := LPath
      else
        Result := #0;
    end;

  function GetSpecialFolder( FolderID : longint ) : string;
    var
      Path : PChar;
      idList : PItemIDList;
    begin
      GetMem( Path, MAX_PATH );
      SHGetSpecialFolderLocation( 0, FolderID, idList );
      SHGetPathFromIDList( idList, Path );
      Result := string( Path );
      FreeMem( Path );
    end;

  function WinVersionMinVista : Boolean;
    begin
      Result := CheckWin32Version( 6, 0 );
    end;

  function UserAppDataFolder : string;
    begin
      if WinVersionMinVista
      then
        Result := GetKnownFolder( StringToGUID( '{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}' ) )
      else
        Result := GetSpecialFolder( CSIDL_APPDATA )
    end;

  function CommonAppDataFolder : string;
    begin
      if WinVersionMinVista
      then
        Result := GetKnownFolder( StringToGUID( '{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}' ) )
      else
        Result := GetSpecialFolder( CSIDL_COMMON_APPDATA )
    end;

  { TAppPath }

  function TAppPath.Data : string;
    begin
      case Location of
        adlUser :
          Result := UserAppDataFolder + '\Vereintool\';
        adlCommon :
          Result := CommonAppDataFolder + '\Vereintool\';
        adlPortable :
          Result := ExtractFilePath( ParamStr( 0 ) + 'Daten\' );
      end;
      Result := Result + 'Daten\';
    end;

  function TAppPath.Handkasse( const ADate : TDateTime ) : string;
    begin
      Result := Kassenbuch( ADate ) + FormatDateTime( '"Handkasse "yyyy".xls"', ADate );
    end;

  function TAppPath.Handkasse : string;
    begin
      Result := Handkasse( Now );
    end;

  function TAppPath.Kassenbuch( const ADate : TDateTime ) : string;
    begin
      Result := Data + FormatDateTime( '"Kassenbuch\"yyyy"\"', ADate );
    end;

  function TAppPath.Kassenbuch : string;
    begin
      Result := Kassenbuch( Now );
    end;

  function TAppPath.Konten : string;
    begin
      Result := Data + 'Konten\';
    end;

  function TAppPath.Mitgliedsausweis : string;
    begin
      Result := Data + 'Mitgliedsausweis\';
    end;

  function TAppPath.Schreiben : string;
    begin
      Result := Data + 'Schreiben\';
    end;

initialization

finalization

  FreeAndNil( _AppPath );

end.
bekommt man
Code:

AppPath.Location=adlUser

C:\Users\user123\AppData\Roaming\Vereintool\Daten\
C:\Users\user123\AppData\Roaming\Vereintool\Daten\Konten\
C:\Users\user123\AppData\Roaming\Vereintool\Daten\Mitgliedsausweis\
C:\Users\user123\AppData\Roaming\Vereintool\Daten\Schreiben\
C:\Users\user123\AppData\Roaming\Vereintool\Daten\Kassenbuch\2013\
C:\Users\user123\AppData\Roaming\Vereintool\Daten\Kassenbuch\2013\Handkasse 2013.xls

AppPath.Location=adlCommon

C:\ProgramData\Vereintool\Daten\
C:\ProgramData\Vereintool\Daten\Konten\
C:\ProgramData\Vereintool\Daten\Mitgliedsausweis\
C:\ProgramData\Vereintool\Daten\Schreiben\
C:\ProgramData\Vereintool\Daten\Kassenbuch\2013\
C:\ProgramData\Vereintool\Daten\Kassenbuch\2013\Handkasse 2013.xls

AppPath.Location=adlPortable

C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\
C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\Konten\
C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\Mitgliedsausweis\
C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\Schreiben\
C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\Kassenbuch\2013\
C:\Users\user123\Documents\RAD Studio\Projekte\_dp\dp_177583\Win32\Debug\dp_177583.exeDaten\Daten\Kassenbuch\2013\Handkasse 2013.xls
Da kann man noch weiter mit spielen
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat