This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
FactuGES/Proveedores/FacturasProveedores.pas
2007-06-26 08:08:27 +00:00

336 lines
11 KiB
ObjectPascal

{
===============================================================================
Copyright (©) 2002. Rodax Software.
===============================================================================
Los contenidos de este fichero son propiedad de Rodax Software titular del
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
bajo el que se suministra.
-----------------------------------------------------------------------------
Web: www.rodax-software.com
===============================================================================
Fecha primera versión: 05-12-2002
Versión actual: 1.0.1
Fecha versión actual: 02-02-2004
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
02-02-2004 Se ha eliminado el atributo SERIE (P8 MULTIEMPRESA)
Se ha adaptado a los nuevos contadores
===============================================================================
}
unit FacturasProveedores;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
RdxFrameFacturasProveedor, RdxBotones, ExtCtrls, RdxPaneles, RdxBarras,
Grids, DBGrids, RXDBCtrl, Menus, am2000menuitem, RdxFrame,
am2000popupmenu, am2000, Db, DBTables, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxEdit,
cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
cxContainer, cxTextEdit, cxMaskEdit, cxDropDownEdit, StdCtrls, ActnList,
RdxEmpresaActiva, am2000utils, cxDataStorage;
type
TfrFacturasProveedores = class(TRdxFrameFacturasProveedor)
BarraFacturas: TRdxBarraSuperior;
bAnadir: TRdxBotonMenu;
bModificar: TRdxBotonSuperior;
bEliminar: TRdxBotonSuperior;
bConsultar: TRdxBotonSuperior;
pnlCuerpo: TRdxPanel;
pnlGridFacturas: TPanel;
dsFacturas: TDataSource;
brSeleccion: TRdxBarraInferior;
bSeleccionar: TRdxBoton;
bCancelar: TRdxBoton;
brSimple: TRdxBarraInferior;
bSalir: TRdxBoton;
bSeparador2: TShape;
gridFacturas: TcxGrid;
gridFacturasDBTableView1: TcxGridDBTableView;
gridFacturasLevel1: TcxGridLevel;
MenuOpciones: TPopupMenu2000;
mnuAnadir: TMenuItem2000;
mnuModificar: TMenuItem2000;
mnuEliminar: TMenuItem2000;
mnuConsultar: TMenuItem2000;
pnlExtra: TRdxBarraSuperior;
menuAnadir: TPopupMenu2000;
Aadirfactura1: TMenuItem2000;
Acciones: TActionList;
actAnadir: TAction;
actModificar: TAction;
actEliminar: TAction;
actConsultar: TAction;
actSeleccionar: TAction;
actCancelar: TAction;
actAceptar: TAction;
MenuItem1: TMenuItem2000;
actAnadirAbono: TAction;
bPagosPendientes: TRdxBotonSuperior;
actFacturasPendientes: TAction;
imgSombra: TImage;
bRefrescar: TRdxBoton;
Panel1: TPanel;
eNombre: TLabel;
Buscar: TcxTextEdit;
bLimpiar: TRdxBoton;
procedure RdxFrameFacturasProveedorShow(Sender: TObject);
procedure actAnadirExecute(Sender: TObject);
procedure actModificarExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure actConsultarExecute(Sender: TObject);
procedure actSeleccionarExecute(Sender: TObject);
procedure actCancelarExecute(Sender: TObject);
procedure actAceptarExecute(Sender: TObject);
procedure gridFacturasDBTableView1DblClick(Sender: TObject);
procedure gridFacturasDBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure actAnadirAbonoBExecute(Sender: TObject);
procedure actAnadirAbonoExecute(Sender: TObject);
procedure actFacturasPendientesExecute(Sender: TObject);
procedure actRefrescarDatosExecute(Sender: TObject);
procedure BuscarPropertiesChange(Sender: TObject);
procedure bLimpiarClick(Sender: TObject);
private
procedure ActualizarBotones;
protected
procedure BuscarFactura; override;
procedure FreeContenido; override;
procedure CambiarModo(ModoAnterior, Modo : TRdxModo); override;
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
published
property TablaFacturasProveedor;
property Entidad;
end;
var
frFacturasProveedores: TfrFacturasProveedores;
implementation
{$R *.DFM}
{ TfrFacturasProveedores }
uses
BaseDatos, TablaFacturasProveedor, IBDatabase,
IBCustomDataSet, Mensajes, Entidades, Variants,
FacturaProveedor, Constantes, FacturasProveedorPendientes, TablaEmpresas,
Configuracion;
procedure TfrFacturasProveedores.BuscarFactura;
begin
with TablaFacturasProveedor do
begin
DisableControls;
Close;
Open;
dmTablaFacturasProveedor.InicializarTablaFacturas(@TablaFacturasProveedor);
ActualizarBotones;
EnableControls;
if not Locate('CODIGO', CodigoFactura, []) then
gridFacturasDBTableView1.Controller.GoToFirst
else
gridFacturasDBTableView1.Controller.TopRowIndex := gridFacturasDBTableView1.Controller.FocusedRowIndex;
end;
end;
constructor TfrFacturasProveedores.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Entidad := entFacturaProveedor;
ConfigurarFrame(Self, Entidad);
BaseDatos := dmBaseDatos.BD;
Transaccion := dmBaseDatos.Transaccion;
TablaFacturasProveedor := TIBDataSet.Create(Self);
dsFacturas.DataSet := TablaFacturasProveedor;
with TablaFacturasProveedor do
begin
Database := BaseDatos;
Transaction := Transaccion;
SelectSQL.Assign(dmTablaFacturasProveedor.sqlConsultarGridFacturas);
ParamByName('CODIGOEMPRESA').AsInteger := EmpresaActiva.Codigo;
Prepare;
Open;
ActualizarBotones;
end;
dmTablaFacturasProveedor.InicializarTablaFacturas(@TablaFacturasProveedor);
dmTablaFacturasProveedor.InicializarGridFacturas(gridFacturas);
gridFacturasDBTableView1.OnDblClick := gridFacturasDBTableView1DblClick;
gridFacturasDBTableView1.Controller.GoToFirst;
end;
destructor TfrFacturasProveedores.Destroy;
begin
TablaFacturasProveedor.Close;
TablaFacturasProveedor.UnPrepare;
TablaFacturasProveedor.Free;
inherited;
end;
procedure TfrFacturasProveedores.FreeContenido;
begin
if (Contenido is TRdxFrameFacturasProveedor) then
CodigoFactura := (Contenido as TRdxFrameFacturasProveedor).CodigoFactura;
inherited FreeContenido;
// gridFacturas.SetFocus;
end;
procedure TfrFacturasProveedores.ActualizarBotones;
begin
if BaseDatos.IsReadOnly then
begin
actAnadir.Enabled := False;
actModificar.Enabled := False;
actEliminar.Enabled := False;
actConsultar.Enabled := True;
actFacturasPendientes.Enabled := True;
Exit;
end;
if TablaFacturasProveedor.RecordCount = 0 then
begin
actAnadir.Enabled := True;
actModificar.Enabled := False;
actEliminar.Enabled := False;
actConsultar.Enabled := False;
actFacturasPendientes.Enabled := False;
end
else begin
actAnadir.Enabled := True;
actModificar.Enabled := True;
actEliminar.Enabled := True;
actConsultar.Enabled := True;
actFacturasPendientes.Enabled := True;
end;
end;
procedure TfrFacturasProveedores.RdxFrameFacturasProveedorShow(
Sender: TObject);
begin
Buscar.SetFocus
end;
procedure TfrFacturasProveedores.actAnadirExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Entidad := entFacturaProveedor;
Contenido.Modo := Anadir;
end;
procedure TfrFacturasProveedores.actModificarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Modo := Modificar;
end;
procedure TfrFacturasProveedores.actEliminarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Modo := Eliminar;
end;
procedure TfrFacturasProveedores.actConsultarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Modo := Consultar;
end;
procedure TfrFacturasProveedores.actSeleccionarExecute(Sender: TObject);
begin
CodigoFactura := TablaFacturasProveedor.FieldByName('CODIGO').AsString;
CloseFrame;
end;
procedure TfrFacturasProveedores.actCancelarExecute(Sender: TObject);
begin
FCodigoFactura := NULL;
CloseFrame;
end;
procedure TfrFacturasProveedores.actAceptarExecute(Sender: TObject);
begin
CloseFrame;
end;
procedure TfrFacturasProveedores.gridFacturasDBTableView1DblClick(
Sender: TObject);
begin
if Modo = Seleccionar then
actSeleccionar.Execute
else
actModificar.Execute;
end;
procedure TfrFacturasProveedores.gridFacturasDBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
IndiceCol : Integer;
begin
if not AViewInfo.Selected then
begin
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName('CLASEFACTURA').Index;
if UpperCase(AViewInfo.GridRecord.DisplayTexts[IndiceCol]) = CTE_CF_ABONO then
ACanvas.Canvas.Font.Color := $000000CC;
end;
end;
procedure TfrFacturasProveedores.actAnadirAbonoBExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Entidad := entAbonoProveedor;
Contenido.Modo := Anadir;
end;
procedure TfrFacturasProveedores.actAnadirAbonoExecute(Sender: TObject);
begin
Contenido := TfrFacturaProveedor.Create(Self);
Contenido.Entidad := entAbonoProveedor;
Contenido.Modo := Anadir;
end;
procedure TfrFacturasProveedores.actFacturasPendientesExecute(
Sender: TObject);
begin
Contenido := TfrFacturasProveedorPendientes.Create(Self);
end;
procedure TfrFacturasProveedores.CambiarModo(ModoAnterior, Modo: TRdxModo);
begin
inherited;
dmTablaFacturasProveedor.InicializarTablaFacturas(@TablaFacturasProveedor);
end;
procedure TfrFacturasProveedores.actRefrescarDatosExecute(Sender: TObject);
begin
FCodigoFactura := TablaFacturasProveedor.FieldByName('CODIGO').AsString;
BuscarFactura;
end;
procedure TfrFacturasProveedores.BuscarPropertiesChange(Sender: TObject);
begin
FiltrarGrid(gridFacturas, Buscar.Text);
end;
procedure TfrFacturasProveedores.bLimpiarClick(Sender: TObject);
begin
Buscar.Text := '';
end;
end.