ProGestion/Modulos/Obras final/Cliente/uDataModuleObrasFinal.pas

199 lines
4.9 KiB
ObjectPascal
Raw Normal View History

unit uDataModuleObrasFinal;
interface
uses SysUtils, Classes, uBizObraFinal, uBizObra;
type
TdmObrasFinal = class(TDataModule)
public
function GetFacturasItems: IBizFacturasObras; overload;
function GetFacturasItems(CodigoObra: Integer): IBizFacturasObras; overload;
function GetFacturasItem(Codigo: Integer): IBizFacturasObras;
function GetRecibosItems: IBizRecibosObras; overload;
function GetRecibosItems(CodigoObra: Integer): IBizRecibosObras; overload;
function GetRecibosItem(Codigo: Integer): IBizRecibosObras;
function GetObrasItems: IBizObraFinal;
function GetObraItem(Codigo: Integer): IBizObraFinal;
function GetItemsSeleccionados(ASource : IBizObraFinal): IBizObraFinal;
end;
var
dmObrasFinal: TdmObrasFinal;
implementation
{$R *.dfm}
uses uDAInterfaces, uDBSelectionList, uDataModuleObras, uDataModuleFacturasCliente,
uDataModuleRecibosCliente, cxControls;
{ TdmObrasFinal }
function TdmObrasFinal.GetFacturasItems: IBizFacturasObras;
begin
Result := (dmFacturasCliente.GetDataTableItems(BIZ_FACTURASOBRAS) as IBizFacturasObras);
end;
function TdmObrasFinal.GetObrasItems: IBizObraFinal;
begin
Result := (dmObras.GetDataTableItems(BIZ_OBRAFINAL) as IBizObraFinal);
end;
function TdmObrasFinal.GetItemsSeleccionados(ASource : IBizObraFinal): IBizObraFinal;
var
aObj : ISelectedRowList;
dtObra : IBizObraFinal;
i : integer;
Cadena: Variant;
begin
if Supports(ASource, ISelectedRowList, aObj) then
begin
if (aObj.SelectedRows.Count = 1) then
begin
ASource.DataTable.GotoBookmark(aObj.SelectedRows[0]);
Result := GetObraItem(ASource.CODIGO);
Exit;
end
else
dtObra := GetObrasItems;
end
else
raise Exception.Create('Interface no soportada (GetItemsSeleccionados)');
ShowHourglassCursor;
try
//Si esta abierta cerramos para poner el where
if dtObra.DataTable.Active then
dtObra.DataTable.Active := False;
with dtObra.DataTable.Where do
begin
Cadena := '';
for i := 0 to aObj.SelectedRows.Count - 1 do
begin
ASource.DataTable.GotoBookmark(aObj.SelectedRows[i]);
if Cadena <> '' then Cadena:= Cadena + ', ';
Cadena:= Cadena + IntToStr(ASource.CODIGO);
end;
Clear;
Cadena := '(' + Cadena + ')';
AddCondition('CODIGO', cIn, Cadena);
end;
Result := dtObra;
finally
HideHourglassCursor;
end;
end;
function TdmObrasFinal.GetObraItem(Codigo: Integer): IBizObraFinal;
var
AObra: IBizObraFinal;
begin
ShowHourglassCursor;
try
AObra := GetObrasItems;
with AObra.DataTable do
begin
if Active then Active := False;
Where.Clear;
Where.AddText('OBRAS.CODIGO' + ' = ' + IntToStr(Codigo));
Active := True;
end;
Result := AObra;
finally
AObra := Nil;
HideHourglassCursor;
end;
end;
function TdmObrasFinal.GetFacturasItems(CodigoObra: Integer): IBizFacturasObras;
var
AFacturas: IBizFacturasObras;
begin
ShowHourglassCursor;
try
AFacturas := GetFacturasItems;
with AFacturas.DataTable do
begin
if Active then Active := False;
Where.Clear;
Where.AddText('CODIGOOBRA' + ' = ' + IntToStr(CodigoObra));
end;
Result := AFacturas;
finally
HideHourglassCursor;
end;
end;
function TdmObrasFinal.GetRecibosItems: IBizRecibosObras;
begin
Result := (dmRecibosCliente.GetDataTableItems(BIZ_RECIBOSOBRAS) as IBizRecibosObras);
end;
function TdmObrasFinal.GetRecibosItems(CodigoObra: Integer): IBizRecibosObras;
var
ARecibos: IBizRecibosObras;
begin
ShowHourglassCursor;
try
ARecibos := GetRecibosItems;
with ARecibos.DataTable do
begin
if Active then Active := False;
Where.Clear;
Where.AddText('CODIGOOBRA' + ' = ' + IntToStr(CodigoObra));
end;
Result := ARecibos;
finally
HideHourglassCursor;
end;
end;
function TdmObrasFinal.GetFacturasItem(Codigo: Integer): IBizFacturasObras;
var
AFacturas: IBizFacturasObras;
begin
ShowHourglassCursor;
try
AFacturas := GetFacturasItems;
with AFacturas.DataTable do
begin
if Active then Active := False;
Where.Clear;
Where.AddText('CODIGO' + ' = ' + IntToStr(Codigo));
end;
Result := AFacturas;
finally
HideHourglassCursor;
end;
end;
function TdmObrasFinal.GetRecibosItem(Codigo: Integer): IBizRecibosObras;
var
ARecibos: IBizRecibosObras;
begin
ShowHourglassCursor;
try
ARecibos := GetRecibosItems;
with ARecibos.DataTable do
begin
if Active then Active := False;
Where.Clear;
Where.AddText('CODIGO' + ' = ' + IntToStr(Codigo));
end;
Result := ARecibos;
finally
HideHourglassCursor;
end;
end;
initialization
dmObrasFinal := TdmObrasFinal.Create(nil);
finalization
FreeAndNil(dmObrasFinal);
end.