2007-06-21 16:02:50 +00:00
{
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Copyright ( <EFBFBD> ) 2 0 0 6 . Rodax Software.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Los contenidos de este fichero son propiedad de Rodax Software titular del
copyright. Este fichero s<EFBFBD> lo podr<EFBFBD> ser copiado, distribuido y utilizado,
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
acuerdo con los t<EFBFBD> rminos y condiciones establecidas en el acuerdo/ contrato
bajo el que se suministra.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Web: www. rodax- software. com
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Fecha primera versi<EFBFBD> n: 0 1 - 0 1 - 2 0 0 6
Versi<EFBFBD> n actual: 1.0 . 1
Fecha versi<EFBFBD> n actual: 2 6 - 0 9 - 2 0 0 6
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Modificaciones:
Fecha Comentarios
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 6 - 0 9 - 2 0 0 6 Se ha modificado la l<EFBFBD> gica al seleccionar un presupuesto para
generar un albar<EFBFBD> n, ahora un albar<EFBFBD> n se podr<EFBFBD> generar a partir
de un presupuesto aunque no tenga asignado ning<EFBFBD> n montaje
2007-11-07 16:56:36 +00:00
0 7 - 1 0 - 2 0 0 7 PETICION DE RAQUEL - As <EFBFBD> podr<EFBFBD> n crear montajes de presupuestos
que todavia no estan aceptados el proceso deber<EFBFBD> cambiar de
situaci<EFBFBD> n el presupuesto elegido ( SetReferencia, GetPresupuestosSinMontaje)
2007-06-21 16:02:50 +00:00
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
}
unit uDataModulePresupuestos;
interface
uses {vcl:} SysUtils, Classes, DB, DBClient,
{RemObjects:} uDAClientDataModule, uDADataTable, uDABINAdapter,
uROServiceComponent, uRORemoteService, uROClient, uROBinMessage,
uROWinInetHttpChannel, uDAScriptingProvider, uDACDSDataTable,
uBizPresupuestosCliente, FactuGES_Intf,
frxExportImage, frxExportPDF, frxDCtrl,
frxClass, frxDMPExport, frxGradient, frxChBox, frxCross, frxRich,
frxChart, frxOLE, frxBarcode;
type
TdmPresupuestos = class( TDAClientDataModule)
RORemoteService: TRORemoteService;
DABinAdapter: TDABINAdapter;
tbl_DetallesPresupuestos: TDACDSDataTable;
ds_DetallesPresupuestos: TDADataSource;
tbl_Presupuestos: TDACDSDataTable;
ds_Presupuestos: TDADataSource;
2009-03-05 18:57:06 +00:00
tbl_ListaAnosPresupuestos: TDACDSDataTable;
ds_ListaAnosPresupuestos: TDADataSource;
2007-06-21 16:02:50 +00:00
procedure DAClientDataModuleCreate( Sender: TObject) ;
public
function PuedoEliminarPresupuesto ( CodigoPresupuesto : Integer ) : Boolean ;
function GetReferencia ( CodigoPresupuesto : Integer ) : String ;
function GetNextAutoinc : integer ;
function GetPresupuestos: IBizPresupuestos;
function GetPresupuesto( CodigoPresupuesto : Integer ) : IBizPresupuestos;
function GetPresupuestosSinAlbaran: IBizPresupuestos;
function GetPresupuestosSinMontaje: IBizPresupuestos;
function SetReferencia ( APresupuesto: IBizPresupuestos; Referencia: Variant ) : Boolean ;
procedure Preview( Const Codigo: Integer ) ;
procedure Refrescar( lReport: TfrxReport; Const Codigo: Integer ; const TamLetra: Integer ) ;
procedure Print( Const Codigo: Integer ) ;
function GetItemsSeleccionados( ASource : IBizPresupuestos) : IBizPresupuestos;
2009-03-05 18:57:06 +00:00
function DarListaAnosPresupuestos: TStringList;
procedure FiltrarAno( APresupuestos: IBizPresupuestos; AWhereDataTable: String ; const Ano: String ) ;
2007-06-21 16:02:50 +00:00
end ;
var
dmPresupuestos: TdmPresupuestos;
implementation
{$R *.DFM}
uses
2009-03-05 18:57:06 +00:00
Forms, Controls, cxControls, uDataTableUtils, uBizContacto, Dialogs, Variants,
2007-06-21 16:02:50 +00:00
uDataModuleContactos, uDataModuleBase, schPresupuestosClient_Intf,
uDAInterfaces, uEditorPreview, uEditorPreviewPresupuesto, uROTypes,
uDBSelectionList;
function TdmPresupuestos. GetPresupuestos: IBizPresupuestos;
var
dtPresupuestos: TDACDSDataTable;
dtDetalles: TDACDSDataTable;
ACursor: TCursor;
begin
ACursor : = Screen. Cursor;
Screen. Cursor : = crHourGlass;
try
dtPresupuestos : = TDACDSDataTable. Create( NIL ) ;
CloneDataTable( tbl_Presupuestos, dtPresupuestos) ;
with dtPresupuestos do
begin
BusinessRulesID : = BIZ_PRESUPUESTOCLIENTE;
FieldByName( fld_PresupuestosDESCUENTO) . BusinessRulesID : = 'Client.Field.Descuento' ;
FieldByName( fld_PresupuestosIVA) . BusinessRulesID : = 'Client.Field.IVA' ;
end ;
dtDetalles : = TDACDSDataTable. Create( NIL ) ;
CloneDataTable( tbl_DetallesPresupuestos, dtDetalles) ;
with dtDetalles do
begin
BusinessRulesID : = BIZ_DETALLESPRESUPUESTOCLIENTE;
DetailOptions : = DetailOptions - [ dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates] ;
FieldByName( fld_DetallesPresupuestosCANTIDAD) . BusinessRulesID : = 'Client.Field.Cantidad' ;
FieldByName( fld_DetallesPresupuestosIMPORTEUNIDAD) . BusinessRulesID : = 'Client.Field.ImporteUnidad' ;
FieldByName( fld_DetallesPresupuestosTIPO) . BusinessRulesID : = 'Client.Field.TipoDetalle' ;
FieldByName( fld_DetallesPresupuestosPUNTOS) . BusinessRulesID : = 'Client.Field.Puntos' ;
FieldByName( fld_DetallesPresupuestosIMPORTEPUNTOS) . BusinessRulesID : = 'Client.Field.ImportePuntos' ;
FieldByName( fld_DetallesPresupuestosVISIBLE) . BusinessRulesID : = 'Client.Field.Visible' ;
2010-03-14 18:07:47 +00:00
FieldByName( fld_DetallesPresupuestosVALORADO) . BusinessRulesID : = 'Client.Field.Valorado' ;
2007-06-21 16:02:50 +00:00
end ;
( dtPresupuestos as IBizPresupuestos) . Detalles : = ( dtDetalles as IBizDetallesPresupuesto) ;
Result : = ( dtPresupuestos as IBizPresupuestos) ;
finally
Screen. Cursor : = ACursor;
end ;
end ;
procedure TdmPresupuestos. DAClientDataModuleCreate( Sender: TObject) ;
begin
RORemoteService. Channel : = dmBase. Channel;
RORemoteService. Message : = dmBase. Message ;
Adapter : = dmBase. Adapter;
end ;
function TdmPresupuestos. GetPresupuestosSinAlbaran: IBizPresupuestos;
var
dsPresupuestos : IBizPresupuestos;
begin
dsPresupuestos : = GetPresupuestos;
with dsPresupuestos. DataTable. Where do
begin
if not Empty then
AddOperator( opAND) ;
Clear;
OpenBraket;
AddText( fld_PresupuestosCODIGOALBARAN + ' is null' , False ) ;
CloseBraket;
AddOperator( opAND) ;
OpenBraket;
AddText( fld_PresupuestosSITUACION + '=' + '' '' + SITUACION_ACEPTADO + '' '' , False ) ;
CloseBraket;
// 26-09-2006
//
// AddOperator(opAND);
// OpenBraket;
// AddText('PRESUPUESTOS.' + fld_PresupuestosREFERENCIA + ' is not NULL', False);
// CloseBraket;
end ;
Result : = dsPresupuestos;
end ;
function TdmPresupuestos. GetNextAutoinc: integer ;
begin
Result : = ( RORemoteService as IsrvPresupuestos) . GetNextAutoinc;
end ;
procedure TdmPresupuestos. Preview( Const Codigo: Integer ) ;
var
AStream: TROBinaryMemoryStream;
AEditorPreviewPresupuesto : TfEditorPreviewPresupuesto;
begin
AEditorPreviewPresupuesto : = TfEditorPreviewPresupuesto. Create( Application) ;
try
AStream : = ( RORemoteService as IsrvPresupuestos) . GenerateReport( Codigo, 0 ) ;
AEditorPreviewPresupuesto. Report. PreviewPages. LoadFromStream( AStream) ;
AEditorPreviewPresupuesto. Codigo : = Codigo;
AEditorPreviewPresupuesto. ShowModal;
finally
AEditorPreviewPresupuesto. Release;
AStream. Free;
end ;
end ;
function TdmPresupuestos. GetReferencia( CodigoPresupuesto: Integer ) : String ;
var
APresupuesto : IBizPresupuestos;
begin
APresupuesto : = GetPresupuesto( CodigoPresupuesto) ;
APresupuesto. DataTable. Active : = True ;
Result : = APresupuesto. REFERENCIA;
end ;
function TdmPresupuestos. GetPresupuesto(
CodigoPresupuesto: Integer ) : IBizPresupuestos;
var
APresupuesto : IBizPresupuestos;
begin
APresupuesto : = GetPresupuestos;
with APresupuesto. DataTable. Where do
AddText( fld_PresupuestosCODIGO + ' = ' + IntToStr( CodigoPresupuesto) ) ;
Result : = APresupuesto;
end ;
function TdmPresupuestos. PuedoEliminarPresupuesto(
CodigoPresupuesto: Integer ) : Boolean ;
begin
Result : = ( RORemoteService as IsrvPresupuestos) . PuedoEliminarPresupuesto( CodigoPresupuesto) ;
end ;
procedure TdmPresupuestos. Print( const Codigo: Integer ) ;
var
AStream: TROBinaryMemoryStream;
AEditorPreview : TfEditorPreview;
begin
AEditorPreview : = TfEditorPreview. Create( Application) ;
try
AStream : = ( RORemoteService as IsrvPresupuestos) . GenerateReport( Codigo, 0 ) ;
AEditorPreview. Report. PreviewPages. LoadFromStream( AStream) ;
AEditorPreview. Print;
finally
AEditorPreview. Release;
AStream. Free;
end ;
end ;
function TdmPresupuestos. GetPresupuestosSinMontaje: IBizPresupuestos;
var
dsPresupuestos : IBizPresupuestos;
begin
dsPresupuestos : = GetPresupuestos;
with dsPresupuestos. DataTable. Where do
begin
if not Empty then
AddOperator( opAND) ;
Clear;
OpenBraket;
AddText( fld_PresupuestosCODIGO + ' not in (select CODIGOPRESUPUESTO from MONTAJES where CODIGOEMPRESA = ' + IntToStr( dmBase. CodigoEmpresa) + ' and CODIGOPRESUPUESTO is not null)' , False ) ;
CloseBraket;
2007-11-07 16:56:36 +00:00
//As<41> podr<64> n crear montajes de presupuestos que todavia no estan aceptados
//el proceso deber<65> cambiar de situaci<63> n el presupuesto elegido
// AddOperator(opAND);
// OpenBraket;
// AddText(fld_PresupuestosSITUACION + '=' + '''' + SITUACION_ACEPTADO + '''', False);
// CloseBraket;
2007-06-21 16:02:50 +00:00
{ AddOperator( opAND) ;
OpenBraket;
AddText( fld_PresupuestosREFERENCIA + ' is not NULL' , False ) ;
CloseBraket; }
end ;
Result : = dsPresupuestos;
end ;
function TdmPresupuestos. GetItemsSeleccionados(
ASource: IBizPresupuestos) : IBizPresupuestos;
var
aObj : ISelectedRowList;
dtPresupuesto : IBizPresupuestos;
i : integer ;
begin
if Supports( ASource, ISelectedRowList, aObj) then
begin
if ( aObj. SelectedRows. Count = 1 ) then
begin
ASource. DataTable. GotoBookmark( aObj. SelectedRows[ 0 ] ) ;
Result : = GetPresupuesto( ASource. CODIGO) ;
Exit;
end
else
dtPresupuesto : = GetPresupuestos;
end
else
raise Exception. Create( 'Interface no soportada (GetItemsSeleccionados)' ) ;
if dtPresupuesto. DataTable. Active then
dtPresupuesto. DataTable. Active : = False ;
with dtPresupuesto. DataTable. Where do
begin
Clear;
for i : = 0 to aObj. SelectedRows. Count - 1 do
begin
ASource. DataTable. GotoBookmark( aObj. SelectedRows[ i] ) ;
if i > 0 then
AddOperator( opAND) ;
AddText( fld_PresupuestosCODIGO + ' = ' + IntToStr( ASource. CODIGO) ) ;
end ;
end ;
Result : = dtPresupuesto;
end ;
function TdmPresupuestos. SetReferencia( APresupuesto: IBizPresupuestos; Referencia: Variant ) : Boolean ;
begin
Result : = False ;
try
if not ( APresupuesto. DataTable. State in dsEditModes) then
APresupuesto. DataTable. Edit;
APresupuesto. DataTable. FieldByName( fld_PresupuestosREFERENCIA) . AsVariant : = Referencia;
2007-11-07 16:56:36 +00:00
//Si el presupuesto al que se la asigna la nueva referencia del montaje esta pendiente lo
//pasamos a aceptado
if not VarIsNull( Referencia)
and ( APresupuesto. DataTable. FieldByName( fld_PresupuestosSITUACION) . AsString = SITUACION_PENDIENTE) then
APresupuesto. DataTable. FieldByName( fld_PresupuestosSITUACION) . AsString : = SITUACION_ACEPTADO;
2007-06-21 16:02:50 +00:00
APresupuesto. Post;
Result : = True ;
except
end ;
end ;
procedure TdmPresupuestos. Refrescar( lReport: TfrxReport; Const Codigo: Integer ; const TamLetra: Integer ) ;
var
AStream: TROBinaryMemoryStream;
begin
AStream : = ( RORemoteService as IsrvPresupuestos) . GenerateReport( Codigo, TamLetra) ;
lReport. PreviewPages. LoadFromStream( AStream) ;
lReport. ShowPreparedReport;
end ;
2009-03-05 18:57:06 +00:00
procedure TdmPresupuestos. FiltrarAno( APresupuestos: IBizPresupuestos; AWhereDataTable: String ; const Ano: String ) ;
var
FechaIni: String ;
FechaFin: String ;
begin
APresupuestos. DataTable. Where. Clear;
APresupuestos. DataTable. Where. AddText( AWhereDataTable) ;
if ( Ano < > 'Todos' ) then
begin
// Filtrar los presupuestos actuales por a<> os
FechaIni : = '01.01.' + Ano;
FechaFin : = '31.12.' + Ano;
with APresupuestos. DataTable. Where do
begin
if NotEmpty then
AddOperator( opAND) ;
AddCondition( fld_PresupuestosFECHAPRESUPUESTO, cMajorOrEqual, FechaIni) ;
AddOperator( opAND) ;
AddCondition( fld_PresupuestosFECHAPRESUPUESTO, cLessOrEqual, FechaFin) ;
end ;
end ;
end ;
function TdmPresupuestos. DarListaAnosPresupuestos: TStringList;
var
AListaAnos: TStringList;
begin
AListaAnos : = TStringList. Create;
ShowHourglassCursor;
try
with tbl_ListaAnosPresupuestos do
begin
Open;
First;
while not eof do
begin
AListaAnos. Add( Format( '%s=%s' , [ Fields[ 0 ] . AsString, Fields[ 0 ] . AsString] ) ) ;
Next;
end ;
Close;
end ;
Result : = AListaAnos;
finally
HideHourglassCursor;
end ;
end ;
2007-06-21 16:02:50 +00:00
initialization
dmPresupuestos : = TdmPresupuestos. Create( nil ) ;
finalization
FreeAndNil( dmPresupuestos) ;
end .