git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@5 9a1d36f3-7752-2d40-8ccb-50eb49674c68
137 lines
3.6 KiB
ObjectPascal
137 lines
3.6 KiB
ObjectPascal
unit uBizDocumentosAsociados;
|
|
|
|
interface
|
|
|
|
type
|
|
|
|
TGestorDocumentos = class(TObject)
|
|
private
|
|
FRootDocumentos: Variant;
|
|
FDirectorio: Variant;
|
|
FModoInsert: Boolean;
|
|
|
|
function CrearDirDocumentos: Boolean;
|
|
function EliminarDirDocumentos : Boolean;
|
|
|
|
function getDirectorio: Variant;
|
|
function getModoInsert: Boolean;
|
|
function getRootDocumentos: Variant;
|
|
procedure setDirectorio(const Value: Variant);
|
|
procedure setModoInsert(const Value: Boolean);
|
|
procedure setRootDocumentos(const Value: Variant);
|
|
public
|
|
property RootDocumentos: Variant read getRootDocumentos write setRootDocumentos;
|
|
property Directorio: Variant read getDirectorio write setDirectorio;
|
|
property ModoInsert: Boolean read getModoInsert write setModoInsert;
|
|
function AnadirDocumento(RutaDocumento: String): Boolean;
|
|
procedure HabilitarDirectorio;
|
|
function darRutaDocumentos: Variant;
|
|
procedure procesarDeleteTable;
|
|
procedure procesarCancelTable;
|
|
end;
|
|
|
|
IBizDocumentosAsociados = interface
|
|
['{60F86497-AA60-4322-878C-A63ECC78B36B}']
|
|
function GetGestorDocumentos: TGestorDocumentos;
|
|
procedure SetGestorDocumentos(Value: TGestorDocumentos);
|
|
property GestorDocumentos: TGestorDocumentos read GetGestorDocumentos write SetGestorDocumentos;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses SysUtils, uSysFunc, Variants, Forms;
|
|
|
|
function TGestorDocumentos.AnadirDocumento(RutaDocumento: String): Boolean;
|
|
var
|
|
DireccionDestino: String;
|
|
begin
|
|
try
|
|
Result := False;
|
|
DireccionDestino := darRutaDocumentos + PathDelim + ExtractFileName(RutaDocumento);
|
|
CopiarFichero(RutaDocumento, DireccionDestino);
|
|
Result := True;
|
|
finally
|
|
end;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.HabilitarDirectorio;
|
|
begin
|
|
if not DirectoryExists(darRutaDocumentos) then
|
|
CrearDirDocumentos;
|
|
end;
|
|
|
|
function TGestorDocumentos.darRutaDocumentos: Variant;
|
|
begin
|
|
Result := FRootDocumentos + PathDelim + VarToStr(FDirectorio);
|
|
end;
|
|
|
|
function TGestorDocumentos.CrearDirDocumentos: Boolean;
|
|
var
|
|
DireccionDestino: String;
|
|
begin
|
|
Result := False;
|
|
DireccionDestino := darRutaDocumentos;
|
|
if not DirectoryExists(DireccionDestino) then
|
|
CreateDir(DireccionDestino);
|
|
Result := True;
|
|
end;
|
|
|
|
function TGestorDocumentos.EliminarDirDocumentos: Boolean;
|
|
begin
|
|
Result := False;
|
|
Application.ProcessMessages;
|
|
if DirectoryExists(darRutaDocumentos) then
|
|
begin
|
|
Deltree(darRutaDocumentos, True);
|
|
Application.ProcessMessages;
|
|
Result := DirectoryExists(darRutaDocumentos);
|
|
end;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.ProcesarDeleteTable;
|
|
begin
|
|
EliminarDirDocumentos;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.ProcesarCancelTable;
|
|
begin
|
|
if FModoInsert then
|
|
EliminarDirDocumentos
|
|
else
|
|
//Eliminaremos el directorio si no tiene documentos, solo tendremos direcctorios
|
|
//en el caso que el presupuesto tenga documentos asociados
|
|
RemoveDir(darRutaDocumentos);
|
|
Application.ProcessMessages;
|
|
end;
|
|
|
|
function TGestorDocumentos.getDirectorio: Variant;
|
|
begin
|
|
Result := FDirectorio;
|
|
end;
|
|
|
|
function TGestorDocumentos.getModoInsert: Boolean;
|
|
begin
|
|
Result := FModoInsert;
|
|
end;
|
|
|
|
function TGestorDocumentos.getRootDocumentos: Variant;
|
|
begin
|
|
Result := FRootDocumentos;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.setDirectorio(const Value: Variant);
|
|
begin
|
|
FDirectorio := Value;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.setModoInsert(const Value: Boolean);
|
|
begin
|
|
FModoInsert := Value;
|
|
end;
|
|
|
|
procedure TGestorDocumentos.setRootDocumentos(const Value: Variant);
|
|
begin
|
|
FRootDocumentos := Value;
|
|
end;
|
|
end.
|