Cambios para que la tienda por defecto de la aplicación se busque entre los vendedores (a un vendedor se la asocia un usuario, ahora se parte de la premisa relación 1 a 1, asi pues segun el usuario con el que se loga se buscara la tienda del vendedor asociado al usuario)

git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@221 f4e31baf-9722-1c47-927c-6f952f962d4b
This commit is contained in:
roberto 2008-05-23 14:42:57 +00:00
parent 0f266dfbec
commit 0b2cb8c58c
10 changed files with 145 additions and 227 deletions

View File

@ -83,13 +83,12 @@ begin
EndUpdate; EndUpdate;
end; end;
end; end;
end; end;
procedure TfrViewTienda.CustomViewDestroy(Sender: TObject); procedure TfrViewTienda.CustomViewDestroy(Sender: TObject);
begin begin
inherited;
FreeAndNIL(FListaTiendas); FreeAndNIL(FListaTiendas);
inherited;
end; end;
procedure TfrViewTienda.ElegirTienda(const AIDTienda: Integer); procedure TfrViewTienda.ElegirTienda(const AIDTienda: Integer);

View File

@ -67,6 +67,8 @@ type
procedure SetUsarPasswordsSeguras(const Value: Boolean); procedure SetUsarPasswordsSeguras(const Value: Boolean);
property UsarPasswordsSeguras : Boolean read GetUsarPasswordsSeguras write SetUsarPasswordsSeguras; property UsarPasswordsSeguras : Boolean read GetUsarPasswordsSeguras write SetUsarPasswordsSeguras;
procedure darIDTiendaVendedorUsuario(const IdUsuario: Integer; var AIdTienda: Integer; var ATienda: String);
{ {
procedure ChangePassword(IDUser: Integer; NewPassword: String); procedure ChangePassword(IDUser: Integer; NewPassword: String);
procedure AddRight(idUser: Integer; ItemRight: TObject; FullPath: Boolean = True); overload; procedure AddRight(idUser: Integer; ItemRight: TObject; FullPath: Boolean = True); overload;
@ -160,6 +162,8 @@ type
function ValidarPassword(const APassword : string; const ALogin : String; function ValidarPassword(const APassword : string; const ALogin : String;
const ANombre: String; out AMsg : String): boolean; const ANombre: String; out AMsg : String): boolean;
procedure darIDTiendaVendedorUsuario(const IdUsuario: Integer; var AIdTienda: Integer; var ATienda: String);
property UsarPasswordsSeguras : Boolean read GetUsarPasswordsSeguras write SetUsarPasswordsSeguras; property UsarPasswordsSeguras : Boolean read GetUsarPasswordsSeguras write SetUsarPasswordsSeguras;
property UserControl : TUserControl read FUserControl; property UserControl : TUserControl read FUserControl;
property MaxIntentosLogin : Integer read GetMaxIntentosLogin write SetMaxIntentosLogin; property MaxIntentosLogin : Integer read GetMaxIntentosLogin write SetMaxIntentosLogin;
@ -359,6 +363,11 @@ begin
Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf); Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf);
end; end;
procedure TUsuariosController.darIDTiendaVendedorUsuario(const IdUsuario: Integer; var AIdTienda: Integer; var ATienda: String);
begin
FDataModule.DarIDTiendaVendedorUsuario(IdUsuario, AIdTienda, ATienda);
end;
function TUsuariosController.DarListaPerfilesUsuario: TStringList; function TUsuariosController.DarListaPerfilesUsuario: TStringList;
var var
APerfilesUsuario: IBizPerfilUsuario; APerfilesUsuario: IBizPerfilUsuario;

View File

@ -358,14 +358,6 @@ inherited DataModuleUsuarios: TDataModuleUsuarios
Size = 250 Size = 250
DisplayLabel = 'Checksum' DisplayLabel = 'Checksum'
DictionaryEntry = 'USUARIOS_CHECKSUM' DictionaryEntry = 'USUARIOS_CHECKSUM'
end
item
Name = 'ID_EMPLEADO'
DataType = datInteger
end
item
Name = 'ID_TIENDA'
DataType = datInteger
end> end>
Params = <> Params = <>
StreamingOptions = [soDisableEventsWhileStreaming] StreamingOptions = [soDisableEventsWhileStreaming]

View File

