123 lines
3.4 KiB
ObjectPascal
123 lines
3.4 KiB
ObjectPascal
|
|
unit uViewContactosAsociados;
|
||
|
|
|
||
|
|
interface
|
||
|
|
|
||
|
|
uses
|
||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
|
|
Dialogs, uViewBase, ComCtrls, ToolWin, dxLayoutControl, StdCtrls, DB,
|
||
|
|
uDADataTable, cxControls, ImgList, PngImageList, uBizContacto,
|
||
|
|
cxContainer, cxEdit, cxTextEdit, cxMemo, Grids, DBGrids, DBCtrls,
|
||
|
|
ActnList, XPMan;
|
||
|
|
|
||
|
|
type
|
||
|
|
IViewContactosAsociados = interface(IViewBase)
|
||
|
|
['{2074C14D-12BD-42EC-8A49-8E66BE20BD3B}']
|
||
|
|
end;
|
||
|
|
|
||
|
|
TfrViewContactosAsociados = class(TfrViewBase, IViewContactosAsociados)
|
||
|
|
dxLayoutControl1: TdxLayoutControl;
|
||
|
|
dxLayoutGroup1: TdxLayoutGroup;
|
||
|
|
dxLayoutGroup2: TdxLayoutGroup;
|
||
|
|
DADataSource1: TDADataSource;
|
||
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
||
|
|
ToolBar2: TToolBar;
|
||
|
|
bAsociarContacto: TToolButton;
|
||
|
|
PngImageList: TPngImageList;
|
||
|
|
bEliminarContactoAsociado: TToolButton;
|
||
|
|
DBLookupListBox1: TDBLookupListBox;
|
||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
||
|
|
bEditar: TToolButton;
|
||
|
|
ActionList1: TActionList;
|
||
|
|
actAnadir: TAction;
|
||
|
|
actEliminar: TAction;
|
||
|
|
actEditar: TAction;
|
||
|
|
XPManifest1: TXPManifest;
|
||
|
|
procedure actEditarUpdate(Sender: TObject);
|
||
|
|
procedure actEliminarUpdate(Sender: TObject);
|
||
|
|
procedure actEditarExecute(Sender: TObject);
|
||
|
|
procedure actEliminarExecute(Sender: TObject);
|
||
|
|
procedure actAnadirExecute(Sender: TObject);
|
||
|
|
private
|
||
|
|
FContacto : IBizContacto;
|
||
|
|
protected
|
||
|
|
function GetContacto: IBizContacto;
|
||
|
|
procedure SetContacto(const Value: IBizContacto);
|
||
|
|
public
|
||
|
|
property Contacto: IBizContacto read GetContacto write SetContacto;
|
||
|
|
end;
|
||
|
|
|
||
|
|
var
|
||
|
|
frViewContactosAsociados: TfrViewContactosAsociados;
|
||
|
|
|
||
|
|
implementation
|
||
|
|
|
||
|
|
uses LiteralesContactos, uDataModuleContactos;
|
||
|
|
|
||
|
|
{$R *.dfm}
|
||
|
|
|
||
|
|
{ TfrViewCategoriasContacto }
|
||
|
|
|
||
|
|
function TfrViewContactosAsociados.GetContacto: IBizContacto;
|
||
|
|
begin
|
||
|
|
Result := FContacto;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.SetContacto(const Value: IBizContacto);
|
||
|
|
begin
|
||
|
|
FContacto := Value;
|
||
|
|
if Assigned(FContacto) then
|
||
|
|
DADataSource1.DataTable := FContacto.Asociados.DataTable
|
||
|
|
else
|
||
|
|
DADataSource1.DataTable := NIL;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.actEditarUpdate(Sender: TObject);
|
||
|
|
begin
|
||
|
|
inherited;
|
||
|
|
(Sender as TAction).Enabled := not Contacto.Asociados.IsEmpty;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.actEliminarUpdate(Sender: TObject);
|
||
|
|
begin
|
||
|
|
inherited;
|
||
|
|
(Sender as TAction).Enabled := not Contacto.Asociados.IsEmpty;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.actEditarExecute(Sender: TObject);
|
||
|
|
var
|
||
|
|
AContacto : IBizContacto;
|
||
|
|
begin
|
||
|
|
try
|
||
|
|
AContacto := dmContactos.GetContacto(Contacto.Asociados.CODIGOASOCIADO);
|
||
|
|
AContacto.Show;
|
||
|
|
Contacto.Asociados.UpdateContactoAsociado(AContacto);
|
||
|
|
finally
|
||
|
|
AContacto := Nil;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.actEliminarExecute(Sender: TObject);
|
||
|
|
begin
|
||
|
|
if (MessageDlg(msgLitBorrarContactoAsociado, mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
||
|
|
Contacto.Asociados.Delete;
|
||
|
|
end;
|
||
|
|
|
||
|
|
procedure TfrViewContactosAsociados.actAnadirExecute(Sender: TObject);
|
||
|
|
var
|
||
|
|
AContactos : IBizContacto;
|
||
|
|
begin
|
||
|
|
AContactos := dmContactos.GetContactos;
|
||
|
|
|
||
|
|
try
|
||
|
|
if AContactos.ShowForMultiSelect = mrOK then
|
||
|
|
begin
|
||
|
|
AContactos := dmContactos.GetItemsSeleccionados(AContactos);
|
||
|
|
Contacto.Asociados.AppendContactos(Contacto.CODIGO, AContactos);
|
||
|
|
end;
|
||
|
|
finally
|
||
|
|
AContactos := NIL;
|
||
|
|
end;
|
||
|
|
end;
|
||
|
|
|
||
|
|
end.
|