179 lines
6.2 KiB
ObjectPascal
179 lines
6.2 KiB
ObjectPascal
|
|
unit uViewFacturaCliente;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, DB, uDADataTable, uCustomView,
|
|||
|
|
uViewDatosYSeleccionCliente, uBizFacturasCliente,
|
|||
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutControl,
|
|||
|
|
cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxSpinEdit, StdCtrls, Mask,
|
|||
|
|
DBCtrls, cxGraphics, dxLayoutLookAndFeels, cxLookupEdit, cxDBLookupEdit,
|
|||
|
|
cxDBLookupComboBox, uFormasPagoController, uDAInterfaces, uBizFormasPago,
|
|||
|
|
uViewTienda, uFacturasClienteController, uViewClienteFactura, Menus, StdActns,
|
|||
|
|
ActnList, uViewObservaciones, cxCheckBox;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewFacturaCliente = interface(IViewBase)
|
|||
|
|
['{3A95930C-20B3-41E9-93CB-21138ADB5B70}']
|
|||
|
|
function GetController : IFacturasClienteController;
|
|||
|
|
procedure SetController (const Value : IFacturasClienteController);
|
|||
|
|
property Controller : IFacturasClienteController read GetController write SetController;
|
|||
|
|
|
|||
|
|
function GetFactura: IBizFacturaCliente;
|
|||
|
|
procedure SetFactura(const Value: IBizFacturaCliente);
|
|||
|
|
property Factura: IBizFacturaCliente read GetFactura write SetFactura;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewFacturaCliente = class(TfrViewBase, IViewFacturaCliente)
|
|||
|
|
DADataSource: TDADataSource;
|
|||
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|||
|
|
eReferencia: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|||
|
|
edtFecha: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group5: TdxLayoutGroup;
|
|||
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|||
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|||
|
|
dsFormaPago: TDADataSource;
|
|||
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|||
|
|
cbFormaPago: TcxDBLookupComboBox;
|
|||
|
|
dxLayoutControl1Item10: TdxLayoutItem;
|
|||
|
|
bFormasPago: TButton;
|
|||
|
|
dxLayoutControl1Group6: TdxLayoutGroup;
|
|||
|
|
frViewTienda1: TfrViewTienda;
|
|||
|
|
dxLayoutControl1Group4: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|||
|
|
frViewClienteFactura1: TfrViewClienteFactura;
|
|||
|
|
dxLayoutControl1Group8: TdxLayoutGroup;
|
|||
|
|
ledtFechaVencimiento: TdxLayoutItem;
|
|||
|
|
edtFechaVencimiento: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|||
|
|
frViewObservaciones1: TfrViewObservaciones;
|
|||
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|||
|
|
cbRecargoEquivalencia: TcxDBCheckBox;
|
|||
|
|
dxLayoutControl1Group9: TdxLayoutGroup;
|
|||
|
|
procedure bFormasPagoClick(Sender: TObject);
|
|||
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|||
|
|
procedure CustomViewCreate(Sender: TObject);
|
|||
|
|
procedure edtFechaVencimientoPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
FFactura : IBizFacturaCliente;
|
|||
|
|
FController : IFacturasClienteController;
|
|||
|
|
FFormasPago : IBizFormaPago;
|
|||
|
|
FFormasPagoController : IFormasPagoController;
|
|||
|
|
function GetFactura: IBizFacturaCliente;
|
|||
|
|
procedure SetFactura(const Value: IBizFacturaCliente);
|
|||
|
|
function GetController : IFacturasClienteController;
|
|||
|
|
procedure SetController (const Value : IFacturasClienteController);
|
|||
|
|
public
|
|||
|
|
property Factura: IBizFacturaCliente read GetFactura write SetFactura;
|
|||
|
|
property Controller : IFacturasClienteController read GetController write SetController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleContactos, schFacturasClienteClient_Intf;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{ TfrViewFacturaCliente }
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.bFormasPagoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FFormasPago) then
|
|||
|
|
FFormasPagoController.VerTodos(FFormasPago);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.CustomViewCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := TFormasPagoController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.CustomViewDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.edtFechaVencimientoPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FFormasPago) then
|
|||
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|||
|
|
ledtFechaVencimiento.Enabled := True
|
|||
|
|
else
|
|||
|
|
ledtFechaVencimiento.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewFacturaCliente.GetController: IFacturasClienteController;
|
|||
|
|
begin
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewFacturaCliente.GetFactura: IBizFacturaCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FFactura;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.SetController(const Value: IFacturasClienteController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FController) then
|
|||
|
|
frViewClienteFactura1.Controller := FController.ClienteController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaCliente.SetFactura(const Value: IBizFacturaCliente);
|
|||
|
|
var
|
|||
|
|
ACadena : String;
|
|||
|
|
begin
|
|||
|
|
FFactura := Value;
|
|||
|
|
if Assigned(FFactura) then
|
|||
|
|
begin
|
|||
|
|
DADataSource.DataTable := FFactura.DataTable;
|
|||
|
|
frViewTienda1.DataItem := FFactura.DataTable;
|
|||
|
|
|
|||
|
|
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_FacturasClienteID, FFactura.ID_FORMA_PAGO, []);
|
|||
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|||
|
|
ledtFechaVencimiento.Enabled := True
|
|||
|
|
else
|
|||
|
|
ledtFechaVencimiento.Enabled := False;
|
|||
|
|
|
|||
|
|
//Solo se deshabilita al insertar, luego la referencia ser<65> modificable
|
|||
|
|
//eReferencia.Enabled := (FFactura.DataTable.State = dsInsert);
|
|||
|
|
|
|||
|
|
if FFactura.TIPO = CTE_TIPO_ABONO then
|
|||
|
|
begin
|
|||
|
|
dxLayoutControl1Group1.Caption := 'Datos del abono:';
|
|||
|
|
dxLayoutControl1Item2.Caption := 'Fecha del abono:';
|
|||
|
|
ACadena := 'Elija el cliente al que se le realizar<61> el abono.';
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
ACadena := 'Elija el cliente al que se le realizar<61> la factura.';
|
|||
|
|
frViewClienteFactura1.MsgElegirCliente := ACadena;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
DADataSource.DataTable := NIL;
|
|||
|
|
dsFormaPago.DataTable := NIL;
|
|||
|
|
frViewClienteFactura1.Cliente := NIL
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|