236 lines
7.4 KiB
ObjectPascal
236 lines
7.4 KiB
ObjectPascal
|
|
unit uViewDatosYSeleccionInstalador;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, StdCtrls, cxControls, cxContainer, cxEdit, cxLabel,
|
|||
|
|
cxDBLabel, ExtCtrls, DB, uDADataTable, uBizContactos,
|
|||
|
|
ComCtrls, ToolWin, ActnList, ImgList, PngImageList, cxTextEdit, cxDBEdit,
|
|||
|
|
pngimage, JvExControls, JvComponent, JvButton, JvTransparentButton, Mask,
|
|||
|
|
DBCtrls, uInstaladoresController, dxLayoutControl, Buttons, uDAInterfaces;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewDatosYSeleccionInstalador = interface(IViewBase)
|
|||
|
|
['{01BA5FEA-3F49-4CC0-959F-C3DC48589148}']
|
|||
|
|
function GetController: IInstaladoresController;
|
|||
|
|
procedure SetController(Value: IInstaladoresController);
|
|||
|
|
property Controller: IInstaladoresController read GetController write SetController;
|
|||
|
|
|
|||
|
|
function GetInstalador: IBizInstalador;
|
|||
|
|
procedure SetInstalador(Value: IBizInstalador);
|
|||
|
|
property Instalador: IBizInstalador read GetInstalador write SetInstalador;
|
|||
|
|
|
|||
|
|
function GetID_Instalador: integer;
|
|||
|
|
procedure SetID_Instalador(const Value: integer);
|
|||
|
|
property ID_Instalador: integer read GetID_Instalador write SetID_Instalador;
|
|||
|
|
|
|||
|
|
function GetOnInstaladorChanged : TNotifyEvent;
|
|||
|
|
procedure SetOnInstaladorChanged (const Value : TNotifyEvent);
|
|||
|
|
property OnInstaladorChanged : TNotifyEvent read GetOnInstaladorChanged
|
|||
|
|
write SetOnInstaladorChanged;
|
|||
|
|
|
|||
|
|
function GetMsgElegirInstalador: String;
|
|||
|
|
procedure SetMsgElegirInstalador(const Value: String);
|
|||
|
|
property MsgElegirInstalador : String read GetMsgElegirInstalador
|
|||
|
|
write SetMsgElegirInstalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewDatosYSeleccionInstalador = class(TfrViewBase, IViewDatosYSeleccionInstalador)
|
|||
|
|
DADataSource: TDADataSource;
|
|||
|
|
ActionList1: TActionList;
|
|||
|
|
actElegirContacto: TAction;
|
|||
|
|
actAnadirContacto: TAction;
|
|||
|
|
actVerContacto: TAction;
|
|||
|
|
PngImageList: TPngImageList;
|
|||
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|||
|
|
edtlNombreInstalador: TcxDBTextEdit;
|
|||
|
|
Button1: TBitBtn;
|
|||
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|||
|
|
Button2: TBitBtn;
|
|||
|
|
dxLayoutControl1Item8: TdxLayoutItem;
|
|||
|
|
Button3: TBitBtn;
|
|||
|
|
dxLayoutControl1Item9: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|||
|
|
procedure actElegirContactoExecute(Sender: TObject);
|
|||
|
|
procedure actAnadirContactoExecute(Sender: TObject);
|
|||
|
|
procedure actVerContactoExecute(Sender: TObject);
|
|||
|
|
procedure actVerContactoUpdate(Sender: TObject);
|
|||
|
|
|
|||
|
|
private
|
|||
|
|
FController : IInstaladoresController;
|
|||
|
|
FInstalador : IBizInstalador;
|
|||
|
|
FOnInstaladorChanged : TNotifyEvent;
|
|||
|
|
FMsgElegirInstalador: String;
|
|||
|
|
function GetMsgElegirInstalador: String;
|
|||
|
|
procedure SetMsgElegirInstalador(const Value: String);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
function GetController: IInstaladoresController;
|
|||
|
|
procedure SetController(Value: IInstaladoresController);
|
|||
|
|
function GetInstalador: IBizInstalador;
|
|||
|
|
procedure SetInstalador(Value: IBizInstalador);
|
|||
|
|
function GetOnInstaladorChanged : TNotifyEvent;
|
|||
|
|
procedure SetOnInstaladorChanged (const Value : TNotifyEvent);
|
|||
|
|
procedure SetReadOnly(Value: Boolean); override;
|
|||
|
|
function GetID_Instalador: integer;
|
|||
|
|
procedure SetID_Instalador(const Value: integer);
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
property Controller: IInstaladoresController read GetController write SetController;
|
|||
|
|
property Instalador: IBizInstalador read GetInstalador write SetInstalador;
|
|||
|
|
property OnInstaladorChanged : TNotifyEvent read GetOnInstaladorChanged write SetOnInstaladorChanged;
|
|||
|
|
property MsgElegirInstalador : String read GetMsgElegirInstalador write SetMsgElegirInstalador;
|
|||
|
|
property ID_Instalador: integer read GetID_Instalador write SetID_Instalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleInstaladores, Math, uCustomView;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.actElegirContactoExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AInstalador : IBizInstalador;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AInstalador := (Controller.ElegirContacto(Controller.BuscarTodos, FMsgElegirInstalador, False) as IBizInstalador);
|
|||
|
|
if Assigned(AInstalador) then
|
|||
|
|
begin
|
|||
|
|
Self.Update;
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
Instalador := AInstalador;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
AInstalador := Nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.actAnadirContactoExecute(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AInstalador : IBizInstalador;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AInstalador := (Controller.Nuevo as IBizInstalador);
|
|||
|
|
Controller.Ver(AInstalador);
|
|||
|
|
Instalador := AInstalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.actVerContactoExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Controller.Ver(Instalador);
|
|||
|
|
if (Application.MessageBox('<27>Desea refrescar los datos del Instalador en el documento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
Instalador := Instalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.actVerContactoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := (Length(edtlNombreInstalador.Text) > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfrViewDatosYSeleccionInstalador.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FMsgElegirInstalador := '';
|
|||
|
|
FController := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrViewDatosYSeleccionInstalador.Destroy;
|
|||
|
|
begin
|
|||
|
|
FController := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionInstalador.GetInstalador: IBizInstalador;
|
|||
|
|
begin
|
|||
|
|
Result := FInstalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionInstalador.GetController: IInstaladoresController;
|
|||
|
|
begin
|
|||
|
|
if not Assigned(FController) then
|
|||
|
|
FController := TInstaladoresController.Create;
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionInstalador.GetID_Instalador: integer;
|
|||
|
|
begin
|
|||
|
|
Result := -1;
|
|||
|
|
if Assigned(FInstalador) then
|
|||
|
|
Result := FInstalador.ID;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionInstalador.GetMsgElegirInstalador: String;
|
|||
|
|
begin
|
|||
|
|
Result := FMsgElegirInstalador;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetInstalador(Value: IBizInstalador);
|
|||
|
|
begin
|
|||
|
|
FInstalador := Value;
|
|||
|
|
if Assigned(FInstalador) then
|
|||
|
|
begin
|
|||
|
|
DADataSource.DataTable := FInstalador.DataTable;
|
|||
|
|
if not FInstalador.DataTable.Active then
|
|||
|
|
FInstalador.DataTable.Active := True;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
DADataSource.DataTable := NIL;
|
|||
|
|
|
|||
|
|
if Assigned(FOnInstaladorChanged) then
|
|||
|
|
FOnInstaladorChanged(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetController(Value: IInstaladoresController);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FController) then
|
|||
|
|
FController := NIL;
|
|||
|
|
|
|||
|
|
FController := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetID_Instalador(const Value: integer);
|
|||
|
|
begin
|
|||
|
|
Self.Instalador := IBizInstalador(Controller.Buscar(Value));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetMsgElegirInstalador(
|
|||
|
|
const Value: String);
|
|||
|
|
begin
|
|||
|
|
FMsgElegirInstalador := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionInstalador.GetOnInstaladorChanged: TNotifyEvent;
|
|||
|
|
begin
|
|||
|
|
Result := FOnInstaladorChanged;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetOnInstaladorChanged(
|
|||
|
|
const Value: TNotifyEvent);
|
|||
|
|
begin
|
|||
|
|
FOnInstaladorChanged := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionInstalador.SetReadOnly(Value: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if ReadOnly then
|
|||
|
|
begin
|
|||
|
|
actAnadirContacto.Enabled := False;
|
|||
|
|
actElegirContacto.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|