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

352 lines
10 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: 03-11-2002
Versión actual: 1.0.0
Fecha versión actual: 03-11-2002
===============================================================================
Modificaciones:
Fecha Comentarios
---------------------------------------------------------------------------
===============================================================================
}
unit Principal;
interface
uses
Windows, ComCtrls, ToolWin, Graphics, Controls,
ExtCtrls, Classes, sysutils, forms, Menus, StdCtrls,
am2000menuitem, am2000popupmenu, am2000, RdxBotones, RdxPaneles,
RdxFrame, ActnList, FthImage, pngimage, am2000utils;
type
TfrPrincipal = class(TRdxFrame)
BarraEstado: TStatusBar;
Acciones: TActionList;
actArticulosModelo: TAction;
actDatos: TAction;
actCompras: TAction;
actVentas: TAction;
actContabilidad: TAction;
actInformes: TAction;
MenuOpciones: TPopupMenu2000;
MenuItem20001: TMenuItem2000;
mnuDocumentos: TMenuItem2000;
MenuItem20002: TMenuItem2000;
MenuItem20003: TMenuItem2000;
MenuItem20004: TMenuItem2000;
MenuItem20005: TMenuItem2000;
actHacerCopia: TAction;
actRestaurarCopia: TAction;
actDocumentos: TAction;
pnlBarraSuperior: TRdxGradientePanel;
imgFondo: TImage;
bEmpresas: TFourthImage;
JzLabel1: TLabel;
bProveedores: TFourthImage;
bClientes: TFourthImage;
bContabilidad: TFourthImage;
bDatos: TFourthImage;
bOpciones: TFourthImage;
JzLabel7: TLabel;
JzLabel8: TLabel;
JzLabel9: TLabel;
JzLabel10: TLabel;
JzLabel11: TLabel;
JzLabel12: TLabel;
bInformes: TFourthImage;
actEmpresas: TAction;
eNombreEmpresa: TLabel;
ConfiguracinPropiedades1: TMenuItem2000;
actPropiedades: TAction;
MenuItem1: TMenuItem2000;
actContadores: TAction;
bSincronizacion: TFourthImage;
Label1: TLabel;
actSincronizacion: TAction;
bAgenda: TFourthImage;
eAgenda: TLabel;
actAgenda: TAction;
actActualizar: TAction;
actConfigActualizazion: TAction;
MenuItem5: TMenuItem2000;
MenuItem6: TMenuItem2000;
MenuItem7: TMenuItem2000;
procedure LogotipoClick(Sender: TObject);
procedure actDatosExecute(Sender: TObject);
procedure actComprasExecute(Sender: TObject);
procedure actVentasExecute(Sender: TObject);
procedure actContabilidadExecute(Sender: TObject);
procedure actInformesExecute(Sender: TObject);
procedure actArticulosModeloExecute(Sender: TObject);
procedure actHacerCopiaExecute(Sender: TObject);
procedure actRestaurarCopiaExecute(Sender: TObject);
procedure actDocumentosExecute(Sender: TObject);
procedure bOpcionesClick(Sender: TObject);
procedure actEmpresasExecute(Sender: TObject);
procedure actDatosUpdate(Sender: TObject);
procedure RdxFrameResize(Sender: TObject);
procedure actPropiedadesExecute(Sender: TObject);
procedure actContadoresExecute(Sender: TObject);
procedure actSincronizacionExecute(Sender: TObject);
procedure actAgendaExecute(Sender: TObject);
procedure actConfigActualizazionExecute(Sender: TObject);
procedure actActualizarExecute(Sender: TObject);
private
public
Version : String;
constructor Create(AOwner : TComponent); override;
procedure ManejadorExcepciones(Sender: TObject; E: Exception);
published
procedure OnCloseApp (Sender: TObject; var Action: TCloseAction);
end;
var
frPrincipal: TfrPrincipal;
implementation
{$R *.DFM}
uses
ContenidoPrincipal, Mensajes, SysFunc, Propiedades,
Excepciones, BaseDatos, BarraDatos, DatosContadores,
BarraClientes, BarraProveedores, BarraLibros, BarraInformes,
HacerCopiaSeguridad, RestaurarCopiaSeguridad, Documentos, ArticulosModelo,
TablaEmpresas, RdxEmpresaActiva, Literales, Configuracion,
ElegirEmpresa, Variants, Entidades, Sincronizacion, BarraAgenda,
Actualizacion;
{ TfrPrincipal }
constructor TfrPrincipal.Create(AOwner: TComponent);
begin
inherited;
ConfigurarVentanaPrincipal(Self);
if PuedeSincronizar then
actSincronizacion.OnUpdate := actDatosUpdate
else begin
actSincronizacion.Enabled := False;
actSincronizacion.OnUpdate := NIL;
end;
Contenido := TfrContenidoPrincipal.Create(Self);
end;
procedure TfrPrincipal.LogotipoClick(Sender: TObject);
begin
Contenido := TfrContenidoPrincipal.Create(Self);
end;
procedure TfrPrincipal.OnCloseApp(Sender: TObject;
var Action: TCloseAction);
begin
Action := caNone;
if VerMensajePregunta(msgDeseaSalir) = mrYES then
if CloseFrame then Action := caFree;
end;
procedure TfrPrincipal.ManejadorExcepciones(Sender: TObject; E: Exception);
begin
TratarExcepcion(E);
end;
procedure TfrPrincipal.actArticulosModeloExecute(Sender: TObject);
begin
HeightModal := 600;
WidthModal := 750;
ContenidoModal := TfrArticulosModelo.Create(Self);
end;
procedure TfrPrincipal.actDatosExecute(Sender: TObject);
begin
Contenido := TfrBarraDatos.Create(Self);
end;
procedure TfrPrincipal.actComprasExecute(Sender: TObject);
begin
Contenido := TfrBarraProveedores.Create(Self);
end;
procedure TfrPrincipal.actVentasExecute(Sender: TObject);
begin
Contenido := TfrBarraClientes.Create(Self);
end;
procedure TfrPrincipal.actContabilidadExecute(Sender: TObject);
begin
Contenido := TfrBarraLibros.Create(Self);
end;
procedure TfrPrincipal.actInformesExecute(Sender: TObject);
begin
Contenido := TfrBarraInformes.Create(Self);
end;
procedure TfrPrincipal.actHacerCopiaExecute(Sender: TObject);
begin
LogotipoClick(Sender);
HeightModal := 340;
WidthModal := 412;
EntidadModal := entOpciones;
ModoModal := Consultar;
ContenidoModal := TfrHacerCopiaSeguridad.Create(Self);
end;
procedure TfrPrincipal.actRestaurarCopiaExecute(Sender: TObject);
begin
LogotipoClick(Sender);
if Contenido.Name <> 'TfrContenidoPrincipal' then
Exit;
HeightModal := 340;
WidthModal := 412;
EntidadModal := entOpciones;
ModoModal := Consultar;
ContenidoModal := TfrRestaurarCopiaSeguridad.Create(Self);
end;
procedure TfrPrincipal.actDocumentosExecute(Sender: TObject);
begin
frDocumentos := TfrDocumentos.Create(Self);
try
frDocumentos.ShowModal;
finally
frDocumentos.Free;
end;
end;
procedure TfrPrincipal.bOpcionesClick(Sender: TObject);
var
P : TPoint;
begin
if (Sender as TImage).PopupMenu <> NIL then
begin
P.X := (Sender as TImage).Left;
P.Y := pnlBarraSuperior.Top + pnlBarraSuperior.Height;
P := ClientToScreen(P);
(Sender as TImage).PopupMenu.Popup(P.X, P.Y);
end;
end;
procedure TfrPrincipal.actEmpresasExecute(Sender: TObject);
var
EmpresaAnterior : Variant;
begin
if (Contenido <> NIL) then
Contenido := TfrContenidoPrincipal.Create(Self);
if (Contenido is TfrContenidoPrincipal) then
begin
EmpresaAnterior := EmpresaActiva.Codigo;
HeightModal := 370;
WidthModal := 594;
ContenidoModal := TfrElegirEmpresa.Create(Self);
if (EmpresaAnterior <> EmpresaActiva.Codigo) then
begin
if EmpresaActiva.Codigo <> -1 then
begin
eNombreEmpresa.Caption := EmpresaActiva.NombreComercial;
BarraEstado.Panels[0].Text := 'Empresa: ' + EmpresaActiva.NombreComercial;
Application.MainForm.Caption := 'FactuGES v' + Version + ' - ' + EmpresaActiva.NombreComercial;
actAgenda.Execute;
end
else
begin
eNombreEmpresa.Caption := '';
BarraEstado.Panels[0].Text := '';
Application.MainForm.Caption := '';
end;
end;
end;
end;
procedure TfrPrincipal.actDatosUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := (EmpresaActiva.Codigo <> -1);
end;
procedure TfrPrincipal.RdxFrameResize(Sender: TObject);
begin
inherited;
eNombreEmpresa.Left := pnlBarraSuperior.Width - eNombreEmpresa.Width - 10;
end;
procedure TfrPrincipal.actPropiedadesExecute(Sender: TObject);
begin
ModoModal := Anadir;
WidthModal := 800;
ContenidoModal := TfrPropiedades.Create(Self);
end;
procedure TfrPrincipal.actContadoresExecute(Sender: TObject);
begin
ModoModal := Anadir;
WidthModal := 400;
ContenidoModal := TfrDatosContadores.Create(Self);
end;
procedure TfrPrincipal.actSincronizacionExecute(Sender: TObject);
begin
inherited;
Contenido := TfrContenidoPrincipal.Create(Self);
fSincronizacion := TfSincronizacion.Create(Self);
try
fSincronizacion.ShowModal;
finally
fSincronizacion.Free;
end;
end;
procedure TfrPrincipal.actAgendaExecute(Sender: TObject);
begin
Contenido := TfrBarraAgenda.Create(Self);
end;
procedure TfrPrincipal.actConfigActualizazionExecute(Sender: TObject);
begin
fConfiguracion := TfConfiguracion.Create(Self);
try
fConfiguracion.ShowModal;
finally
FreeAndNil(fConfiguracion);
end;
end;
procedure TfrPrincipal.actActualizarExecute(Sender: TObject);
begin
fConfiguracion := TfConfiguracion.Create(Self);
try
if not fConfiguracion.HayConfiguracion then
begin
if (VerMensajePregunta('Todavía no se ha indicado la configuración para las actualizaciones automáticas.' +
#10#13 + '¿Desea hacerlo ahora?') = IDYES) then
begin
actConfigActualizazion.Execute;
actActualizar.Execute; // Reintentar;
end
else
VerMensaje('No se pueden consultar las actualizaciones hasta que no se configuren.');
end
else
fConfiguracion.Actualizar;
finally
FreeAndNil(fConfiguracion);
end;
end;
end.