{ =============================================================================== Copyright (©) 2002. 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: 19-04-2004 Versión actual: 1.0.0 Fecha versión actual: 19-04-2004 =============================================================================== Modificaciones: Fecha Comentarios --------------------------------------------------------------------------- =============================================================================== } unit RdxFrameEmpresas; {$I ..\COMPILE.INC} interface uses Consts, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, RdxFrame, RdxDBFrame, IBCustomDataSet, IBDataBase, Tipos, IB, DB; type TRdxFrameEmpresas = class(TRdxDBFrame) private FTablaEmpresas : TIBDataSet; protected FCodigoEmpresa : Variant; procedure SetTablaEmpresas (Value : TIBDataSet); procedure SetCodigoEmpresa (Value : Variant); virtual; procedure SetContenido (NuevoFrame : TRdxFrame); override; function TratarCambios : integer; override; procedure BuscarEmpresa; virtual; procedure CambiarModo(ModoAnterior, Modo : TRdxModo); override; public property TablaEmpresas: TIBDataSet read FTablaEmpresas write SetTablaEmpresas; property CodigoEmpresa : Variant read FCodigoEmpresa write SetCodigoEmpresa; constructor Create (AOwner : TComponent); override; published property BaseDatos; property Transaccion; end; implementation {$R *.DFM} uses Mensajes, StrFunc, Literales {$IFDEF RDX_D6}, Variants{$ENDIF}; { TRdxFrameClientes } constructor TRdxFrameEmpresas.Create(AOwner: TComponent); begin inherited Create(AOwner); FCodigoEmpresa := NULL; FTablaEmpresas := NIL; end; function TRdxFrameEmpresas.TratarCambios : integer; begin if (TablaEmpresas.State in dsEditModes) then begin case VerMensajePregunta(msgGuardarCambios) of IDCANCEL : Result := IDCANCEL; IDYES : begin if (RealizarOperacion) then Result := IDOK else Result := IDCANCEL; end; IDNO : begin if (DescartarOperacion) then Result := IDOK else Result := IDCANCEL; end; end end else Result := IDOK; end; procedure TRdxFrameEmpresas.SetCodigoEmpresa(Value: Variant); begin if not EsCadenaVacia(Value) then begin FCodigoEmpresa := Value; BuscarEmpresa; end end; procedure TRdxFrameEmpresas.SetContenido(NuevoFrame: TRdxFrame); begin if (FContenido <> NIL) then if (Contenido.Name = NuevoFrame.ClassName) then begin NuevoFrame.Free; exit; end; inherited; if (TablaEmpresas <> NIL) then begin FCodigoEmpresa := TablaEmpresas.FieldByName('CODIGO').Value; if Contenido is TRdxFrameEmpresas then (Contenido as TRdxFrameEmpresas).CodigoEmpresa := FCodigoEmpresa; end; end; procedure TRdxFrameEmpresas.CambiarModo(ModoAnterior, Modo : TRdxModo); begin inherited; if (FModo in [Normal, Seleccionar]) then begin TablaEmpresas.Close; TablaEmpresas.Open; end else begin { Si estábamos en el modo Añadir y pasamos a cualquier otro modo SIEMPRE es necesario buscar el codigo de almacén que tiene el frame en CodigoEmpresa (al activar el modo Añadir NO se pisa este valor con el código de almacén nuevo), preguntamos si la tabla esta activa por si se ha cerrado al realizar algun cambio en modificar y ejecutar TratarCambios} if (not TablaEmpresas.Active) or (ModoAnterior = Anadir) then BuscarEmpresa; end; end; procedure TRdxFrameEmpresas.SetTablaEmpresas(Value: TIBDataSet); begin if (FTablaEmpresas <> Value) then FTablaEmpresas := Value; end; procedure TRdxFrameEmpresas.BuscarEmpresa; begin // end; end.