238 lines
7.2 KiB
ObjectPascal
238 lines
7.2 KiB
ObjectPascal
|
|
unit uViewDatosYSeleccionContrato;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, StdCtrls, cxControls, cxContainer, cxEdit, cxLabel,
|
|||
|
|
cxDBLabel, ExtCtrls, DB, uDADataTable, ComCtrls, ToolWin, ActnList, ImgList,
|
|||
|
|
PngImageList, cxTextEdit, cxDBEdit, pngimage, JvExControls, JvComponent, JvButton,
|
|||
|
|
JvTransparentButton, Mask, DBCtrls, dxLayoutControl, Buttons, uDAInterfaces,
|
|||
|
|
uBizContratosCliente, uContratosClienteController;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewDatosYSeleccionContrato = interface(IViewBase)
|
|||
|
|
['{B66D091E-27F3-45CB-9B3D-364BA5760CFC}']
|
|||
|
|
function GetIdContrato: integer;
|
|||
|
|
procedure SetIdContrato(const Value: integer);
|
|||
|
|
property IdContrato: integer read GetIdContrato write SetIdContrato;
|
|||
|
|
|
|||
|
|
function GetContrato: IBizContratoCliente;
|
|||
|
|
procedure SetContrato(const Value: IBizContratoCliente);
|
|||
|
|
property Contrato: IBizContratoCliente read GetContrato write SetContrato;
|
|||
|
|
|
|||
|
|
function GetOnContratoChanged : TNotifyEvent;
|
|||
|
|
procedure SetOnContratoChanged (const Value : TNotifyEvent);
|
|||
|
|
property OnContratoChanged : TNotifyEvent read GetOnContratoChanged
|
|||
|
|
write SetOnContratoChanged;
|
|||
|
|
|
|||
|
|
function GetMsgElegirContrato: String;
|
|||
|
|
procedure SetMsgElegirContrato(const Value: String);
|
|||
|
|
property MsgElegirContrato : String read GetMsgElegirContrato
|
|||
|
|
write SetMsgElegirContrato;
|
|||
|
|
|
|||
|
|
function GetDataItem: TDADataTable;
|
|||
|
|
procedure SetDataItem(const Value: TDADataTable);
|
|||
|
|
property DataItem : TDADataTable read GetDataItem write SetDataItem;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewDatosYSeleccionContrato = class(TfrViewBase, IViewDatosYSeleccionContrato)
|
|||
|
|
DADataSource: TDADataSource;
|
|||
|
|
ActionList1: TActionList;
|
|||
|
|
actElegirContrato: TAction;
|
|||
|
|
actAnadirContrato: TAction;
|
|||
|
|
actVerContrato: TAction;
|
|||
|
|
PngImageList: TPngImageList;
|
|||
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
Button1: TBitBtn;
|
|||
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|||
|
|
Button2: TBitBtn;
|
|||
|
|
dxLayoutControl1Item8: TdxLayoutItem;
|
|||
|
|
Button3: TBitBtn;
|
|||
|
|
dxLayoutControl1Item9: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
edtRefContrato: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|||
|
|
edtRefClienteContrato: TcxDBTextEdit;
|
|||
|
|
procedure actElegirContratoExecute(Sender: TObject);
|
|||
|
|
procedure actAnadirContratoExecute(Sender: TObject);
|
|||
|
|
procedure actVerContratoExecute(Sender: TObject);
|
|||
|
|
procedure actVerContratoUpdate(Sender: TObject);
|
|||
|
|
|
|||
|
|
private
|
|||
|
|
FDataItem : TDADataTable;
|
|||
|
|
FContrato: IBizContratoCliente;
|
|||
|
|
FController : IContratosClienteController;
|
|||
|
|
FOnContratoChanged : TNotifyEvent;
|
|||
|
|
FMsgElegirContrato: String;
|
|||
|
|
function GetMsgElegirContrato: String;
|
|||
|
|
procedure SetMsgElegirContrato(const Value: String);
|
|||
|
|
function GetDataItem: TDADataTable;
|
|||
|
|
procedure SetDataItem(const Value: TDADataTable);
|
|||
|
|
function GetContrato: IBizContratoCliente;
|
|||
|
|
procedure SetContrato(const Value: IBizContratoCliente);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
function GetOnContratoChanged : TNotifyEvent;
|
|||
|
|
procedure SetOnContratoChanged (const Value : TNotifyEvent);
|
|||
|
|
procedure SetReadOnly(Value: Boolean); override;
|
|||
|
|
function GetIdContrato: integer;
|
|||
|
|
procedure SetIdContrato(const Value: integer);
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
property DataItem : TDADataTable read GetDataItem write SetDataItem;
|
|||
|
|
property OnContratoChanged : TNotifyEvent read GetOnContratoChanged write SetOnContratoChanged;
|
|||
|
|
property MsgElegirContrato : String read GetMsgElegirContrato write SetMsgElegirContrato;
|
|||
|
|
property IdContrato: integer read GetIdContrato write SetIdContrato;
|
|||
|
|
property Contrato: IBizContratoCliente read GetContrato write SetContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleContratosCliente, Math, uCustomView;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.actElegirContratoExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AContrato : IBizContratoCliente;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
AContrato := (FController.ElegirContratos(FController.BuscarTodos, FMsgElegirContrato, False) as IBizContratoCliente);
|
|||
|
|
if Assigned(AContrato) then
|
|||
|
|
begin
|
|||
|
|
Self.Update;
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
Contrato := AContrato;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
AContrato := Nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.actAnadirContratoExecute(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AContrato : IBizContratoCliente;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AContrato := (FController.Nuevo as IBizContratoCliente);
|
|||
|
|
FController.Ver(AContrato);
|
|||
|
|
Contrato := AContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.actVerContratoExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FContrato) then
|
|||
|
|
FController.Ver(FContrato);
|
|||
|
|
if (Application.MessageBox('<27>Desea refrescar los datos del Contrato en el documento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
Contrato := Contrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.actVerContratoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := (Length(edtRefContrato.Text) > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfrViewDatosYSeleccionContrato.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FMsgElegirContrato := '';
|
|||
|
|
FContrato := Nil;
|
|||
|
|
FController := TContratosClienteController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrViewDatosYSeleccionContrato.Destroy;
|
|||
|
|
begin
|
|||
|
|
FContrato := Nil;
|
|||
|
|
FController := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionContrato.GetContrato: IBizContratoCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionContrato.GetDataItem: TDADataTable;
|
|||
|
|
begin
|
|||
|
|
Result := FDataItem;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionContrato.GetIdContrato: integer;
|
|||
|
|
begin
|
|||
|
|
Result := -1;
|
|||
|
|
if Assigned(FContrato) then
|
|||
|
|
Result := FContrato.ID;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionContrato.GetMsgElegirContrato: String;
|
|||
|
|
begin
|
|||
|
|
Result := FMsgElegirContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetContrato(const Value: IBizContratoCliente);
|
|||
|
|
begin
|
|||
|
|
FContrato := Value;
|
|||
|
|
if Assigned(FContrato) then
|
|||
|
|
if not FContrato.DataTable.Active then
|
|||
|
|
FContrato.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
if Assigned(FOnContratoChanged) then
|
|||
|
|
FOnContratoChanged(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetDataItem(const Value: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
FDataItem := Value;
|
|||
|
|
DADataSource.DataTable := FDataItem;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetIdContrato(const Value: integer);
|
|||
|
|
begin
|
|||
|
|
if (Value > 0) then
|
|||
|
|
begin
|
|||
|
|
FContrato := IBizContratoCliente(FController.Buscar(Value));
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetMsgElegirContrato(
|
|||
|
|
const Value: String);
|
|||
|
|
begin
|
|||
|
|
FMsgElegirContrato := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDatosYSeleccionContrato.GetOnContratoChanged: TNotifyEvent;
|
|||
|
|
begin
|
|||
|
|
Result := FOnContratoChanged;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetOnContratoChanged(
|
|||
|
|
const Value: TNotifyEvent);
|
|||
|
|
begin
|
|||
|
|
FOnContratoChanged := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDatosYSeleccionContrato.SetReadOnly(Value: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if ReadOnly then
|
|||
|
|
begin
|
|||
|
|
actAnadirContrato.Enabled := False;
|
|||
|
|
actElegirContrato.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|