@ -21,10 +21,12 @@ type
tbl_PERFILES: TDAMemDataTable; tbl_PERFILES: TDAMemDataTable;
ds_PERFILES: TDADataSource; ds_PERFILES: TDADataSource;
procedure DataModuleCreate(Sender: TObject); procedure DataModuleCreate(Sender: TObject);
private private
procedure InicializarCamposUserControl(AUserControl: TUserControl); procedure InicializarCamposUserControl(AUserControl: TUserControl);
procedure InicializarSettingsUserControl(AUserControl: TUserControl); procedure InicializarSettingsUserControl(AUserControl: TUserControl);
function CreateConnectorInstance : TUCDataConnector; function CreateConnectorInstance : TUCDataConnector;
public public
function GetUsuario(const ID : Integer) : IBizUsuario; function GetUsuario(const ID : Integer) : IBizUsuario;
function NuevoUsuario : IBizUsuario; function NuevoUsuario : IBizUsuario;
@ -35,6 +37,7 @@ type
function GetPerfil (const ID : Integer) : IBizPerfilUsuario; function GetPerfil (const ID : Integer) : IBizPerfilUsuario;
procedure InicializarUserControl (AUserControl : TUserControl); procedure InicializarUserControl (AUserControl : TUserControl);
procedure DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
end; end;
@ -72,6 +75,14 @@ begin
Result := GetUsuario(ID_NULO) Result := GetUsuario(ID_NULO)
end; end;
procedure TDataModuleUsuarios.DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
begin
//Nos devuelve el id de la tienda a la que pertenece el vendedor que tiene asignado
//el usuario con el que ha accedido a la aplicación.
//Esto funciona mientras la relación sea 1 a 1, cuando sea 1 a n (un usuario pertenece a varios vendedores deja de funcionar)
(srvUsuarios as IsrvUsuarios).darIDTiendaVendedorUsuario(ID_USUARIO, AIdTienda, ATienda);
end;
procedure TDataModuleUsuarios.DataModuleCreate(Sender: TObject); procedure TDataModuleUsuarios.DataModuleCreate(Sender: TObject);
begin begin
inherited; inherited;

View File

@ -17,6 +17,8 @@ type
function NuevoPerfil : IBizPerfilUsuario; function NuevoPerfil : IBizPerfilUsuario;
function GetPerfiles : IBizPerfilUsuario; function GetPerfiles : IBizPerfilUsuario;
function GetPerfil(const ID : Integer) : IBizPerfilUsuario; function GetPerfil(const ID : Integer) : IBizPerfilUsuario;
procedure DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
end; end;
implementation implementation

View File

