git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_FactuGES/trunk@4 6cb6b671-b4a0-dd4c-8bdc-3006503d97e9
136 lines
4.4 KiB
ObjectPascal
136 lines
4.4 KiB
ObjectPascal
unit uViewSituacionMontaje;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, dxLayoutControl, cxControls, StdCtrls, DB, uDADataTable,
|
|
cxContainer, cxEdit, cxLabel, cxDBLabel, cxTextEdit, cxCurrencyEdit, cxDBEdit,
|
|
ExtCtrls, cxMaskEdit;
|
|
|
|
type
|
|
TfrViewSituacionMontaje = class(TfrViewBase)
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|
dsDataTable: TDADataSource;
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
ImporteContrato2: TcxDBLabel;
|
|
ImporteContrato1: TcxDBCurrencyEdit;
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|
Bevel1: TBevel;
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|
Bevel2: TBevel;
|
|
dxLayoutControl1Item9: TdxLayoutItem;
|
|
ImportePedidos: TcxCurrencyEdit;
|
|
dxLayoutControl1Item11: TdxLayoutItem;
|
|
ImporteGastos: TcxCurrencyEdit;
|
|
dxLayoutControl1Item12: TdxLayoutItem;
|
|
ImporteBeneficio: TcxCurrencyEdit;
|
|
dxLayoutControl1Item13: TdxLayoutItem;
|
|
ImporteCobrado: TcxCurrencyEdit;
|
|
dxLayoutControl1Item14: TdxLayoutItem;
|
|
ImportePendiente: TcxCurrencyEdit;
|
|
dxLayoutControl1Item15: TdxLayoutItem;
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
PorcentajeBeneficio: TcxLabel;
|
|
procedure CustomViewCreate(Sender: TObject);
|
|
procedure ImporteContrato1PropertiesEditValueChanged(Sender: TObject);
|
|
procedure ImporteBeneficioPropertiesEditValueChanged(Sender: TObject);
|
|
procedure ImportePendientePropertiesEditValueChanged(Sender: TObject);
|
|
private
|
|
FImportePedidos: Double;
|
|
FImporteOtrosGastos: Double;
|
|
FImporteCobrado: Double;
|
|
procedure setImporteCobrado(const Value: Double);
|
|
procedure setImporteOtrosGastos(const Value: Double);
|
|
procedure setImportePedidos(const Value: Double);
|
|
procedure CalcularSituacion;
|
|
public
|
|
property pImportePedidos: Double read FImportePedidos write setImportePedidos;
|
|
property pImporteOtrosGastos: Double read FImporteOtrosGastos write setImporteOtrosGastos;
|
|
property pImporteCobrado: Double read FImporteCobrado write setImporteCobrado;
|
|
end;
|
|
|
|
implementation
|
|
{$R *.dfm}
|
|
|
|
{ TfrViewSituacionMontaje }
|
|
|
|
procedure TfrViewSituacionMontaje.CalcularSituacion;
|
|
var
|
|
lImporteBeneficio: Double;
|
|
lPorcentajeBeneficio: Double;
|
|
lImportePendiente: Double;
|
|
begin
|
|
if VarIsNull(ImporteContrato1.Value) then
|
|
exit;
|
|
|
|
lImporteBeneficio := (ImporteContrato1.Value + (FImportePedidos + FImporteOtrosGastos));
|
|
if (ImporteContrato1.Value <> 0) then
|
|
lPorcentajeBeneficio := (lImporteBeneficio * 100) / ImporteContrato1.Value;
|
|
lImportePendiente := ImporteContrato1.Value - FImporteCobrado;
|
|
|
|
ImporteBeneficio.Value := lImporteBeneficio;
|
|
PorcentajeBeneficio.Caption := FormatFloat('0.00%', lPorcentajeBeneficio);
|
|
ImportePendiente.Value := lImportePendiente;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.CustomViewCreate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FImportePedidos := 0;
|
|
FImporteOtrosGastos := 0;
|
|
FImporteCobrado := 0;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.ImporteBeneficioPropertiesEditValueChanged(Sender: TObject);
|
|
begin
|
|
if ImporteBeneficio.Value < 0 then
|
|
begin
|
|
ImporteBeneficio.Style.Font.Color := clRed;
|
|
PorcentajeBeneficio.Style.Font.Color := clRed
|
|
end
|
|
else
|
|
begin
|
|
ImporteBeneficio.Style.Font.Color := clWindowText;
|
|
PorcentajeBeneficio.Style.Font.Color := clWindowText
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.ImporteContrato1PropertiesEditValueChanged(Sender: TObject);
|
|
begin
|
|
CalcularSituacion;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.ImportePendientePropertiesEditValueChanged(Sender: TObject);
|
|
begin
|
|
if ImportePendiente.Value < 0
|
|
then ImportePendiente.Style.Font.Color := clWindowText
|
|
else ImportePendiente.Style.Font.Color := clRed;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.setImporteCobrado(const Value: Double);
|
|
begin
|
|
FImporteCobrado := Value;
|
|
ImporteCobrado.Value := FImporteCobrado;
|
|
CalcularSituacion;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.setImporteOtrosGastos(const Value: Double);
|
|
begin
|
|
FImporteOtrosGastos := Value;
|
|
ImporteGastos.Value := (-1)* FImporteOtrosGastos;
|
|
CalcularSituacion;
|
|
end;
|
|
|
|
procedure TfrViewSituacionMontaje.setImportePedidos(const Value: Double);
|
|
begin
|
|
FImportePedidos := Value;
|
|
ImportePedidos.Value := (-1)* FImportePedidos;
|
|
CalcularSituacion;
|
|
end;
|
|
|
|
end.
|