git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@175 93f398dd-4eb6-7a46-baf6-13f46f578da2
238 lines
7.3 KiB
ObjectPascal
238 lines
7.3 KiB
ObjectPascal
unit uViewDatosYSeleccionComercial;
|
||
|
||
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, uComercialesController, dxLayoutControl, Buttons, uDAInterfaces;
|
||
|
||
type
|
||
IViewDatosYSeleccionComercial = interface(IViewBase)
|
||
['{CA00C39C-6204-4D8A-B550-8686FD810F6F}']
|
||
function GetController: IComercialesController;
|
||
procedure SetController(Value: IComercialesController);
|
||
property Controller: IComercialesController read GetController write SetController;
|
||
|
||
function GetComercial: IBizComercial;
|
||
procedure SetComercial(Value: IBizComercial);
|
||
property Comercial: IBizComercial read GetComercial write SetComercial;
|
||
|
||
function GetID_Comercial: integer;
|
||
procedure SetID_Comercial(const Value: integer);
|
||
property ID_Comercial: integer read GetID_Comercial write SetID_Comercial;
|
||
|
||
function GetOnComercialChanged : TNotifyEvent;
|
||
procedure SetOnComercialChanged (const Value : TNotifyEvent);
|
||
property OnComercialChanged : TNotifyEvent read GetOnComercialChanged
|
||
write SetOnComercialChanged;
|
||
|
||
function GetMsgElegirComercial: String;
|
||
procedure SetMsgElegirComercial(const Value: String);
|
||
property MsgElegirComercial : String read GetMsgElegirComercial
|
||
write SetMsgElegirComercial;
|
||
end;
|
||
|
||
TfrViewDatosYSeleccionComercial = class(TfrViewBase, IViewDatosYSeleccionComercial)
|
||
DADataSource: TDADataSource;
|
||
ActionList1: TActionList;
|
||
actElegirContacto: TAction;
|
||
actAnadirContacto: TAction;
|
||
actVerContacto: TAction;
|
||
PngImageList: TPngImageList;
|
||
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
||
dxLayoutControl1: TdxLayoutControl;
|
||
dxLayoutControl1Item1: TdxLayoutItem;
|
||
edtlNombreAgente: TcxDBTextEdit;
|
||
dxLayoutControl1Item2: TdxLayoutItem;
|
||
edtDelegacion: 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 : IComercialesController;
|
||
FComercial : IBizComercial;
|
||
FOnComercialChanged : TNotifyEvent;
|
||
FMsgElegirComercial: String;
|
||
function GetMsgElegirComercial: String;
|
||
procedure SetMsgElegirComercial(const Value: String);
|
||
|
||
protected
|
||
function GetController: IComercialesController;
|
||
procedure SetController(Value: IComercialesController);
|
||
function GetComercial: IBizComercial;
|
||
procedure SetComercial(Value: IBizComercial);
|
||
function GetOnComercialChanged : TNotifyEvent;
|
||
procedure SetOnComercialChanged (const Value : TNotifyEvent);
|
||
procedure SetReadOnly(Value: Boolean); override;
|
||
function GetID_Comercial: integer;
|
||
procedure SetID_Comercial(const Value: integer);
|
||
public
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
property Controller: IComercialesController read GetController write SetController;
|
||
property Comercial: IBizComercial read GetComercial write SetComercial;
|
||
property OnComercialChanged : TNotifyEvent read GetOnComercialChanged write SetOnComercialChanged;
|
||
property MsgElegirComercial : String read GetMsgElegirComercial write SetMsgElegirComercial;
|
||
property ID_Comercial: integer read GetID_Comercial write SetID_Comercial;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uDataModuleComerciales, Math, uCustomView;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.actElegirContactoExecute(Sender: TObject);
|
||
var
|
||
AComercial : IBizComercial;
|
||
begin
|
||
inherited;
|
||
AComercial := (Controller.ElegirContacto(Controller.BuscarTodos, FMsgElegirComercial, False) as IBizComercial);
|
||
if Assigned(AComercial) then
|
||
begin
|
||
Self.Update;
|
||
ShowHourglassCursor;
|
||
try
|
||
Comercial := AComercial;
|
||
finally
|
||
HideHourglassCursor;
|
||
end;
|
||
end;
|
||
AComercial := Nil;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.actAnadirContactoExecute(
|
||
Sender: TObject);
|
||
var
|
||
AComercial : IBizComercial;
|
||
begin
|
||
inherited;
|
||
AComercial := (Controller.Nuevo as IBizComercial);
|
||
Controller.Ver(AComercial);
|
||
Comercial := AComercial;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.actVerContactoExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
Controller.Ver(Comercial);
|
||
if (Application.MessageBox('<27>Desea refrescar los datos del comercial en el documento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
Comercial := Comercial;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.actVerContactoUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := (Length(edtlNombreAgente.Text) > 0);
|
||
end;
|
||
|
||
constructor TfrViewDatosYSeleccionComercial.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
FMsgElegirComercial := '';
|
||
FController := NIL;
|
||
end;
|
||
|
||
destructor TfrViewDatosYSeleccionComercial.Destroy;
|
||
begin
|
||
FController := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
function TfrViewDatosYSeleccionComercial.GetComercial: IBizComercial;
|
||
begin
|
||
Result := FComercial;
|
||
end;
|
||
|
||
function TfrViewDatosYSeleccionComercial.GetController: IComercialesController;
|
||
begin
|
||
if not Assigned(FController) then
|
||
FController := TComercialesController.Create;
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfrViewDatosYSeleccionComercial.GetID_Comercial: integer;
|
||
begin
|
||
Result := -1;
|
||
if Assigned(FComercial) then
|
||
Result := FComercial.ID;
|
||
end;
|
||
|
||
function TfrViewDatosYSeleccionComercial.GetMsgElegirComercial: String;
|
||
begin
|
||
Result := FMsgElegirComercial;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetComercial(Value: IBizComercial);
|
||
begin
|
||
FComercial := Value;
|
||
if Assigned(FComercial) then
|
||
begin
|
||
DADataSource.DataTable := FComercial.DataTable;
|
||
if not FComercial.DataTable.Active then
|
||
FComercial.DataTable.Active := True;
|
||
end
|
||
else
|
||
DADataSource.DataTable := NIL;
|
||
|
||
if Assigned(FOnComercialChanged) then
|
||
FOnComercialChanged(Self);
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetController(Value: IComercialesController);
|
||
begin
|
||
if Assigned(FController) then
|
||
FController := NIL;
|
||
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetID_Comercial(const Value: integer);
|
||
begin
|
||
Self.Comercial := IBizComercial(Controller.Buscar(Value));
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetMsgElegirComercial(
|
||
const Value: String);
|
||
begin
|
||
FMsgElegirComercial := Value;
|
||
end;
|
||
|
||
function TfrViewDatosYSeleccionComercial.GetOnComercialChanged: TNotifyEvent;
|
||
begin
|
||
Result := FOnComercialChanged;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetOnComercialChanged(
|
||
const Value: TNotifyEvent);
|
||
begin
|
||
FOnComercialChanged := Value;
|
||
end;
|
||
|
||
procedure TfrViewDatosYSeleccionComercial.SetReadOnly(Value: Boolean);
|
||
begin
|
||
inherited;
|
||
|
||
if ReadOnly then
|
||
begin
|
||
actAnadirContacto.Enabled := False;
|
||
actElegirContacto.Enabled := False;
|
||
end;
|
||
end;
|
||
|
||
end.
|