@ -9,12 +9,12 @@ const
{ Data table rules ids { Data table rules ids
Feel free to change them to something more human readable Feel free to change them to something more human readable
but make sure they are unique in the context of your application } but make sure they are unique in the context of your application }
RID_USUARIOS = '{65B7BC42-83C2-459A-8F99-C8DCCC5AD9B6}'; RID_USUARIOS = '{33D6AE2E-8518-4E35-9BED-D5952F0A8931}';
RID_USUARIOS_EVENTOS = '{C3A73414-3473-4FF2-9994-AE5A0B64C1B5}'; RID_USUARIOS_EVENTOS = '{3310F829-00D6-43CE-B41E-60922A628503}';
RID_USUARIOS_LOGON = '{5BECFBB1-EEA4-4EA3-936D-7EB7AE7771E5}'; RID_USUARIOS_LOGON = '{E45B7C80-1F27-4D73-BCA4-CD0C2C1B7CEB}';
RID_PERMISOS = '{15383330-12A0-4322-A74B-D9BCE77F7DC1}'; RID_PERMISOS = '{0000D1FE-8EC8-4BC6-A499-2F3C215EF8F9}';
RID_PERMISOSEX = '{73F57CFD-17AC-4F91-BCD8-497A6F9A81D8}'; RID_PERMISOSEX = '{7424313C-3027-4073-97AE-4126FD866607}';
RID_PERFILES = '{F2615EE5-08AB-4A18-A97C-345924BEE04F}'; RID_PERFILES = '{9CEB3528-1A72-48AE-AA40-D7307185B2FD}';
{ Data table names } { Data table names }
nme_USUARIOS = 'USUARIOS'; nme_USUARIOS = 'USUARIOS';
@ -37,8 +37,6 @@ const
fld_USUARIOSTIPO = 'TIPO'; fld_USUARIOSTIPO = 'TIPO';
fld_USUARIOSID_PERFIL = 'ID_PERFIL'; fld_USUARIOSID_PERFIL = 'ID_PERFIL';
fld_USUARIOSCHECKSUM = 'CHECKSUM'; fld_USUARIOSCHECKSUM = 'CHECKSUM';
fld_USUARIOSID_EMPLEADO = 'ID_EMPLEADO';
fld_USUARIOSID_TIENDA = 'ID_TIENDA';
{ USUARIOS field indexes } { USUARIOS field indexes }
idx_USUARIOSID = 0; idx_USUARIOSID = 0;
@ -53,8 +51,6 @@ const
idx_USUARIOSTIPO = 9; idx_USUARIOSTIPO = 9;
idx_USUARIOSID_PERFIL = 10; idx_USUARIOSID_PERFIL = 10;
idx_USUARIOSCHECKSUM = 11; idx_USUARIOSCHECKSUM = 11;
idx_USUARIOSID_EMPLEADO = 12;
idx_USUARIOSID_TIENDA = 13;
{ USUARIOS_EVENTOS fields } { USUARIOS_EVENTOS fields }
fld_USUARIOS_EVENTOSAPLICACION = 'APLICACION'; fld_USUARIOS_EVENTOSAPLICACION = 'APLICACION';
@ -133,7 +129,7 @@ const
type type
{ IUSUARIOS } { IUSUARIOS }
IUSUARIOS = interface(IDAStronglyTypedDataTable) IUSUARIOS = interface(IDAStronglyTypedDataTable)
['{99CA8E68-602A-4E23-BE22-1243423EB570}'] ['{609EF276-E3F0-44BE-897A-B99980AB6CA6}']
{ Property getters and setters } { Property getters and setters }
function GetIDValue: Integer; function GetIDValue: Integer;
procedure SetIDValue(const aValue: Integer); procedure SetIDValue(const aValue: Integer);
@ -183,14 +179,6 @@ type
procedure SetCHECKSUMValue(const aValue: String); procedure SetCHECKSUMValue(const aValue: String);
function GetCHECKSUMIsNull: Boolean; function GetCHECKSUMIsNull: Boolean;
procedure SetCHECKSUMIsNull(const aValue: Boolean); procedure SetCHECKSUMIsNull(const aValue: Boolean);
function GetID_EMPLEADOValue: Integer;
procedure SetID_EMPLEADOValue(const aValue: Integer);
function GetID_EMPLEADOIsNull: Boolean;
procedure SetID_EMPLEADOIsNull(const aValue: Boolean);
function GetID_TIENDAValue: Integer;
procedure SetID_TIENDAValue(const aValue: Integer);
function GetID_TIENDAIsNull: Boolean;
procedure SetID_TIENDAIsNull(const aValue: Boolean);
{ Properties } { Properties }
@ -218,10 +206,6 @@ type
property ID_PERFILIsNull: Boolean read GetID_PERFILIsNull write SetID_PERFILIsNull; property ID_PERFILIsNull: Boolean read GetID_PERFILIsNull write SetID_PERFILIsNull;
property CHECKSUM: String read GetCHECKSUMValue write SetCHECKSUMValue; property CHECKSUM: String read GetCHECKSUMValue write SetCHECKSUMValue;
property CHECKSUMIsNull: Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull; property CHECKSUMIsNull: Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull;
property ID_EMPLEADO: Integer read GetID_EMPLEADOValue write SetID_EMPLEADOValue;
property ID_EMPLEADOIsNull: Boolean read GetID_EMPLEADOIsNull write SetID_EMPLEADOIsNull;
property ID_TIENDA: Integer read GetID_TIENDAValue write SetID_TIENDAValue;
property ID_TIENDAIsNull: Boolean read GetID_TIENDAIsNull write SetID_TIENDAIsNull;
end; end;
{ TUSUARIOSDataTableRules } { TUSUARIOSDataTableRules }
@ -277,14 +261,6 @@ type
procedure SetCHECKSUMValue(const aValue: String); virtual; procedure SetCHECKSUMValue(const aValue: String); virtual;
function GetCHECKSUMIsNull: Boolean; virtual; function GetCHECKSUMIsNull: Boolean; virtual;
procedure SetCHECKSUMIsNull(const aValue: Boolean); virtual; procedure SetCHECKSUMIsNull(const aValue: Boolean); virtual;
function GetID_EMPLEADOValue: Integer; virtual;
procedure SetID_EMPLEADOValue(const aValue: Integer); virtual;
function GetID_EMPLEADOIsNull: Boolean; virtual;
procedure SetID_EMPLEADOIsNull(const aValue: Boolean); virtual;
function GetID_TIENDAValue: Integer; virtual;
procedure SetID_TIENDAValue(const aValue: Integer); virtual;
function GetID_TIENDAIsNull: Boolean; virtual;
procedure SetID_TIENDAIsNull(const aValue: Boolean); virtual;
{ Properties } { Properties }
property ID: Integer read GetIDValue write SetIDValue; property ID: Integer read GetIDValue write SetIDValue;
@ -311,10 +287,6 @@ type
property ID_PERFILIsNull: Boolean read GetID_PERFILIsNull write SetID_PERFILIsNull; property ID_PERFILIsNull: Boolean read GetID_PERFILIsNull write SetID_PERFILIsNull;
property CHECKSUM: String read GetCHECKSUMValue write SetCHECKSUMValue; property CHECKSUM: String read GetCHECKSUMValue write SetCHECKSUMValue;
property CHECKSUMIsNull: Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull; property CHECKSUMIsNull: Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull;
property ID_EMPLEADO: Integer read GetID_EMPLEADOValue write SetID_EMPLEADOValue;
property ID_EMPLEADOIsNull: Boolean read GetID_EMPLEADOIsNull write SetID_EMPLEADOIsNull;
property ID_TIENDA: Integer read GetID_TIENDAValue write SetID_TIENDAValue;
property ID_TIENDAIsNull: Boolean read GetID_TIENDAIsNull write SetID_TIENDAIsNull;
public public
constructor Create(aDataTable: TDADataTable); override; constructor Create(aDataTable: TDADataTable); override;
@ -324,7 +296,7 @@ type
{ IUSUARIOS_EVENTOS } { IUSUARIOS_EVENTOS }
IUSUARIOS_EVENTOS = interface(IDAStronglyTypedDataTable) IUSUARIOS_EVENTOS = interface(IDAStronglyTypedDataTable)
['{8266AB36-18C0-48E4-8CB1-13779322E8C7}'] ['{57EB0AE4-C30E-4AEA-BB87-FBC94F54B462}']
{ Property getters and setters } { Property getters and setters }
function GetAPLICACIONValue: String; function GetAPLICACIONValue: String;
procedure SetAPLICACIONValue(const aValue: String); procedure SetAPLICACIONValue(const aValue: String);
@ -455,7 +427,7 @@ type
{ IUSUARIOS_LOGON } { IUSUARIOS_LOGON }
IUSUARIOS_LOGON = interface(IDAStronglyTypedDataTable) IUSUARIOS_LOGON = interface(IDAStronglyTypedDataTable)
['{1721EA9B-77A8-4E0E-978A-EDCD53AA859F}'] ['{341AC508-0746-40B5-A092-8C1D9CDBC604}']
{ Property getters and setters } { Property getters and setters }
function GetLOGONIDValue: String; function GetLOGONIDValue: String;
procedure SetLOGONIDValue(const aValue: String); procedure SetLOGONIDValue(const aValue: String);
@ -538,7 +510,7 @@ type
{ IPERMISOS } { IPERMISOS }
IPERMISOS = interface(IDAStronglyTypedDataTable) IPERMISOS = interface(IDAStronglyTypedDataTable)
['{92A64248-1BF3-424E-B311-4C879E30177A}'] ['{323F36F2-E464-4CAB-AE8C-B72295B949A4}']
{ Property getters and setters } { Property getters and setters }
function GetID_USUARIOValue: Integer; function GetID_USUARIOValue: Integer;
procedure SetID_USUARIOValue(const aValue: Integer); procedure SetID_USUARIOValue(const aValue: Integer);
@ -609,7 +581,7 @@ type
{ IPERMISOSEX } { IPERMISOSEX }
IPERMISOSEX = interface(IDAStronglyTypedDataTable) IPERMISOSEX = interface(IDAStronglyTypedDataTable)
['{C134946D-8CCA-44D0-9C52-7B3B5EB08E49}'] ['{84605C14-E7FC-4E1E-BE35-A0EBC3E7A02F}']
{ Property getters and setters } { Property getters and setters }
function GetID_USUARIOValue: Integer; function GetID_USUARIOValue: Integer;
procedure SetID_USUARIOValue(const aValue: Integer); procedure SetID_USUARIOValue(const aValue: Integer);
@ -692,7 +664,7 @@ type
{ IPERFILES } { IPERFILES }
IPERFILES = interface(IDAStronglyTypedDataTable) IPERFILES = interface(IDAStronglyTypedDataTable)
['{4B59467A-22C8-4D7C-A516-BBF3D6C6801A}'] ['{A0804B85-AECF-4F9A-A3C1-85068D16D302}']
{ Property getters and setters } { Property getters and setters }
function GetIDValue: Integer; function GetIDValue: Integer;
procedure SetIDValue(const aValue: Integer); procedure SetIDValue(const aValue: Integer);
@ -1028,48 +1000,6 @@ begin
DataTable.Fields[idx_USUARIOSCHECKSUM].AsVariant := Null; DataTable.Fields[idx_USUARIOSCHECKSUM].AsVariant := Null;
end; end;
function TUSUARIOSDataTableRules.GetID_EMPLEADOValue: Integer;
begin
result := DataTable.Fields[idx_USUARIOSID_EMPLEADO].AsInteger;
end;
procedure TUSUARIOSDataTableRules.SetID_EMPLEADOValue(const aValue: Integer);
begin
DataTable.Fields[idx_USUARIOSID_EMPLEADO].AsInteger := aValue;
end;
function TUSUARIOSDataTableRules.GetID_EMPLEADOIsNull: boolean;
begin
result := DataTable.Fields[idx_USUARIOSID_EMPLEADO].IsNull;
end;
procedure TUSUARIOSDataTableRules.SetID_EMPLEADOIsNull(const aValue: Boolean);
begin
if aValue then
DataTable.Fields[idx_USUARIOSID_EMPLEADO].AsVariant := Null;
end;
function TUSUARIOSDataTableRules.GetID_TIENDAValue: Integer;
begin
result := DataTable.Fields[idx_USUARIOSID_TIENDA].AsInteger;
end;
procedure TUSUARIOSDataTableRules.SetID_TIENDAValue(const aValue: Integer);
begin
DataTable.Fields[idx_USUARIOSID_TIENDA].AsInteger := aValue;
end;
function TUSUARIOSDataTableRules.GetID_TIENDAIsNull: boolean;
begin
result := DataTable.Fields[idx_USUARIOSID_TIENDA].IsNull;
end;
procedure TUSUARIOSDataTableRules.SetID_TIENDAIsNull(const aValue: Boolean);
begin
if aValue then
DataTable.Fields[idx_USUARIOSID_TIENDA].AsVariant := Null;
end;
{ TUSUARIOS_EVENTOSDataTableRules } { TUSUARIOS_EVENTOSDataTableRules }
constructor TUSUARIOS_EVENTOSDataTableRules.Create(aDataTable: TDADataTable); constructor TUSUARIOS_EVENTOSDataTableRules.Create(aDataTable: TDADataTable);

