This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
FactuGES/Clientes/ElegirDireccionCliente.pas
2007-06-26 08:08:27 +00:00

144 lines
4.0 KiB
ObjectPascal

unit ElegirDireccionCliente;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxControls, cxContainer,
StdCtrls, ExtCtrls, RdxPaneles, cxListBox, RdxBotones,
cxMemo, RdxRadioButton, TablaClientes, ActnList;
type
TDireccionElegida = (dePrincipal, deSucursal);
TfrElegirDireccionCliente = class(TForm)
RdxPanel1: TRdxPanel;
eTitulo: TLabel;
bGuardar: TRdxBoton;
DireccionSucursales: TcxListBox;
rbDireccionPrincipal: TRdxRadioButton;
rbDireccionSucursales: TRdxRadioButton;
DireccionPrincipal: TLabel;
ActionList1: TActionList;
actDireccionPrincipal: TAction;
Label2: TLabel;
actDireccionSucursales: TAction;
procedure actDireccionPrincipalExecute(Sender: TObject);
procedure actDireccionSucursalesExecute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure actDireccionPrincipalUpdate(Sender: TObject);
procedure actDireccionSucursalesUpdate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
FCliente: TDatosCliente;
FDireccionElegida: TDireccionElegida;
procedure SetCliente(const Value: TDatosCliente);
function GetNumSucursal: Integer;
public
property Cliente : TDatosCliente read FCliente write SetCliente;
property DireccionSeleccionada : TDireccionElegida read FDireccionElegida default dePrincipal;
Property NumSucursal : Integer read GetNumSucursal default 0;
published
end;
var
frElegirDireccionCliente: TfrElegirDireccionCliente;
implementation
{$R *.dfm}
Uses
Configuracion, Entidades;
{ TfrElegirDireccionCliente }
procedure TfrElegirDireccionCliente.SetCliente(const Value: TDatosCliente);
var
Contador : Integer;
Texto : String;
begin
FCliente := TDatosCliente.Create(Value.Codigo);
with FCliente do
begin
Texto := Format('%s %s', [NIFCIF, Nombre]);
Texto := Texto + #10 + #13;
Texto := Texto + Format('%s %s %s', [Calle, Numero, Piso]);
Texto := Texto + #10 + #13;
Texto := Texto + Format('%s %s %s', [Poblacion, CodigoPostal, Provincia]);
DireccionPrincipal.Caption := Texto;
end;
with DireccionSucursales.Items do
begin
for Contador := 0 to FCliente.Sucursales.Count - 1 do
with FCliente.Sucursales.Sucursal[Contador] do
begin
Texto := Format('%s %s, ', [Nombre, NIFCIF]);
Texto := Texto + Format('%s %s %s, ', [Calle, Numero, Piso]);
Texto := Texto + Format(' %s %s %s ', [Poblacion, CodigoPostal, Provincia]);
Add(Texto);
end;
end;
end;
procedure TfrElegirDireccionCliente.actDireccionPrincipalExecute(
Sender: TObject);
begin
FDireccionElegida := dePrincipal;
end;
procedure TfrElegirDireccionCliente.actDireccionSucursalesExecute(
Sender: TObject);
begin
FDireccionElegida := deSucursal;
if (DireccionSucursales.ItemIndex < 0) then
DireccionSucursales.ItemIndex := 0;
end;
procedure TfrElegirDireccionCliente.FormDestroy(Sender: TObject);
begin
if Assigned(FCliente) then
FCliente.Free;
FCliente := NIL;
end;
procedure TfrElegirDireccionCliente.FormCreate(Sender: TObject);
begin
ConfigurarFrame(Self, entPresupuestoCliente);
FCliente := NIL;
end;
procedure TfrElegirDireccionCliente.actDireccionPrincipalUpdate(
Sender: TObject);
begin
DireccionPrincipal.Enabled := (Sender as TAction).Checked;
end;
procedure TfrElegirDireccionCliente.actDireccionSucursalesUpdate(
Sender: TObject);
begin
DireccionSucursales.Enabled := (Sender as TAction).Checked;
end;
function TfrElegirDireccionCliente.GetNumSucursal: Integer;
begin
if not rbDireccionSucursales.Enabled then
Result := -1
else begin
if (DireccionSucursales.ItemIndex < 0) then
Result := 0
else
Result := DireccionSucursales.ItemIndex;
end;
end;
procedure TfrElegirDireccionCliente.FormShow(Sender: TObject);
begin
eTitulo.Caption := eTitulo.Caption + ' de ' + FCliente.Nombre;
end;
end.