Tecsitel_FactuGES2/Source/Modulos/Contactos/Views/uEditorElegirDireccionEntrega.pas
2009-07-09 11:21:22 +00:00

277 lines
7.9 KiB
ObjectPascal
Raw Blame History

unit uEditorElegirDireccionEntrega;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, Mask, DBCtrls, DB, uDADataTable,
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit,
uIEditorElegirDireccionEntrega, uCustomView, uBizContactos,
uViewBase, uViewBarraSeleccion, JvExControls, JvComponent,
DBCGrids, uBizDireccionesContacto, uDAInterfaces, ActnList,
uDireccionesContactoController;
type
TfEditorElegirDireccionEntrega = class(TForm, IEditorElegirDireccionEntrega)
dsDirecciones: TDADataSource;
frViewBarraSeleccion1: TfrViewBarraSeleccion;
lblTitle: TLabel;
lblComments: TLabel;
DBCtrlGrid1: TDBCtrlGrid;
eCalle: TDBText;
ePoblacion: TDBText;
eTelefono: TDBText;
eProvincia: TDBText;
ePersonaContacto: TDBText;
eNombre: TDBText;
eCodigoPostal: TDBText;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
rdxDestino1: TRadioButton;
RadioButton1: TRadioButton;
ActionList1: TActionList;
actDirSocial: TAction;
actOtro: TAction;
dsContacto: TDADataSource;
pnlDirSocial: TPanel;
DBText1: TDBText;
Label3: TLabel;
DBText2: TDBText;
Label5: TLabel;
DBText3: TDBText;
DBText4: TDBText;
DBText5: TDBText;
DBText7: TDBText;
Label6: TLabel;
DBText6: TDBText;
procedure frViewBarraSeleccion1actSeleccionarExecute(Sender: TObject);
procedure frViewBarraSeleccion1actCancelarExecute(Sender: TObject);
procedure DBCtrlGrid1DblClick(Sender: TObject);
procedure ComponenteDblClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure actDirSocialExecute(Sender: TObject);
procedure actOtroExecute(Sender: TObject);
procedure actOtroUpdate(Sender: TObject);
private
procedure ColorearTextoDirSocial(AColor : TColor);
procedure ColorearTextoDirOtra(AColor : TColor);
protected
FDirecciones: IBizDireccionesContacto;
FContacto : IBizContacto;
FDireccionesController : IDireccionesContactoController;
function GetContacto: IBizContacto;
procedure SetContacto(const Value: IBizContacto);
procedure SetMensaje (const AValue: String);
function GetMensaje: String;
function GetDireccionSeleccionada: IBizDireccionesContacto;
procedure RefrescarEstado;
published
public
property Mensaje : String read GetMensaje write SetMensaje;
property Contacto : IBizContacto read GetContacto write SetContacto;
property DireccionSeleccionada: IBizDireccionesContacto read GetDireccionSeleccionada;
end;
implementation
{$R *.dfm}
uses
uStringsUtils, Variants, uDialogUtils;
{ TfEditorDireccionEntrega }
procedure TfEditorElegirDireccionEntrega.DBCtrlGrid1DblClick(Sender: TObject);
begin
frViewBarraSeleccion1.actSeleccionar.Execute;
end;
procedure TfEditorElegirDireccionEntrega.FormCreate(Sender: TObject);
begin
FDireccionesController := TDireccionesContactoController.Create;
end;
procedure TfEditorElegirDireccionEntrega.FormDestroy(Sender: TObject);
begin
FDireccionesController := NIL;
end;
procedure TfEditorElegirDireccionEntrega.FormShow(Sender: TObject);
begin
if Assigned(FContacto) then
begin
if Supports(FContacto, IBizCliente) then
begin
Caption := 'Elegir una direcci<63>n de cliente';
lblTitle.Caption := 'Seleccione una direcci<63>n de cliente';
end;
if Supports(FContacto, IBizProveedor) then
begin
Caption := 'Elegir una direcci<63>n de proveedor';
lblTitle.Caption := 'Seleccione una direcci<63>n de proveedor';
end;
end;
actDirSocial.Checked := True;
RefrescarEstado;
end;
procedure TfEditorElegirDireccionEntrega.actDirSocialExecute(Sender: TObject);
begin
actDirSocial.Checked := True;
RefrescarEstado;
end;
procedure TfEditorElegirDireccionEntrega.actOtroExecute(Sender: TObject);
begin
actOtro.Checked := True;
RefrescarEstado;
end;
procedure TfEditorElegirDireccionEntrega.actOtroUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := (FDirecciones.RecordCount > 0)
end;
procedure TfEditorElegirDireccionEntrega.ComponenteDblClick(Sender: TObject);
begin
DBCtrlGrid1DblClick(Sender);
end;
procedure TfEditorElegirDireccionEntrega.frViewBarraSeleccion1actCancelarExecute(
Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TfEditorElegirDireccionEntrega.frViewBarraSeleccion1actSeleccionarExecute(
Sender: TObject);
begin
ModalResult := mrOk;
end;
function TfEditorElegirDireccionEntrega.GetContacto: IBizContacto;
begin
Result := FContacto;
end;
function TfEditorElegirDireccionEntrega.GetDireccionSeleccionada: IBizDireccionesContacto;
begin
Result := FDireccionesController.Nuevo;
if actOtro.Checked then
begin
with Result do
begin
ID := FDirecciones.ID;
NOMBRE := FDirecciones.NOMBRE;
CALLE := FDirecciones.CALLE;
POBLACION := FDirecciones.POBLACION;
CODIGO_POSTAL := FDirecciones.CODIGO_POSTAL;
PROVINCIA := FDirecciones.PROVINCIA;
TELEFONO := FDirecciones.TELEFONO;
FAX := FDirecciones.FAX;
MOVIL := FDirecciones.MOVIL;
EMAIL := FDirecciones.EMAIL;
PERSONA_CONTACTO := FDirecciones.PERSONA_CONTACTO;
end;
end
else begin
with Result do
begin
DataTable.FieldByName('ID').AsVariant := Null;
NOMBRE := FContacto.NOMBRE;
CALLE := FContacto.CALLE;
POBLACION := FContacto.POBLACION;
CODIGO_POSTAL := FContacto.CODIGO_POSTAL;
PROVINCIA := FContacto.PROVINCIA;
TELEFONO := FContacto.TELEFONO_1;
FAX := FContacto.FAX;
MOVIL := FContacto.MOVIL_1;
EMAIL := FContacto.EMAIL_1;
PERSONA_CONTACTO := FContacto.PERSONA_CONTACTO;
end;
end;
end;
function TfEditorElegirDireccionEntrega.GetMensaje: String;
begin
Result := lblComments.Caption;
end;
procedure TfEditorElegirDireccionEntrega.RefrescarEstado;
begin
if (actOtro.Checked) then
begin
DBCtrlGrid1.Enabled := True;
DBCtrlGrid1.Color := clWindow;
pnlDirSocial.Enabled := False;
pnlDirSocial.Color := clBtnFace;
ColorearTextoDirOtra(clWindowText);
ColorearTextoDirSocial(clGray);
end;
if (actDirSocial.Checked) then
begin
DBCtrlGrid1.Enabled := False;
DBCtrlGrid1.Color := clBtnFace;
pnlDirSocial.Enabled := True;
pnlDirSocial.Color := clWindow;
ColorearTextoDirSocial(clWindowText);
ColorearTextoDirOtra(clGray);
end;
end;
procedure TfEditorElegirDireccionEntrega.ColorearTextoDirOtra(AColor: TColor);
begin
eNombre.Font.Color := AColor;
eCalle.Font.Color := AColor;
ePoblacion.Font.Color := AColor;
eProvincia.Font.Color := AColor;
eTelefono.Font.Color := AColor;
ePersonaContacto.Font.Color := AColor;
eCodigoPostal.Font.Color := AColor;
end;
procedure TfEditorElegirDireccionEntrega.ColorearTextoDirSocial(AColor: TColor);
begin
DBText1.Font.Color := AColor;
DBText2.Font.Color := AColor;
DBText3.Font.Color := AColor;
DBText4.Font.Color := AColor;
DBText5.Font.Color := AColor;
DBText6.Font.Color := AColor;
DBText7.Font.Color := AColor;
end;
procedure TfEditorElegirDireccionEntrega.SetContacto(const Value: IBizContacto);
begin
FContacto := Value;
if Assigned(FContacto) then
begin
FDirecciones := FContacto.Direcciones;
dsContacto.DataTable := FContacto.DataTable;
dsDirecciones.DataTable := FDirecciones.DataTable;
end
else begin
FDirecciones := NIL;
dsDirecciones.DataTable := NIL;
dsContacto.DataTable := NIL;
end;
end;
procedure TfEditorElegirDireccionEntrega.SetMensaje(const AValue: String);
begin
if not EsCadenaVacia(AValue) then
lblComments.Caption := AValue
else
lblComments.Caption := ' ';
end;
end.