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

190 lines
6.0 KiB
ObjectPascal
Raw Normal View History

unit uViewClienteDatosComerciales;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, cxGraphics, DB, uDADataTable, dxLayoutControl,
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit,
cxDBLookupEdit, cxDBLookupComboBox, cxControls, cxSpinEdit, cxDBEdit,
uBizContactos, cxCheckBox, StdCtrls, uFormasPagoController, uTiposIVAController,
uDAInterfaces, uBizFormasPago, uBizTiposIVA, cxCurrencyEdit, uComercialesController;
type
IViewClienteDatosComerciales = interface(IViewBase)
['{50D671FA-1109-4D7D-B3F8-8E7DCFEB32A4}']
function GetContacto: IBizContacto;
procedure SetContacto(const Value: IBizContacto);
property Contacto: IBizContacto read GetContacto write SetContacto;
end;
TfrViewClienteDatosComerciales = class(TfrViewBase, IViewClienteDatosComerciales)
dxLayoutControl1: TdxLayoutControl;
dxLayoutGroup1: TdxLayoutGroup;
dxLayoutControl1Group3: TdxLayoutGroup;
dsAgentes: TDADataSource;
dxLayoutControl1Item2: TdxLayoutItem;
eDiasVencimiento: TcxDBSpinEdit;
dxLayoutControl1Item3: TdxLayoutItem;
cbRegimenIVA: TcxDBComboBox;
dsDatosComerciales: TDADataSource;
dxLayoutControl1Item4: TdxLayoutItem;
cbRecargoEquivalencia: TcxDBCheckBox;
dsFormaPago: TDADataSource;
dxLayoutControl1Item5: TdxLayoutItem;
cbFormaPago: TcxDBLookupComboBox;
dxLayoutControl1Group5: TdxLayoutGroup;
Label1: TLabel;
dxLayoutControl1Item6: TdxLayoutItem;
bFormasPago: TButton;
dxLayoutControl1Item7: TdxLayoutItem;
dxLayoutControl1Item8: TdxLayoutItem;
eIVA: TcxDBLookupComboBox;
dxLayoutControl1Item9: TdxLayoutItem;
bTiposIVA: TButton;
dsTiposIVA: TDADataSource;
dxLayoutControl1Group1: TdxLayoutGroup;
dxLayoutControl1Group2: TdxLayoutGroup;
dxLayoutControl1Item1: TdxLayoutItem;
cxDBSpinEdit1: TcxDBSpinEdit;
dxLayoutControl1Item10: TdxLayoutItem;
cxDBSpinEdit2: TcxDBSpinEdit;
dxLayoutControl1Item11: TdxLayoutItem;
eDescuentoLinea: TcxDBSpinEdit;
dxLayoutControl1Group4: TdxLayoutGroup;
dxLayoutControl1Group6: TdxLayoutGroup;
dxLayoutControl1Item12: TdxLayoutItem;
Label2: TLabel;
dxLayoutControl1Item13: TdxLayoutItem;
eDescuento: TcxDBSpinEdit;
dxLayoutControl1Item14: TdxLayoutItem;
ePrecioPunto: TcxDBCurrencyEdit;
dxLayoutControl1Item15: TdxLayoutItem;
cbComercial: TcxDBLookupComboBox;
dxLayoutControl1Group8: TdxLayoutGroup;
procedure CustomViewCreate(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
procedure cbRegimenIVAPropertiesInitPopup(Sender: TObject);
procedure bFormasPagoClick(Sender: TObject);
procedure bTiposIVAClick(Sender: TObject);
procedure CustomViewShow(Sender: TObject);
protected
FContacto : IBizContacto;
FTiposIVA : IBizTipoIVA;
FComerciales : IBizComercial;
FFormasPago : IBizFormaPago;
FFormasPagoController : IFormasPagoController;
FTiposIVAController : ITiposIVAController;
FComercialesController : IComercialesController;
function GetContacto: IBizContacto;
procedure SetContacto(const Value: IBizContacto);
public
property Contacto: IBizContacto read GetContacto write SetContacto;
end;
implementation
{$R *.dfm}
uses
uRegimenIVAUtils, uFactuGES_App;
{ TfrViewClienteDatosComerciales }
procedure TfrViewClienteDatosComerciales.bFormasPagoClick(Sender: TObject);
begin
inherited;
if Assigned(FFormasPago) then
FFormasPagoController.VerTodos(FFormasPago);
end;
procedure TfrViewClienteDatosComerciales.bTiposIVAClick(Sender: TObject);
begin
inherited;
if Assigned(FTiposIVA) then
FTiposIVAController.VerTodos(FTiposIVA);
end;
procedure TfrViewClienteDatosComerciales.cbRegimenIVAPropertiesInitPopup(
Sender: TObject);
begin
inherited;
with cbRegimenIVA.Properties do
begin
if Items.Count = 0 then
Items := DarRegimenesIVA;
end;
end;
procedure TfrViewClienteDatosComerciales.CustomViewCreate(Sender: TObject);
begin
inherited;
FTiposIVA := Nil;
FComerciales := Nil;
FFormasPago := Nil;
FContacto := Nil;
FComercialesController := TComercialesController.Create;
FFormasPagoController := TFormasPagoController.Create;
FTiposIVAController := TTiposIVAController.Create;
end;
procedure TfrViewClienteDatosComerciales.CustomViewDestroy(Sender: TObject);
begin
inherited;
FTiposIVA := Nil;
FComerciales := Nil;
FFormasPago := Nil;
FContacto := Nil;
FComercialesController := NIL;
FFormasPagoController := NIL;
FTiposIVAController := NIL;
end;
procedure TfrViewClienteDatosComerciales.CustomViewShow(Sender: TObject);
begin
inherited;
//Solo se ve campo comercial en abeto
if (AppFactuGES.EmpresaActiva.ID = CTE_EMPRESA_ABETO) then
begin
dxLayoutControl1Group8.Enabled := True;
dxLayoutControl1Group8.Visible := True;
end
else
begin
dxLayoutControl1Group8.Enabled := False;
dxLayoutControl1Group8.Visible := False;
end;
end;
function TfrViewClienteDatosComerciales.GetContacto: IBizContacto;
begin
Result := FContacto;
end;
procedure TfrViewClienteDatosComerciales.SetContacto(const Value: IBizContacto);
begin
FContacto := Value;
if Assigned(FContacto) then
begin
dsDatosComerciales.DataTable := FContacto.DataTable;
FFormasPago := FFormasPagoController.BuscarTodos;
dsFormaPago.DataTable := FFormasPago.DataTable;
dsFormaPago.DataTable.Active := True;
FTiposIVA := FTiposIVAController.BuscarTodos;
dsTiposIVA.DataTable := FTiposIVA.DataTable;
dsTiposIVA.DataTable.Active := True;
FComerciales := (FComercialesController.BuscarTodos as IBizComercial);
dsAgentes.DataTable := FComerciales.DataTable;
dsAgentes.DataTable.Active := True;
end
else begin
dsDatosComerciales.DataTable := NIL;
dsAgentes.DataTable := NIL;
dsFormaPago.DataTable := NIL;
dsTiposIVA.DataTable := NIL;
end
end;
end.