AbetoDesign_FactuGES2/Source/Modulos/Contactos/Views/uViewSubCuentaContacto.pas

207 lines
6.8 KiB
ObjectPascal
Raw Blame History

unit uViewSubCuentaContacto;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, ExtCtrls, StdCtrls, Buttons, DB, uDADataTable,
DBCtrls, Grids, DBGrids, uBizContactos, Mask, ComCtrls, uCustomView,
JvComponent, JvFormAutoSize, cxControls, cxContainer, cxEdit, cxTextEdit,
cxDBEdit, dxLayoutControl, uDAInterfaces, cxGraphics, cxDropDownEdit,
cxImageComboBox, cxMaskEdit, cxCalendar, ImgList, PngImageList, ActnList,
cxCurrencyEdit, uSubCuentasController, cxCheckBox;
type
IViewSubCuenta = interface(IViewBase)
['{F01E0772-4D72-41DD-AFEF-4BA6548A1FC6}']
function GetContacto: IBizContacto;
procedure SetContacto(const Value: IBizContacto);
property Contacto: IBizContacto read GetContacto write SetContacto;
end;
TfrViewSubCuentaContacto = class(TfrViewBase, IViewSubCuenta)
DADataSource: TDADataSource;
layoutApunteGroup_Root: TdxLayoutGroup;
layoutApunte: TdxLayoutControl;
layoutApunteGroup1: TdxLayoutGroup;
layoutApunteItem2: TdxLayoutItem;
eRefSubCuenta: TcxDBTextEdit;
layoutApunteItem4: TdxLayoutItem;
BitBtn3: TBitBtn;
actLista: TActionList;
actElegirSubCuenta: TAction;
layoutApunteItem5: TdxLayoutItem;
eSubCuenta: TcxDBTextEdit;
layoutApunteGroup3: TdxLayoutGroup;
actVerSubcuenta: TAction;
actAnadirSubcuenta: TAction;
layoutApunteItem1: TdxLayoutItem;
BitBtn1: TBitBtn;
layoutApunteItem3: TdxLayoutItem;
BitBtn2: TBitBtn;
layoutApunteItem6: TdxLayoutItem;
cbIgnorarContabilidad: TcxDBCheckBox;
layoutApunteGroup2: TdxLayoutGroup;
SmallImages: TPngImageList;
layoutApunteItem7: TdxLayoutItem;
rdTipoSubcuenta: TDBRadioGroup;
procedure CustomViewCreate(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
procedure actElegirSubCuentaExecute(Sender: TObject);
procedure actAnadirSubcuentaExecute(Sender: TObject);
procedure actVerSubcuentaExecute(Sender: TObject);
procedure cbIgnorarContabilidadPropertiesChange(Sender: TObject);
procedure actElegirSubCuentaUpdate(Sender: TObject);
procedure actAnadirSubcuentaUpdate(Sender: TObject);
procedure actVerSubcuentaUpdate(Sender: TObject);
procedure CustomViewShow(Sender: TObject);
protected
FController : ISubcuentasController;
FContacto: IBizContacto;
function GetContacto: IBizContacto;
procedure SetContacto(const Value: IBizContacto);
public
property Contacto: IBizContacto read GetContacto write SetContacto;
end;
implementation
{$R *.dfm}
uses uFactuGes_App;
{ TfrViewSubCuenta }
{
******************************* TfrViewSubCuenta ********************************
}
procedure TfrViewSubCuentaContacto.actAnadirSubcuentaExecute(Sender: TObject);
begin
inherited;
if Supports(FContacto, IBizCliente) then
FController.AnadirSubCuentaContacto((Contacto as IBizCliente).SubCuentas, CTE_CUENTASCLIENTE)
else if Supports(FContacto, IBizProveedor) then
FController.AnadirSubCuentaContacto((Contacto as IBizProveedor).SubCuentas, CTE_CUENTASPROVEEDOR);
end;
procedure TfrViewSubCuentaContacto.actAnadirSubcuentaUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Enabled := (not (cbIgnorarContabilidad.Checked))
and (DADataSource.DataTable.IsEmpty);
end;
procedure TfrViewSubCuentaContacto.actElegirSubCuentaExecute(Sender: TObject);
begin
inherited;
if Supports(FContacto, IBizCliente) then
FController.ElegirSubCuentaContacto((Contacto as IBizCliente).SubCuentas, CTE_CUENTASCLIENTE)
else if Supports(FContacto, IBizProveedor) then
FController.ElegirSubCuentaContacto((Contacto as IBizProveedor).SubCuentas, CTE_CUENTASPROVEEDOR);
end;
procedure TfrViewSubCuentaContacto.actElegirSubCuentaUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Enabled := (not (cbIgnorarContabilidad.Checked))
and (DADataSource.DataTable.IsEmpty);
end;
procedure TfrViewSubCuentaContacto.actVerSubcuentaExecute(Sender: TObject);
begin
inherited;
if Supports(FContacto, IBizCliente) then
FController.VerSubCuentaContacto((Contacto as IBizCliente).SubCuentas)
else if Supports(FContacto, IBizProveedor) then
FController.VerSubCuentaContacto((Contacto as IBizProveedor).SubCuentas);
end;
procedure TfrViewSubCuentaContacto.actVerSubcuentaUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Enabled := (not eRefSubCuenta.DataBinding.Field.IsNull)
and (not cbIgnorarContabilidad.Checked);
end;
procedure TfrViewSubCuentaContacto.cbIgnorarContabilidadPropertiesChange(Sender: TObject);
begin
inherited;
if cbIgnorarContabilidad.Checked then
begin
if Supports(FContacto, IBizCliente) then
FController.EliminarSubCuentaContacto((Contacto as IBizCliente).SubCuentas)
else if Supports(FContacto, IBizProveedor) then
FController.EliminarSubCuentaContacto((Contacto as IBizProveedor).SubCuentas);
end
else
//Rellenar automaticamente la cuenta seg<65>n la tienda a la que pertenezca
end;
{
function TfrViewApunte.GetController: IApuntesController;
begin
Result := FController;
end;
}
procedure TfrViewSubCuentaContacto.CustomViewCreate(Sender: TObject);
begin
inherited;
FController := TSubcuentasController.Create;
end;
procedure TfrViewSubCuentaContacto.CustomViewDestroy(Sender: TObject);
begin
FController := Nil;
inherited;
end;
procedure TfrViewSubCuentaContacto.CustomViewShow(Sender: TObject);
begin
inherited;
//Solo se activar<61> la vista de contabilidad si existe un ejercicio activo
if Assigned(AppFactuGES.EjercicioActivo) then
begin
layoutApunte.Enabled := True;
actLista.State := asNormal;
cbIgnorarContabilidad.Enabled := True;
BitBtn1.Enabled := True;
BitBtn2.Enabled := True;
BitBtn3.Enabled := True;
rdTipoSubcuenta.Enabled := True;
end
else
begin
layoutApunte.Enabled := False;
actLista.State := asSuspended;
cbIgnorarContabilidad.Enabled := False;
BitBtn1.Enabled := False;
BitBtn2.Enabled := False;
BitBtn3.Enabled := False;
rdTipoSubcuenta.Enabled := False;
end;
end;
function TfrViewSubCuentaContacto.GetContacto: IBizContacto;
begin
Result := FContacto;
end;
procedure TfrViewSubCuentaContacto.SetContacto(const Value: IBizContacto);
begin
FContacto := Value;
if Assigned(FContacto) then
begin
if Supports(FContacto, IBizCliente) then
DADataSource.DataTable := (FContacto as IBizCliente).SubCuentas.DataTable
else if Supports(FContacto, IBizProveedor) then
DADataSource.DataTable := (FContacto as IBizProveedor).SubCuentas.DataTable;
end
else
DADataSource.DataTable := NIL;
end;
end.