git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@25 9a1d36f3-7752-2d40-8ccb-50eb49674c68
192 lines
5.5 KiB
ObjectPascal
192 lines
5.5 KiB
ObjectPascal
unit uViewDatosYSeleccionContacto;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, StdCtrls, cxControls, cxContainer, cxEdit, cxLabel,
|
|
cxDBLabel, ExtCtrls, DB, uDADataTable, uBizContacto,
|
|
ComCtrls, ToolWin, ActnList, ImgList, PngImageList, cxTextEdit, cxDBEdit,
|
|
pngimage, JvExControls, JvComponent, JvButton, JvTransparentButton, Mask,
|
|
DBCtrls;
|
|
|
|
type
|
|
IViewDatosYSeleccionContacto = interface(IViewBase)
|
|
['{FCBC26C6-5B00-4985-B8AD-E91C79BE469B}']
|
|
function GetContacto: IBizContacto;
|
|
procedure SetContacto(Value: IBizContacto);
|
|
property Contacto: IBizContacto read GetContacto write SetContacto;
|
|
|
|
function GetOnContactoChanged : TNotifyEvent;
|
|
procedure SetOnContactoChanged (const Value : TNotifyEvent);
|
|
property OnContactoChanged : TNotifyEvent read GetOnContactoChanged
|
|
write SetOnContactoChanged;
|
|
end;
|
|
|
|
TfrViewDatosYSeleccionContacto = class(TfrViewBase, IViewDatosYSeleccionContacto)
|
|
DADataSource: TDADataSource;
|
|
Label5: TLabel;
|
|
Bevel1: TBevel;
|
|
ToolBar1: TToolBar;
|
|
ToolButton1: TToolButton;
|
|
ActionList1: TActionList;
|
|
actElegirContacto: TAction;
|
|
ToolButton2: TToolButton;
|
|
actAnadirContacto: TAction;
|
|
actVerContacto: TAction;
|
|
PngImageList: TPngImageList;
|
|
edtlNombre: TcxDBTextEdit;
|
|
edtPoblacion: TcxDBTextEdit;
|
|
edtProvincia: TcxDBTextEdit;
|
|
edtNIFCIF: TcxDBTextEdit;
|
|
lblNombre: TLabel;
|
|
lblNIFCIF: TLabel;
|
|
edtCalle: TcxDBTextEdit;
|
|
lblCalle: TLabel;
|
|
lblPoblacion: TLabel;
|
|
lblProvincia: TLabel;
|
|
ToolButton3: TToolButton;
|
|
ToolBar2: TToolBar;
|
|
ToolButton4: TToolButton;
|
|
lblCodigoPostal: TLabel;
|
|
edtCodigoPostal: TcxDBTextEdit;
|
|
procedure actElegirContactoExecute(Sender: TObject);
|
|
procedure actAnadirContactoExecute(Sender: TObject);
|
|
procedure actVerContactoExecute(Sender: TObject);
|
|
procedure actVerContactoUpdate(Sender: TObject);
|
|
procedure cxLabel1Click(Sender: TObject);
|
|
private
|
|
FContacto : IBizContacto;
|
|
FOnContactoChanged : TNotifyEvent;
|
|
protected
|
|
function GetContacto: IBizContacto;
|
|
procedure SetContacto(Value: IBizContacto);
|
|
function GetOnContactoChanged : TNotifyEvent;
|
|
procedure SetOnContactoChanged (const Value : TNotifyEvent);
|
|
public
|
|
property Contacto: IBizContacto read GetContacto write SetContacto;
|
|
property OnContactoChanged : TNotifyEvent read GetOnContactoChanged
|
|
write SetOnContactoChanged;
|
|
end;
|
|
|
|
var
|
|
frViewDatosYSeleccionContacto: TfrViewDatosYSeleccionContacto;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
uDataModuleContactos, Math;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.actElegirContactoExecute(Sender: TObject);
|
|
var
|
|
AContacto : IBizContacto;
|
|
begin
|
|
inherited;
|
|
{ case FContacto.Categorias.CODIGOCATEGORIA of
|
|
CLIENTE : AContacto := dmContactos.GetClientes;
|
|
PROVEEDOR : AContacto := dmContactos.GetProveedores;
|
|
INSTALADOR : AContacto := dmContactos.GetInstaladores;
|
|
end;}
|
|
|
|
if Supports(FContacto, IBizInstalador) then
|
|
AContacto := dmContactos.GetInstaladores;
|
|
if Supports(FContacto, IBizCliente) then
|
|
AContacto := dmContactos.GetClientes;
|
|
if Supports(FContacto, IBizProveedor) then
|
|
AContacto := dmContactos.GetProveedores;
|
|
|
|
try
|
|
if AContacto.ShowForSelect = mrOK then
|
|
begin
|
|
Contacto := dmContactos.GetItemsSeleccionados(AContacto);
|
|
end;
|
|
finally
|
|
AContacto := NIL;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.actAnadirContactoExecute(
|
|
Sender: TObject);
|
|
var
|
|
AContactos : IBizContacto;
|
|
begin
|
|
inherited;
|
|
{ case FContacto.Categorias.CODIGOCATEGORIA of
|
|
CLIENTE : AContactos := dmContactos.GetCliente(-1);
|
|
PROVEEDOR : AContactos := dmContactos.GetProveedor(-1);
|
|
end;}
|
|
|
|
if Supports(FContacto, IBizProveedor) then
|
|
AContactos := dmContactos.GetProveedor(-1);
|
|
if Supports(FContacto, IBizCliente) then
|
|
AContactos := dmContactos.GetCliente(-1);
|
|
|
|
try
|
|
AContactos.DataTable.Active := True;
|
|
AContactos.Insert;
|
|
AContactos.Show;
|
|
if AContactos.DataTable.RecordCount > 0 then
|
|
Contacto := AContactos;
|
|
finally
|
|
AContactos := NIL;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.actVerContactoExecute(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
|
|
if Assigned(Contacto) then
|
|
begin
|
|
Contacto.DataTable.Open;
|
|
if (Contacto.DataTable.RecordCount = 0) or (Contacto.BAJA_LOGICA = 1) then
|
|
ShowMessage('La ficha ha sido eliminada del programa.')
|
|
else
|
|
Contacto.Show;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.actVerContactoUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
(Sender as TAction).Enabled := Length(edtlNombre.Text) > 0;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.cxLabel1Click(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
actVerContacto.Execute;
|
|
end;
|
|
|
|
function TfrViewDatosYSeleccionContacto.GetContacto: IBizContacto;
|
|
begin
|
|
Result := FContacto;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.SetContacto(Value: IBizContacto);
|
|
begin
|
|
FContacto := Value;
|
|
DADataSource.DataTable := FContacto.DataTable;
|
|
|
|
if not FContacto.DataTable.Active then
|
|
FContacto.DataTable.Active := True;
|
|
|
|
if Assigned(FOnContactoChanged) then
|
|
FOnContactoChanged(Self);
|
|
end;
|
|
|
|
function TfrViewDatosYSeleccionContacto.GetOnContactoChanged: TNotifyEvent;
|
|
begin
|
|
Result := FOnContactoChanged;
|
|
end;
|
|
|
|
procedure TfrViewDatosYSeleccionContacto.SetOnContactoChanged(
|
|
const Value: TNotifyEvent);
|
|
begin
|
|
FOnContactoChanged := Value;
|
|
end;
|
|
|
|
end.
|