View File

@ -9,17 +9,17 @@ const
{ Delta rules ids { Delta rules ids
Feel free to change them to something more human readable Feel free to change them to something more human readable
but make sure they are unique in the context of your application } but make sure they are unique in the context of your application }
RID_USUARIOSDelta = '{767AECF0-73DF-483C-BCD3-83A9E425177B}'; RID_USUARIOSDelta = '{0CF1FB0D-0814-43C8-9EEA-C73F89D9EEFC}';
RID_USUARIOS_EVENTOSDelta = '{AF20CF49-049C-4541-B01D-CCAAC2CDA912}'; RID_USUARIOS_EVENTOSDelta = '{70259783-5480-4B8A-8C19-E5F3AF2ADF5E}';
RID_USUARIOS_LOGONDelta = '{C4702DF5-B82A-469C-A97E-79BAF8012A26}'; RID_USUARIOS_LOGONDelta = '{664180AD-0611-4CF4-BDE0-AA2BA4AC9973}';
RID_PERMISOSDelta = '{97700BF0-18B1-4CB0-8AFD-340B150C6A59}'; RID_PERMISOSDelta = '{820DAE3D-63A0-4EEB-862C-A85EDF85E804}';
RID_PERMISOSEXDelta = '{2F16E82F-201A-48B6-8898-32C56932E696}'; RID_PERMISOSEXDelta = '{A01553FE-193F-4827-A0F2-9904D94C140F}';
RID_PERFILESDelta = '{CA9075EF-2994-4366-94B6-7416B3D9936E}'; RID_PERFILESDelta = '{E7F3AB12-F120-4630-8AD5-01021379CC52}';
type type
{ IUSUARIOSDelta } { IUSUARIOSDelta }
IUSUARIOSDelta = interface(IUSUARIOS) IUSUARIOSDelta = interface(IUSUARIOS)
['{767AECF0-73DF-483C-BCD3-83A9E425177B}'] ['{0CF1FB0D-0814-43C8-9EEA-C73F89D9EEFC}']
{ Property getters and setters } { Property getters and setters }
function GetOldIDValue : Integer; function GetOldIDValue : Integer;
function GetOldUSERNAMEValue : String; function GetOldUSERNAMEValue : String;
@ -33,8 +33,6 @@ type
function GetOldTIPOValue : String; function GetOldTIPOValue : String;
function GetOldID_PERFILValue : Integer; function GetOldID_PERFILValue : Integer;
function GetOldCHECKSUMValue : String; function GetOldCHECKSUMValue : String;
function GetOldID_EMPLEADOValue : Integer;
function GetOldID_TIENDAValue : Integer;
{ Properties } { Properties }
property OldID : Integer read GetOldIDValue; property OldID : Integer read GetOldIDValue;
@ -49,8 +47,6 @@ type
property OldTIPO : String read GetOldTIPOValue; property OldTIPO : String read GetOldTIPOValue;
property OldID_PERFIL : Integer read GetOldID_PERFILValue; property OldID_PERFIL : Integer read GetOldID_PERFILValue;
property OldCHECKSUM : String read GetOldCHECKSUMValue; property OldCHECKSUM : String read GetOldCHECKSUMValue;
property OldID_EMPLEADO : Integer read GetOldID_EMPLEADOValue;
property OldID_TIENDA : Integer read GetOldID_TIENDAValue;
end; end;
{ TUSUARIOSBusinessProcessorRules } { TUSUARIOSBusinessProcessorRules }
@ -130,18 +126,6 @@ type
function GetOldCHECKSUMIsNull: Boolean; virtual; function GetOldCHECKSUMIsNull: Boolean; virtual;
procedure SetCHECKSUMValue(const aValue: String); virtual; procedure SetCHECKSUMValue(const aValue: String); virtual;
procedure SetCHECKSUMIsNull(const aValue: Boolean); virtual; procedure SetCHECKSUMIsNull(const aValue: Boolean); virtual;
function GetID_EMPLEADOValue: Integer; virtual;
function GetID_EMPLEADOIsNull: Boolean; virtual;
function GetOldID_EMPLEADOValue: Integer; virtual;
function GetOldID_EMPLEADOIsNull: Boolean; virtual;
procedure SetID_EMPLEADOValue(const aValue: Integer); virtual;
procedure SetID_EMPLEADOIsNull(const aValue: Boolean); virtual;
function GetID_TIENDAValue: Integer; virtual;
function GetID_TIENDAIsNull: Boolean; virtual;
function GetOldID_TIENDAValue: Integer; virtual;
function GetOldID_TIENDAIsNull: Boolean; virtual;
procedure SetID_TIENDAValue(const aValue: Integer); virtual;
procedure SetID_TIENDAIsNull(const aValue: Boolean); virtual;
{ Properties } { Properties }
property ID : Integer read GetIDValue write SetIDValue; property ID : Integer read GetIDValue write SetIDValue;
@ -192,14 +176,6 @@ type
property CHECKSUMIsNull : Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull; property CHECKSUMIsNull : Boolean read GetCHECKSUMIsNull write SetCHECKSUMIsNull;
property OldCHECKSUM : String read GetOldCHECKSUMValue; property OldCHECKSUM : String read GetOldCHECKSUMValue;
property OldCHECKSUMIsNull : Boolean read GetOldCHECKSUMIsNull; property OldCHECKSUMIsNull : Boolean read GetOldCHECKSUMIsNull;
property ID_EMPLEADO : Integer read GetID_EMPLEADOValue write SetID_EMPLEADOValue;
property ID_EMPLEADOIsNull : Boolean read GetID_EMPLEADOIsNull write SetID_EMPLEADOIsNull;
property OldID_EMPLEADO : Integer read GetOldID_EMPLEADOValue;
property OldID_EMPLEADOIsNull : Boolean read GetOldID_EMPLEADOIsNull;
property ID_TIENDA : Integer read GetID_TIENDAValue write SetID_TIENDAValue;
property ID_TIENDAIsNull : Boolean read GetID_TIENDAIsNull write SetID_TIENDAIsNull;
property OldID_TIENDA : Integer read GetOldID_TIENDAValue;
property OldID_TIENDAIsNull : Boolean read GetOldID_TIENDAIsNull;
public public
constructor Create(aBusinessProcessor: TDABusinessProcessor); override; constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
@ -209,7 +185,7 @@ type
{ IUSUARIOS_EVENTOSDelta } { IUSUARIOS_EVENTOSDelta }
IUSUARIOS_EVENTOSDelta = interface(IUSUARIOS_EVENTOS) IUSUARIOS_EVENTOSDelta = interface(IUSUARIOS_EVENTOS)
['{AF20CF49-049C-4541-B01D-CCAAC2CDA912}'] ['{70259783-5480-4B8A-8C19-E5F3AF2ADF5E}']
{ Property getters and setters } { Property getters and setters }
function GetOldAPLICACIONValue : String; function GetOldAPLICACIONValue : String;
function GetOldID_USUARIOValue : Integer; function GetOldID_USUARIOValue : Integer;
@ -340,7 +316,7 @@ type
{ IUSUARIOS_LOGONDelta } { IUSUARIOS_LOGONDelta }
IUSUARIOS_LOGONDelta = interface(IUSUARIOS_LOGON) IUSUARIOS_LOGONDelta = interface(IUSUARIOS_LOGON)
['{C4702DF5-B82A-469C-A97E-79BAF8012A26}'] ['{664180AD-0611-4CF4-BDE0-AA2BA4AC9973}']
{ Property getters and setters } { Property getters and setters }
function GetOldLOGONIDValue : String; function GetOldLOGONIDValue : String;
function GetOldID_USUARIOValue : Integer; function GetOldID_USUARIOValue : Integer;
@ -422,7 +398,7 @@ type
{ IPERMISOSDelta } { IPERMISOSDelta }
IPERMISOSDelta = interface(IPERMISOS) IPERMISOSDelta = interface(IPERMISOS)
['{97700BF0-18B1-4CB0-8AFD-340B150C6A59}'] ['{820DAE3D-63A0-4EEB-862C-A85EDF85E804}']
{ Property getters and setters } { Property getters and setters }
function GetOldID_USUARIOValue : Integer; function GetOldID_USUARIOValue : Integer;
function GetOldMODULOValue : String; function GetOldMODULOValue : String;
@ -492,7 +468,7 @@ type
{ IPERMISOSEXDelta } { IPERMISOSEXDelta }
IPERMISOSEXDelta = interface(IPERMISOSEX) IPERMISOSEXDelta = interface(IPERMISOSEX)
['{2F16E82F-201A-48B6-8898-32C56932E696}'] ['{A01553FE-193F-4827-A0F2-9904D94C140F}']
{ Property getters and setters } { Property getters and setters }
function GetOldID_USUARIOValue : Integer; function GetOldID_USUARIOValue : Integer;
function GetOldMODULOValue : String; function GetOldMODULOValue : String;
@ -574,7 +550,7 @@ type
{ IPERFILESDelta } { IPERFILESDelta }
IPERFILESDelta = interface(IPERFILES) IPERFILESDelta = interface(IPERFILES)
['{CA9075EF-2994-4366-94B6-7416B3D9936E}'] ['{E7F3AB12-F120-4630-8AD5-01021379CC52}']
{ Property getters and setters } { Property getters and setters }
function GetOldIDValue : Integer; function GetOldIDValue : Integer;
function GetOldUSERNAMEValue : String; function GetOldUSERNAMEValue : String;
@ -1030,68 +1006,6 @@ begin
BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSCHECKSUM] := Null; BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSCHECKSUM] := Null;
end; end;
function TUSUARIOSBusinessProcessorRules.GetID_EMPLEADOValue: Integer;
begin
result := BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_EMPLEADO];
end;
function TUSUARIOSBusinessProcessorRules.GetID_EMPLEADOIsNull: Boolean;
begin
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_EMPLEADO]);
end;
function TUSUARIOSBusinessProcessorRules.GetOldID_EMPLEADOValue: Integer;
begin
result := BusinessProcessor.CurrentChange.OldValueByName[fld_USUARIOSID_EMPLEADO];
end;
function TUSUARIOSBusinessProcessorRules.GetOldID_EMPLEADOIsNull: Boolean;
begin
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_USUARIOSID_EMPLEADO]);
end;
procedure TUSUARIOSBusinessProcessorRules.SetID_EMPLEADOValue(const aValue: Integer);
begin
BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_EMPLEADO] := aValue;
end;
procedure TUSUARIOSBusinessProcessorRules.SetID_EMPLEADOIsNull(const aValue: Boolean);
begin
if aValue then
BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_EMPLEADO] := Null;
end;
function TUSUARIOSBusinessProcessorRules.GetID_TIENDAValue: Integer;
begin
result := BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_TIENDA];
end;
function TUSUARIOSBusinessProcessorRules.GetID_TIENDAIsNull: Boolean;
begin
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_TIENDA]);
end;
function TUSUARIOSBusinessProcessorRules.GetOldID_TIENDAValue: Integer;
begin
result := BusinessProcessor.CurrentChange.OldValueByName[fld_USUARIOSID_TIENDA];
end;
function TUSUARIOSBusinessProcessorRules.GetOldID_TIENDAIsNull: Boolean;
begin
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_USUARIOSID_TIENDA]);
end;
procedure TUSUARIOSBusinessProcessorRules.SetID_TIENDAValue(const aValue: Integer);
begin
BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_TIENDA] := aValue;
end;
procedure TUSUARIOSBusinessProcessorRules.SetID_TIENDAIsNull(const aValue: Boolean);
begin
if aValue then
BusinessProcessor.CurrentChange.NewValueByName[fld_USUARIOSID_TIENDA] := Null;
end;
{ TUSUARIOS_EVENTOSBusinessProcessorRules } { TUSUARIOS_EVENTOSBusinessProcessorRules }
constructor TUSUARIOS_EVENTOSBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor); constructor TUSUARIOS_EVENTOSBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);

