This repository has been archived on 2024-11-29. You can view files and clone it, but cannot push or open issues or pull requests.
Tecsitel_FactuGES/Clientes/ListadoPresupuestosCli.pas
2007-06-21 15:47:20 +00:00

267 lines
7.6 KiB
ObjectPascal

{
===============================================================================
Copyright (©) 2001. Rodax Software.
===============================================================================
Los contenidos de este fichero son propiedad de Rodax Software titular del
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
bajo el que se suministra.
-----------------------------------------------------------------------------
Web: www.rodax-software.com
===============================================================================
Fecha primera versión: 11-08-2002
Versión actual: 1.0.3
Fecha versión actual: 30-06-2004
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
08-03-2003 Se han puesto componentes con calendario.
10-03-2003 p259. Informe con la lista de todos los presupuestos
de cliente.
30-06-2004 p272. Adaptación a multiempresa.
30-06-2004 p274. Actualización del informe a FastReport.
===============================================================================
}
unit ListadoPresupuestosCli;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ListadoBase, ExtCtrls, StdCtrls, RdxTitulos, RdxPaneles, cxControls, Tipos,
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar,
RdxCampos, RdxRadioButton, cxButtonEdit;
type
TfrListadoPresupuestosCli = class(TfrListadoBase)
Label1: TLabel;
FechaIni: TcxDateEdit;
Label2: TLabel;
FechaFin: TcxDateEdit;
Bevel1: TBevel;
rbCodigo: TRdxRadioButton;
eCodigoIni: TLabel;
NombreCliente: TRdxEdit;
rbTodos: TRdxRadioButton;
eInfoCriterios: TLabel;
CodCli: TcxButtonEdit;
procedure FechaIniPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
procedure FechaFinPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
procedure rbTodosClick(Sender: TObject);
procedure rbCodigoClick(Sender: TObject);
procedure CodCliPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure CodCliPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
procedure RdxFrameShow(Sender: TObject);
private
FFechaIni: Variant;
FFechaFin: Variant;
FCodigoCliente: Variant;
procedure ActivarCliente;
procedure DesactivarCliente;
procedure SetCodigoCliente(const Value: Variant);
procedure RefrescarInforme; override;
protected
procedure FreeContenido; override;
procedure VerModal; override;
public
property CodigoCliente : Variant read FCodigoCliente write SetCodigoCliente;
constructor Create (AOwner : TComponent); override;
end;
var
frListadoPresupuestosCli: TfrListadoPresupuestosCli;
implementation
{$R *.DFM}
{ TfrListadoFacturasCli }
uses
Configuracion, Literales, InformeListadoPresupuestosCli, DateFunc, TablaClientes,
Clientes, StrFunc;
constructor TfrListadoPresupuestosCli.Create(AOwner: TComponent);
begin
inherited;
ConfigurarFrame(Self, Self.Entidad);
FFechaIni := DarDiaInicioMesDat;
FFechaFin := DarDiaFinalMesDat;
FechaIni.Date := FFechaIni;
FechaFin.Date := FFechaFin;
FCodigoCliente := NULL;
FInforme := TdmInformeListadoPresupuestosCli.Create(Self);
FInforme.Preview := FVistaPrevia.Preview;
RefrescarInforme;
end;
procedure TfrListadoPresupuestosCli.FechaIniPropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
begin
if (StrToDate(DisplayValue) > FechaFin.Date) then
begin
ErrorText := msgFechaIniMayor;
Error := True;
Exit;
end;
FFechaIni := StrToDate(DisplayValue);
RefrescarInforme;
end;
procedure TfrListadoPresupuestosCli.FechaFinPropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
begin
if (StrToDate(DisplayValue) < FechaIni.Date) then
begin
ErrorText := msgFechaIniMayor;
Error := True;
Exit;
end;
FFechaFin := StrToDate(DisplayValue);
RefrescarInforme;
end;
procedure TfrListadoPresupuestosCli.RefrescarInforme;
begin
with (FInforme as TdmInformeListadoPresupuestosCli) do
begin
FechaIni := FFechaIni;
FechaFin := FFechaFin;
if rbTodos.Checked then
Tipo := tiTodo
else begin
Tipo := tiPorCliente;
if FCodigoCliente = Null then
Exit;
CodigoCliente := FCodigoCliente;
NombreCliente := Self.NombreCliente.Text;
end;
Previsualizar;
end;
end;
procedure TfrListadoPresupuestosCli.ActivarCliente;
begin
CodCli.Enabled := True;
CodCli.SetFocus;
NombreCliente.Enabled := True;
end;
procedure TfrListadoPresupuestosCli.DesactivarCliente;
begin
CodCli.Enabled := False;
NombreCliente.Enabled := False;
end;
procedure TfrListadoPresupuestosCli.SetCodigoCliente(const Value: Variant);
var
DatosCliente : TDatosCliente;
begin
if Value = Null then
Exit;
if FCodigoCliente <> Value then
begin
FCodigoCliente := Value;
DatosCliente := TDatosCliente.Create;
try
DatosCliente.Codigo := FCodigoCliente;
dmTablaClientes.DarDatosCliente(DatosCliente);
CodCli.Text := FCodigoCliente;
NombreCliente.Text := DatosCliente.Nombre;
finally
DatosCliente.Free;
end;
RefrescarInforme;
end;
end;
procedure TfrListadoPresupuestosCli.rbTodosClick(Sender: TObject);
begin
DesactivarCliente;
RefrescarInforme;
end;
procedure TfrListadoPresupuestosCli.rbCodigoClick(Sender: TObject);
begin
ActivarCliente;
RefrescarInforme;
end;
procedure TfrListadoPresupuestosCli.CodCliPropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
ModoModal := Seleccionar;
ContenidoModal := TfrClientes.Create(Self);
end;
procedure TfrListadoPresupuestosCli.CodCliPropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
begin
if EsCadenaVacia (DisplayValue) then
begin
Error := True;
ErrorText := msgCliFaltaCodigo;
Exit;
end;
if (dmTablaClientes.ValidarCodigo(DisplayValue)) then
begin
DisplayValue := dmTablaClientes.FormatearCodigo(DisplayValue);
if (not dmTablaClientes.ExisteCodigo(DisplayValue)) then
begin
Error := True;
ErrorText := Format(msgCliCodCliNoExiste, [DisplayValue]);
Exit;
end;
end
else begin
Error := True;
ErrorText := Format(msgCliCodCliIncorrecto, [DisplayValue]);
Exit;
end;
CodigoCliente := DisplayValue;
end;
procedure TfrListadoPresupuestosCli.VerModal;
begin
if (ContenidoModal is TfrClientes) then
(ContenidoModal as TfrClientes).CodigoCliente := FCodigoCliente;
inherited;
end;
procedure TfrListadoPresupuestosCli.FreeContenido;
begin
if (ContenidoModal is TfrClientes) then
CodigoCliente := (ContenidoModal as TfrClientes).CodigoCliente;
inherited;
end;
procedure TfrListadoPresupuestosCli.RdxFrameShow(Sender: TObject);
begin
DesactivarCliente;
FechaIni.SetFocus;
end;
end.