git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES/trunk@4 b68bf8ae-e977-074f-a058-3cfd71dd8f45
167 lines
4.3 KiB
ObjectPascal
167 lines
4.3 KiB
ObjectPascal
unit ElegirEmpresa;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
ComCtrls, ExtCtrls, DBCGrids, StdCtrls, DBCtrls, IBDatabase, Db, IBSQL,
|
|
IBCustomDataSet, IBTable, cxControls, cxContainer, cxEdit, cxImage,
|
|
cxDBEdit, Grids, DBGrids, pngimage, RdxBotones, RdxPaneles,
|
|
RdxBarras, RXCtrls, FthBtns, ActnList, RdxFrameEmpresas;
|
|
|
|
type
|
|
TfrElegirEmpresa = class(TRdxFrameEmpresas)
|
|
DBCtrlGrid1: TDBCtrlGrid;
|
|
DBText1: TDBText;
|
|
DBText2: TDBText;
|
|
dsEmpresas: TDataSource;
|
|
pnlBarraSuperior: TRdxGradientePanel;
|
|
imgFondo: TImage;
|
|
brDoble: TRdxBarraInferior;
|
|
bSeleccionar: TRdxBoton;
|
|
bCancelar: TRdxBoton;
|
|
Shape1: TShape;
|
|
Image6: TImage;
|
|
Image1: TImage;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
bGestionar: TRdxBoton;
|
|
FourthStandardButton1: TFourthStandardButton;
|
|
FourthStandardButton2: TFourthStandardButton;
|
|
Acciones: TActionList;
|
|
actAnadir: TAction;
|
|
actModificar: TAction;
|
|
actEliminar: TAction;
|
|
actConsultar: TAction;
|
|
actCancelar: TAction;
|
|
actAbrir: TAction;
|
|
actCerrar: TAction;
|
|
DBImage1: TDBImage;
|
|
procedure actAbrirExecute(Sender: TObject);
|
|
procedure actModificarExecute(Sender: TObject);
|
|
procedure actEliminarExecute(Sender: TObject);
|
|
procedure actAnadirExecute(Sender: TObject);
|
|
procedure RdxFrameEmpresasShow(Sender: TObject);
|
|
private
|
|
procedure BuscarEmpresa; override;
|
|
procedure FreeContenido; override;
|
|
public
|
|
constructor Create (AOwner : TComponent); override;
|
|
destructor Destroy; override;
|
|
published
|
|
property TablaEmpresas;
|
|
property Entidad;
|
|
end;
|
|
|
|
var
|
|
frElegirEmpresa: TfrElegirEmpresa;
|
|
|
|
implementation
|
|
|
|
{$R *.DFM}
|
|
|
|
uses
|
|
RdxEmpresaActiva, RdxGestorContadores, Configuracion, BaseDatos, Tipos,
|
|
TablaEmpresas, Empresa;
|
|
|
|
{ TfElegirEmpresa }
|
|
|
|
procedure TfrElegirEmpresa.BuscarEmpresa;
|
|
begin
|
|
with TablaEmpresas do
|
|
begin
|
|
DisableControls;
|
|
Close;
|
|
Open;
|
|
EnableControls;
|
|
if EmpresaActiva.Codigo <> NULL then
|
|
Locate('CODIGO', EmpresaActiva.Codigo, []);
|
|
end;
|
|
end;
|
|
|
|
constructor TfrElegirEmpresa.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
Entidad := entEmpresa;
|
|
ConfigurarVentanaPrincipal(Self);
|
|
|
|
BaseDatos := dmBaseDatos.BD;
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|
TablaEmpresas := TIBDataSet.Create(Self);
|
|
dsEmpresas.DataSet := TablaEmpresas;
|
|
|
|
with TablaEmpresas do
|
|
begin
|
|
DisableControls;
|
|
Database := BaseDatos;
|
|
Transaction := Transaccion;
|
|
SelectSQL.Assign(dmTablaEmpresas.sqlGrid);
|
|
Prepare;
|
|
EnableControls;
|
|
end;
|
|
end;
|
|
|
|
destructor TfrElegirEmpresa.Destroy;
|
|
begin
|
|
TablaEmpresas.Close;
|
|
TablaEmpresas.Unprepare;
|
|
TablaEmpresas.Free;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.FreeContenido;
|
|
begin
|
|
if (ContenidoModal is TRdxFrameEmpresas) then
|
|
CodigoEmpresa := (ContenidoModal as TRdxFrameEmpresas).CodigoEmpresa;
|
|
inherited FreeContenido;
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.actAbrirExecute(Sender: TObject);
|
|
begin
|
|
EmpresaActiva.Codigo := TablaEmpresas.FieldByName('CODIGO').AsInteger;
|
|
GestorContadores.CodigoEmpresa := TablaEmpresas.FieldByName('CODIGO').AsInteger;
|
|
CloseFrame;
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.actModificarExecute(Sender: TObject);
|
|
var
|
|
ContenidoAux : TRdxFrameEmpresas;
|
|
begin
|
|
ModoModal := Modificar;
|
|
WidthModal := 550;
|
|
HeightModal := 590;
|
|
ContenidoAux := TfrEmpresa.Create(Self);
|
|
ContenidoAux.CodigoEmpresa := TablaEmpresas.FieldByName('CODIGO').AsVariant;
|
|
ContenidoModal := ContenidoAux;
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.actEliminarExecute(Sender: TObject);
|
|
var
|
|
ContenidoAux : TRdxFrameEmpresas;
|
|
begin
|
|
if (TablaEmpresas.FieldByName('CODIGO').AsVariant = EmpresaActiva.Codigo) then
|
|
EmpresaActiva.Codigo := Null;
|
|
|
|
ModoModal := Eliminar;
|
|
WidthModal := 550;
|
|
HeightModal := 530;
|
|
ContenidoAux := TfrEmpresa.Create(Self);
|
|
ContenidoAux.CodigoEmpresa := TablaEmpresas.FieldByName('CODIGO').AsVariant;
|
|
ContenidoModal := ContenidoAux;
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.actAnadirExecute(Sender: TObject);
|
|
begin
|
|
ModoModal := Anadir;
|
|
WidthModal := 550;
|
|
HeightModal := 590;
|
|
ContenidoModal := TfrEmpresa.Create(Self);
|
|
end;
|
|
|
|
procedure TfrElegirEmpresa.RdxFrameEmpresasShow(Sender: TObject);
|
|
begin
|
|
BuscarEmpresa;
|
|
end;
|
|
|
|
end.
|