View File

@ -117,6 +117,47 @@ object srvUsuarios: TsrvUsuarios
DataDictionary = DataDictionary DataDictionary = DataDictionary
Diagrams = Diagrams Diagrams = Diagrams
Datasets = < Datasets = <
item
Params = <
item
Name = 'ID_USUARIO'
Value = ''
ParamType = daptInput
end>
Statements = <
item
Connection = 'IBX'
ConnectionType = 'Interbase'
Default = True
TargetTable = 'V_VENDEDORES'
Name = 'IBX'
SQL =
'select ID_TIENDA, TIENDA'#10'from V_VENDEDORES'#10'left join USUARIOS on' +
' (USUARIOS.ID = V_VENDEDORES.ID_USUARIO)'#10'where USUARIOS.ID = :ID' +
'_USUARIO'#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID_TIENDA'
TableField = 'ID_TIENDA'
end
item
DatasetField = 'TIENDA'
TableField = 'TIENDA'
end>
end>
Name = 'darTiendaVendedorUsuario'
Fields = <
item
Name = 'ID_TIENDA'
DataType = datInteger
end
item
Name = 'TIENDA'
DataType = datString
Size = 255
end>
end
item item
Params = <> Params = <>
Statements = < Statements = <
@ -174,14 +215,6 @@ object srvUsuarios: TsrvUsuarios
item item
DatasetField = 'CHECKSUM' DatasetField = 'CHECKSUM'
TableField = 'CHECKSUM' TableField = 'CHECKSUM'
end
item
DatasetField = 'ID_EMPLEADO'
TableField = 'ID_EMPLEADO'
end
item
DatasetField = 'ID_TIENDA'
TableField = 'ID_TIENDA'
end> end>
end> end>
Name = 'USUARIOS' Name = 'USUARIOS'
@ -253,14 +286,6 @@ object srvUsuarios: TsrvUsuarios
DataType = datString DataType = datString
Size = 250 Size = 250
DictionaryEntry = 'USUARIOS_CHECKSUM' DictionaryEntry = 'USUARIOS_CHECKSUM'
end
item
Name = 'ID_EMPLEADO'
DataType = datInteger
end
item
Name = 'ID_TIENDA'
DataType = datInteger
end> end>
end end
item item

