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/Clientes/FacturasProforma.pas
2007-06-26 08:08:27 +00:00

296 lines
8.9 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: 25-12-2002
Versión actual: 1.0.0
Fecha versión actual: 25-12-2002
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
===============================================================================
}
unit FacturasProforma;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, ComCtrls, RdxBotones, ToolWin, ExtCtrls,
Menus, RXDBCtrl, Configuracion, RdxFrame,
Db, RdxPaneles, RdxBarras,
cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxEdit, cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
am2000menuitem, am2000popupmenu, am2000, cxContainer, cxTextEdit,
cxMaskEdit, cxDropDownEdit, StdCtrls, ActnList, RdxFrameFacturasProforma,
RdxEmpresaActiva, am2000utils, cxDataStorage;
type
TfrFacturasProforma = class(TRdxFrameFacturasProforma)
dsFacturas: TDataSource;
BarraFacturas: TRdxBarraSuperior;
pnlCuerpo: TRdxPanel;
pnlGrid: TRdxPanel;
brSeleccion: TRdxBarraInferior;
bSeleccionar: TRdxBoton;
bCancelar: TRdxBoton;
brSimple: TRdxBarraInferior;
bSalir: TRdxBoton;
gridFacturas: TcxGrid;
gridFacturasDBTableView1: TcxGridDBTableView;
gridFacturasLevel1: TcxGridLevel;
MenuOpciones: TPopupMenu2000;
miAnadir: TMenuItem2000;
miModificar: TMenuItem2000;
miEliminar: TMenuItem2000;
miConsultar: TMenuItem2000;
miSeparador: TMenuItem2000;
miImprimir: TMenuItem2000;
Acciones: TActionList;
actAnadir: TAction;
actModificar: TAction;
actEliminar: TAction;
actConsultar: TAction;
actImprimir: TAction;
actSeleccionar: TAction;
actCancelar: TAction;
actAceptar: TAction;
bAnadir: TRdxBotonSuperior;
bModificar: TRdxBotonSuperior;
bEliminar: TRdxBotonSuperior;
bConsultar: TRdxBotonSuperior;
bSeparador1: TShape;
bImprimir: TRdxBotonSuperior;
imgSombra: TImage;
pnlCuerpo2: TRdxPanel;
pnlExtra: TRdxBarraSuperior;
bRefrescar: TRdxBoton;
Panel2: TPanel;
eNombre: TLabel;
Buscar: TcxTextEdit;
bLimpiar: TRdxBoton;
procedure RdxFrameFacturasProformaShow(Sender: TObject);
procedure actImprimirExecute(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 actRefrescarDatosExecute(Sender: TObject);
procedure BuscarPropertiesChange(Sender: TObject);
procedure bLimpiarClick(Sender: TObject);
private
FCodigoCliente : String;
procedure ActualizarBotones;
protected
procedure FreeContenido; override;
procedure SetContenido (NuevoFrame : TRdxFrame); override;
procedure BuscarFactura; override;
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
end;
var
frFacturasProforma: TfrFacturasProforma;
implementation
{$R *.DFM}
uses
BaseDatos, TablaFacturasProforma, IBDatabase, Literales,
IBCustomDataSet, Mensajes, Entidades, Variants, ImprimirFacturasProforma,
Constantes, FacturaProforma, TablaEmpresas;
procedure TfrFacturasProforma.BuscarFactura;
begin
with TablaFacturas do
begin
DisableControls;
Close;
Open;
dmTablaFacturasProforma.InicializarTablaFacturas(@TablaFacturas);
ActualizarBotones;
EnableControls;
if not Locate('CODIGO', CodigoFactura, []) then
gridFacturasDBTableView1.Controller.GoToFirst
else
gridFacturasDBTableView1.Controller.TopRowIndex := gridFacturasDBTableView1.Controller.FocusedRowIndex;
end;
end;
constructor TfrFacturasProforma.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Entidad := entFacturaProforma;
BaseDatos := dmBaseDatos.BD;
Transaccion := dmBaseDatos.Transaccion;
TablaFacturas := TIBDataSet.Create(Self);
dsFacturas.DataSet := TablaFacturas;
with TablaFacturas do
begin
Database := BaseDatos;
Transaction := Transaccion;
SelectSQL.Assign(dmTablaFacturasProforma.sqlConsultarGridFacturas);
ParamByName('CODIGOEMPRESA').AsInteger := EmpresaActiva.Codigo;
Prepare;
Open;
ActualizarBotones;
end;
dmTablaFacturasProforma.InicializarTablaFacturas(@TablaFacturas);
dmTablaFacturasProforma.InicializarGridFacturas(gridFacturas);
gridFacturasDBTableView1.OnDblClick := gridFacturasDBTableView1DblClick;
gridFacturasDBTableView1.Controller.GoToFirst;
end;
destructor TfrFacturasProforma.Destroy;
begin
TablaFacturas.Close;
TablaFacturas.UnPrepare;
TablaFacturas.Free;
inherited;
end;
procedure TfrFacturasProforma.FreeContenido;
begin
if (Contenido is TRdxFrameFacturasProforma) then
CodigoFactura := (Contenido as TRdxFrameFacturasProforma).CodigoFactura;
inherited FreeContenido;
//gridFacturas.SetFocus;
end;
procedure TfrFacturasProforma.ActualizarBotones;
begin
if BaseDatos.IsReadOnly then
begin
actAnadir.Enabled := False;
actModificar.Enabled := False;
actEliminar.Enabled := False;
actConsultar.Enabled := True;
actImprimir.Enabled := True;
Exit;
end;
if TablaFacturas.RecordCount = 0 then
begin
actAnadir.Enabled := True;
actModificar.Enabled := False;
actEliminar.Enabled := False;
actConsultar.Enabled := False;
actImprimir.Enabled := False;
end
else begin
actAnadir.Enabled := True;
actModificar.Enabled := True;
actEliminar.Enabled := True;
actConsultar.Enabled := True;
actImprimir.Enabled := True;
end;
end;
procedure TfrFacturasProforma.RdxFrameFacturasProformaShow(Sender: TObject);
begin
Buscar.SetFocus
end;
procedure TfrFacturasProforma.SetContenido(NuevoFrame: TRdxFrame);
begin
inherited;
if (Contenido is TfrImprimirFacturasProforma) then
(Contenido as TfrImprimirFacturasProforma).CodigoFactura := FCodigoFactura;
end;
procedure TfrFacturasProforma.actImprimirExecute(Sender: TObject);
begin
Contenido := TfrImprimirFacturasProforma.Create(Self);
Contenido.Modo := Imprimir;
end;
procedure TfrFacturasProforma.actAnadirExecute(Sender: TObject);
begin
Contenido := TfrFacturaProforma.Create(Self);
Contenido.Modo := Anadir;
end;
procedure TfrFacturasProforma.actModificarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProforma.Create(Self);
Contenido.Modo := Modificar;
end;
procedure TfrFacturasProforma.actEliminarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProforma.Create(Self);
Contenido.Modo := Eliminar;
end;
procedure TfrFacturasProforma.actConsultarExecute(Sender: TObject);
begin
Contenido := TfrFacturaProforma.Create(Self);
Contenido.Modo := Consultar;
end;
procedure TfrFacturasProforma.actSeleccionarExecute(Sender: TObject);
begin
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
CloseFrame;
end;
procedure TfrFacturasProforma.actCancelarExecute(Sender: TObject);
begin
FCodigoFactura := NULL;
CloseFrame;
end;
procedure TfrFacturasProforma.actAceptarExecute(Sender: TObject);
begin
CloseFrame;
end;
procedure TfrFacturasProforma.gridFacturasDBTableView1DblClick(
Sender: TObject);
begin
if Modo = Seleccionar then
actSeleccionar.Execute
else
actModificar.Execute;
end;
procedure TfrFacturasProforma.actRefrescarDatosExecute(Sender: TObject);
begin
FCodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
BuscarFactura;
end;
procedure TfrFacturasProforma.BuscarPropertiesChange(Sender: TObject);
begin
FiltrarGrid(gridFacturas, Buscar.Text);
end;
procedure TfrFacturasProforma.bLimpiarClick(Sender: TObject);
begin
Buscar.Text := '';
end;
end.