This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES2/Source/Modulos/Facturas proforma/Views/uViewFacturaProforma.pas
2014-01-14 13:56:10 +00:00

236 lines
7.9 KiB
ObjectPascal
Raw Blame History

unit uViewFacturaProforma;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, DB, uDADataTable, uCustomView,
uBizFacturasProforma,
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutControl,
cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxSpinEdit, StdCtrls, Mask,
DBCtrls, cxGraphics, dxLayoutLookAndFeels, cxLookupEdit, cxDBLookupEdit,
cxDBLookupComboBox, uFormasPagoController, uDAInterfaces, uBizFormasPago,
ActnList, uViewDatosYSeleccionClienteFacturaProforma, uFacturasProformaController;
type
IViewFacturaProforma = interface(IViewBase)
['{78EE6F9A-C742-4F01-B8F9-8E1BE77E491B}']
function GetFactura: IBizFacturaProforma;
procedure SetFactura(const Value: IBizFacturaProforma);
property Factura: IBizFacturaProforma read GetFactura write SetFactura;
function GetController : IFacturasProformaController;
procedure SetController (const Value : IFacturasProformaController);
property Controller : IFacturasProformaController read GetController write SetController;
function GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaProforma;
property ViewClienteFactura: IViewDatosYSeleccionClienteFacturaProforma read GetViewClienteFactura;
end;
TfrViewFacturaProforma = class(TfrViewBase, IViewFacturaProforma)
DADataSource: TDADataSource;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutControl1Item1: TdxLayoutItem;
eReferencia: TcxDBTextEdit;
dxLayoutControl1Item2: TdxLayoutItem;
edtFecha: TcxDBDateEdit;
dxLayoutControl1Group1: TdxLayoutGroup;
dxLayoutControl1Group2: TdxLayoutGroup;
dxLayoutControl1Item5: TdxLayoutItem;
memObservaciones: TcxDBMemo;
dxLayoutControl1Group5: TdxLayoutGroup;
dxLayoutControl1Item6: TdxLayoutItem;
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
dsFormaPago: TDADataSource;
dxLayoutControl1Item4: TdxLayoutItem;
cbFormaPago: TcxDBLookupComboBox;
dxLayoutControl1Item10: TdxLayoutItem;
bFormasPago: TButton;
dxLayoutControl1Item3: TdxLayoutItem;
cbCuentaBancaria: TcxDBComboBox;
ActionList1: TActionList;
dxLayoutControl1Group9: TdxLayoutGroup;
dxLayoutControl1Group6: TdxLayoutGroup;
dxLayoutControl1Group4: TdxLayoutGroup;
ledtFechaVencimiento: TdxLayoutItem;
edtFechaVencimiento: TcxDBDateEdit;
dxLayoutControl1Group3: TdxLayoutGroup;
dxLayoutControl1Item11: TdxLayoutItem;
frViewDatosYSeleccionClienteFacturaProforma1: TfrViewDatosYSeleccionClienteFacturaProforma;
dxLayoutControl1Item7: TdxLayoutItem;
cbSituacion: TcxDBComboBox;
procedure bFormasPagoClick(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
procedure CustomViewCreate(Sender: TObject);
procedure edtFechaVemcimientoPropertiesEditValueChanged(Sender: TObject);
protected
FFactura : IBizFacturaProforma;
FController : IFacturasProformaController;
FFormasPago : IBizFormaPago;
FFormasPagoController : IFormasPagoController;
FViewClienteFactura : IViewDatosYSeleccionClienteFacturaProforma;
function GetFactura: IBizFacturaProforma;
procedure SetFactura(const Value: IBizFacturaProforma);
function GetController : IFacturasProformaController;
procedure SetController (const Value : IFacturasProformaController);
procedure RellenarCuentasBancarias;
function GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaProforma;
public
property Factura: IBizFacturaProforma read GetFactura write SetFactura;
property Controller : IFacturasProformaController read GetController write SetController;
property ViewClienteFactura: IViewDatosYSeleccionClienteFacturaProforma read GetViewClienteFactura;
end;
implementation
uses
uDataModuleContactos, schFacturasProformaClient_Intf, uFactuGES_App,
uEmpresasController, uClientesController, uBizContactos, uBizDireccionesContacto;
{$R *.dfm}
{ TfrViewFacturaProforma }
procedure TfrViewFacturaProforma.bFormasPagoClick(Sender: TObject);
begin
inherited;
if Assigned(FFormasPago) then
FFormasPagoController.VerTodos(FFormasPago);
end;
procedure TfrViewFacturaProforma.CustomViewCreate(Sender: TObject);
begin
inherited;
FFormasPago := Nil;
FFormasPagoController := TFormasPagoController.Create;
FViewClienteFactura := frViewDatosYSeleccionClienteFacturaProforma1;
end;
procedure TfrViewFacturaProforma.CustomViewDestroy(Sender: TObject);
begin
inherited;
FFormasPago := Nil;
FFormasPagoController := NIL;
FViewClienteFactura := NIL;
end;
procedure TfrViewFacturaProforma.edtFechaVemcimientoPropertiesEditValueChanged(
Sender: TObject);
begin
if Assigned(FFormasPago) then
if (FFormasPago.Plazos.RecordCount = 0) then
ledtFechaVencimiento.Enabled := True
else
ledtFechaVencimiento.Enabled := False;
end;
function TfrViewFacturaProforma.GetController: IFacturasProformaController;
begin
Result := FController;
end;
function TfrViewFacturaProforma.GetFactura: IBizFacturaProforma;
begin
Result := FFactura;
end;
function TfrViewFacturaProforma.GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaProforma;
begin
Result := FViewClienteFactura;
end;
procedure TfrViewFacturaProforma.RellenarCuentasBancarias;
var
AController : IEmpresasController;
ALista : TStringList;
AListaIBAN : TStringList;
AListaCliente: TStringList;
i : integer;
begin
AController := TEmpresasController.Create;
try
ALista := AController.DarListaCuentasBancarias(AppFactuGES.EmpresaActiva);
AListaIBAN := AController.DarListaCuentasBancariasIBAN(AppFactuGES.EmpresaActiva);
AListaCliente := Controller.ClienteController.DarListaCuentasBancarias(FFactura.ID_CLIENTE);
try
with cbCuentaBancaria.Properties.Items do
begin
BeginUpdate;
try
Clear;
Add('');
for i := 0 to ALista.Count - 1 do
Add(ALista.Names[i]);
if AListaIBAN.Count > 0 then
begin
Add('--------------');
for i := 0 to AListaIBAN.Count - 1 do
Add(AListaIBAN.Names[i]);
end;
if AListaCliente.Count > 0 then
begin
Add('--------------');
for i := 0 to AListaCliente.Count - 1 do
Add(AListaCliente.Names[i]);
end;
finally
EndUpdate;
end;
end;
finally
FreeANDNIL(ALista);
FreeANDNIL(AListaIBAN);
end;
finally
AController := NIL;
end;
end;
procedure TfrViewFacturaProforma.SetController(const Value: IFacturasProformaController);
begin
FController := Value;
end;
procedure TfrViewFacturaProforma.SetFactura(const Value: IBizFacturaProforma);
var
ACadena : String;
begin
FFactura := Value;
RellenarCuentasBancarias;
if Assigned(FFactura) then
begin
DADataSource.DataTable := FFactura.DataTable;
FViewClienteFactura.Factura := FFactura;
FFormasPago := FFormasPagoController.BuscarTodos;
dsFormaPago.DataTable := FFormasPago.DataTable;
dsFormaPago.DataTable.Active := True;
//Posicionamos la tabla en la forma de pago que tiene la factura ya que no lo hace el componente por si solo
FFormasPago.DataTable.Locate(fld_FacturasProformaID, FFactura.ID_FORMA_PAGO, []);
if (FFormasPago.Plazos.RecordCount = 0) then
ledtFechaVencimiento.Enabled := True
else
ledtFechaVencimiento.Enabled := False;
ACadena := 'Elija el cliente al que se le realizar<61> la factura.';
//ViewDatosYSeleccionClienteFacturaProforma1.MsgElegirCliente := ACadena;
end
else begin
DADataSource.DataTable := NIL;
dsFormaPago.DataTable := NIL;
FViewClienteFactura.Factura := NIL;
end;
end;
end.