View File

@ -29,16 +29,21 @@ type
procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject; procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject;
var aConnectionName: string); var aConnectionName: string);
procedure DataAbstractServiceCreate(Sender: TObject); procedure DataAbstractServiceCreate(Sender: TObject);
private
protected protected
{ IsrvUsuarios methods } procedure DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
end; end;
implementation implementation
{$R *.dfm} {$R *.dfm}
uses uses
{Generated:} FactuGES_Invk, uDataModuleServer; {Generated:} FactuGES_Invk, uROClasses, uDAInterfaces, uDataModuleServer;
const
CTE_ID_TODAS = 0;
CTE_TODAS = 'Todas';
procedure Create_srvUsuarios(out anInstance : IUnknown); procedure Create_srvUsuarios(out anInstance : IUnknown);
begin begin
@ -46,6 +51,43 @@ begin
end; end;
{ srvUsuarios } { srvUsuarios }
procedure TsrvUsuarios.DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
var
AConn : IDAConnection;
dsData: IDADataset;
begin
AConn := dmServer.ConnectionManager.NewConnection(dmServer.ConnectionManager.GetDefaultConnectionName);
try
try
dsData := schUsuarios.NewDataset(AConn, 'darTiendaVendedorUsuario', ['ID_USUARIO'], [ID_USUARIO]);
dsData.Active := True;
case dsData.RecordCount of
0: begin
AIdTienda := CTE_ID_TODAS;
ATienda := CTE_TODAS;
end;
1: begin
AIdTienda := dsData.FieldByName('ID_TIENDA').AsInteger;
ATienda := dsData.FieldByName('TIENDA').AsString;
end
else
RaiseError('Error al buscar tienda por defecto para el usuario');
end;
AConn.CommitTransaction;
except
RaiseError('Error al buscar ejercicio activo de la empresa');
AConn.RollbackTransaction;
end;
finally
dsData := NIL;
end;
end;
procedure TsrvUsuarios.DataAbstractServiceBeforeAcquireConnection( procedure TsrvUsuarios.DataAbstractServiceBeforeAcquireConnection(
aSender: TObject; var aConnectionName: string); aSender: TObject; var aConnectionName: string);
begin begin

