unit uEditorFechaPagoProveedor; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, ExtCtrls, uEditorBasico, uIEditorFechaPagoProveedor, uSubCuentasController, Buttons, cxCheckBox, uCustomView, uViewBase, uViewListaSubCuentas; type TfEditorFechaPagoProveedor = class(TfEditorBasico, IEditorFechaPagoProveedor) Label1: TLabel; eFechaPago: TcxDateEdit; bAceptar: TButton; bCancelar: TButton; Label2: TLabel; Panel1: TPanel; frViewListaSubcuentas1: TfrViewListaSubcuentas; PnlComentario: TPanel; lbComentario: TLabel; Label3: TLabel; procedure FormShow(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCreate(Sender: TObject); procedure eFechaPagoPropertiesEditValueChanged(Sender: TObject); private FFechaPago : TDateTime; FComentario: Variant; FSoloLectura: Boolean; function GetFechaPago: TDateTime; procedure SetFechaPago(const Value: TDateTime); function GetIgnorarContabilidad: Integer; procedure SetIgnorarContabilidad(const Value: Integer); function GetIdSubCuenta: Integer; procedure SetIdSubCuenta(const Value: Integer); function GetComentario: Variant; procedure SetComentario(const Value: Variant); function GetSoloLectura: Boolean; procedure SetSoloLectura(const Value: Boolean); public property FechaPago: TDateTime Read GetFechaPago write SetFechaPago; property IgnorarContabilidad: Integer Read GetIgnorarContabilidad write SetIgnorarContabilidad; property IdSubCuenta: Integer Read GetIdSubCuenta write SetIdSubCuenta; property Comentario: Variant read GetComentario write SetComentario; property SoloLectura: Boolean read GetSoloLectura write SetSoloLectura; procedure DeshabilitarContabilidad; end; implementation {$R *.dfm} {$INCLUDE ..\..\..\FactuGES.inc} uses uDialogUtils, uFactuGES_App, uBizEjercicios; procedure TfEditorFechaPagoProveedor.DeshabilitarContabilidad; begin frViewListaSubCuentas1.eContabilizar.Enabled := False; end; procedure TfEditorFechaPagoProveedor.eFechaPagoPropertiesEditValueChanged(Sender: TObject); begin FechaPago := eFechaPago.Date; end; procedure TfEditorFechaPagoProveedor.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose := True; if Self.ModalResult = mrOk then begin if (length(eFechaPago.EditValue) = 0) then begin CanClose := False; ShowWarningMessage('Debe establecer la fecha del pago'); end; if (IgnorarContabilidad = 0) then begin if (AppFactuGES.EjercicioActivo.ESTADO = CTE_CERRADO) then begin CanClose := False; ShowWarningMessage('El pago no puede pasar a la parte contable de la aplicación porque el ejercicio activo está CERRADO'); end else if (IdSubCuenta < 1) then begin CanClose := False; ShowWarningMessage('Debe establecer la caja o banco donde se realiza el pago'); end end; end; end; procedure TfEditorFechaPagoProveedor.FormCreate(Sender: TObject); begin {$IFDEF CONTABILIDAD} frViewListaSubCuentas1.TipoSubCuenta := tCajas; {$ENDIF} Comentario := Null; FSoloLectura := False; end; procedure TfEditorFechaPagoProveedor.FormShow(Sender: TObject); begin if (length(eFechaPago.Text) = 0) then eFechaPago.Date := Date; {$IFDEF CONTABILIDAD} frViewListaSubCuentas1.Visible := true; if Assigned(AppFactuGES.EjercicioActivo) then begin frViewListaSubcuentas1.eContabilizar.Checked := False; end else begin frViewListaSubcuentas1.eContabilizar.Checked := True; end; {$ELSE} frViewListaSubCuentas1.Visible := false; {$ENDIF} end; function TfEditorFechaPagoProveedor.GetComentario: Variant; begin Result := FComentario; end; function TfEditorFechaPagoProveedor.GetFechaPago: TDateTime; begin Result := FFechaPago; end; function TfEditorFechaPagoProveedor.GetIdSubCuenta: Integer; begin Result := frViewListaSubCuentas1.IdSubCuenta; end; function TfEditorFechaPagoProveedor.GetIgnorarContabilidad: Integer; begin Result := frViewListaSubCuentas1.eContabilizar.EditValue; end; function TfEditorFechaPagoProveedor.GetSoloLectura: Boolean; begin Result := FSoloLectura; end; procedure TfEditorFechaPagoProveedor.SetComentario(const Value: Variant); begin FComentario := Value; lbComentario.Caption := ''; lbComentario.Caption := VarToStr(FComentario); if VarIsNull(FComentario) then PnlComentario.Visible := False else PnlComentario.Visible := True; end; procedure TfEditorFechaPagoProveedor.SetFechaPago(const Value: TDateTime); begin FFechaPago := Value; eFechaPago.EditValue := FFechaPago; end; procedure TfEditorFechaPagoProveedor.SetIdSubCuenta(const Value: Integer); begin frViewListaSubCuentas1.ElegirSubCuenta(Value); end; procedure TfEditorFechaPagoProveedor.SetIgnorarContabilidad(const Value: Integer); begin frViewListaSubCuentas1.eContabilizar.EditValue := Value; frViewListaSubCuentas1.Refrescar; end; procedure TfEditorFechaPagoProveedor.SetSoloLectura(const Value: Boolean); begin FSoloLectura := Value; if FSoloLectura then begin eFechaPago.Enabled := False; frViewListaSubcuentas1.ReadOnly := True; end else begin eFechaPago.Enabled := True; frViewListaSubcuentas1.ReadOnly := False; end; end; end.