View File

@ -67,7 +67,6 @@ type
property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent; property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent;
property Terminated : Boolean read GetTerminated; property Terminated : Boolean read GetTerminated;
//TEMPORAL
function getVAR_IDTIENDA : Integer; function getVAR_IDTIENDA : Integer;
procedure setVAR_IDTIENDA (AValue : Integer); procedure setVAR_IDTIENDA (AValue : Integer);
function getVAR_TIENDA : String; function getVAR_TIENDA : String;
@ -82,7 +81,6 @@ type
TAppFactuGES = class(TInterfacedObject, IAppFactuGES) TAppFactuGES = class(TInterfacedObject, IAppFactuGES)
private private
//TEMPORAL
FVAR_IDTIENDA: Integer; FVAR_IDTIENDA: Integer;
FVAR_TIENDA: String; FVAR_TIENDA: String;
@ -121,6 +119,7 @@ type
procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo); procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo);
procedure RegisterModule(AModuleInfo : TModuleInfo); procedure RegisterModule(AModuleInfo : TModuleInfo);
procedure PonerTiendaPorDefecto; procedure PonerTiendaPorDefecto;
protected protected
procedure DoMainForm; procedure DoMainForm;
@ -128,6 +127,7 @@ type
procedure ShowSplashForm; procedure ShowSplashForm;
procedure HideSplashForm; procedure HideSplashForm;
procedure UpdateSplashForm; procedure UpdateSplashForm;
public public
constructor Create; virtual; constructor Create; virtual;
@ -154,7 +154,6 @@ type
property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent; property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent;
property Terminated : Boolean read GetTerminated; property Terminated : Boolean read GetTerminated;
//TEMPORAL
function getVAR_IDTIENDA : Integer; function getVAR_IDTIENDA : Integer;
procedure setVAR_IDTIENDA (AValue : Integer); procedure setVAR_IDTIENDA (AValue : Integer);
function getVAR_TIENDA : String; function getVAR_TIENDA : String;
@ -173,9 +172,7 @@ implementation
uses uses
Dialogs, uDialogUtils, cxControls, uUsuariosViewRegister, Dialogs, uDialogUtils, cxControls, uUsuariosViewRegister,
uEmpresasViewRegister, uEjerciciosController, uAppInfoUtils, uEmpresasViewRegister, uEjerciciosController, uAppInfoUtils;
//TEMPORAL
IniFiles;
procedure TAppFactuGES.CambiarEjercicio(const AIDEmpresa: Integer); procedure TAppFactuGES.CambiarEjercicio(const AIDEmpresa: Integer);
var var
@ -220,20 +217,17 @@ begin
FDoLoadModulesEvent(); FDoLoadModulesEvent();
end; end;
//TEMPORAL
procedure TAppFactuGES.PonerTiendaPorDefecto; procedure TAppFactuGES.PonerTiendaPorDefecto;
var var
Fichero : String; AIdTienda: Integer;
ATienda: String;
begin begin
Fichero := ExtractFileDir(ParamStr(0))+ '\' + 'FACTUGES.INI'; //Nos devuelve el id de la tienda a la que pertenece el vendedor que tiene asignado
//el usuario con el que ha accedido a la aplicación.
with TIniFile.Create(Fichero) do //Esto funciona mientras la relación sea 1 a 1, cuando sea 1 a n (un usuario pertenece a varios vendedores deja de funcionar)
begin UsuariosController.darIDTiendaVendedorUsuario(UsuarioActivo.ID, AIdTienda, ATienda);
VAR_IDTIENDA := ReadInteger ('VARIABLES', 'IdTienda', 0); VAR_IDTIENDA := AIdTienda;
VAR_TIENDA := ReadString ('VARIABLES', 'Tienda', 'Todas'); VAR_TIENDA := ATienda;
Free;
end;
end; end;
constructor TAppFactuGES.Create; constructor TAppFactuGES.Create;