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;
end;
end;
end;
procedure TfrViewTienda.CustomViewDestroy(Sender: TObject);
begin
inherited;
FreeAndNIL(FListaTiendas);
inherited;
end;
procedure TfrViewTienda.ElegirTienda(const AIDTienda: Integer);

View File

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

View File

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

View File

@ -21,10 +21,12 @@ type
tbl_PERFILES: TDAMemDataTable;
ds_PERFILES: TDADataSource;
procedure DataModuleCreate(Sender: TObject);
private
procedure InicializarCamposUserControl(AUserControl: TUserControl);
procedure InicializarSettingsUserControl(AUserControl: TUserControl);
function CreateConnectorInstance : TUCDataConnector;
public
function GetUsuario(const ID : Integer) : IBizUsuario;
function NuevoUsuario : IBizUsuario;
@ -35,6 +37,7 @@ type
function GetPerfil (const ID : Integer) : IBizPerfilUsuario;
procedure InicializarUserControl (AUserControl : TUserControl);
procedure DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
end;
@ -72,6 +75,14 @@ begin
Result := GetUsuario(ID_NULO)
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);
begin
inherited;

View File

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

View File

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

View File

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

View File

@ -117,6 +117,47 @@ object srvUsuarios: TsrvUsuarios
DataDictionary = DataDictionary
Diagrams = Diagrams
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
Params = <>
Statements = <
@ -174,14 +215,6 @@ object srvUsuarios: TsrvUsuarios
item
DatasetField = 'CHECKSUM'
TableField = 'CHECKSUM'
end
item
DatasetField = 'ID_EMPLEADO'
TableField = 'ID_EMPLEADO'
end
item
DatasetField = 'ID_TIENDA'
TableField = 'ID_TIENDA'
end>
end>
Name = 'USUARIOS'
@ -253,14 +286,6 @@ object srvUsuarios: TsrvUsuarios
DataType = datString
Size = 250
DictionaryEntry = 'USUARIOS_CHECKSUM'
end
item
Name = 'ID_EMPLEADO'
DataType = datInteger
end
item
Name = 'ID_TIENDA'
DataType = datInteger
end>
end
item

View File

@ -12,7 +12,7 @@ unit srvUsuarios_Impl;
interface
uses
{vcl:} Classes, SysUtils,
{vcl:} Classes, SysUtils,
{RemObjects:} uROXMLIntf, uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
{Required:} uRORemoteDataModule,
{Ancestor Implementation:} DataAbstractService_Impl,
@ -29,16 +29,21 @@ type
procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject;
var aConnectionName: string);
procedure DataAbstractServiceCreate(Sender: TObject);
private
protected
{ IsrvUsuarios methods }
procedure DarIDTiendaVendedorUsuario(const ID_USUARIO: Integer; var AIdTienda: Integer; var ATienda: String);
end;
implementation
{$R *.dfm}
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);
begin
@ -46,6 +51,43 @@ begin
end;
{ 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(
aSender: TObject; var aConnectionName: string);
begin

View File

@ -67,7 +67,6 @@ type
property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent;
property Terminated : Boolean read GetTerminated;
//TEMPORAL
function getVAR_IDTIENDA : Integer;
procedure setVAR_IDTIENDA (AValue : Integer);
function getVAR_TIENDA : String;
@ -82,7 +81,6 @@ type
TAppFactuGES = class(TInterfacedObject, IAppFactuGES)
private
//TEMPORAL
FVAR_IDTIENDA: Integer;
FVAR_TIENDA: String;
@ -121,6 +119,7 @@ type
procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo);
procedure RegisterModule(AModuleInfo : TModuleInfo);
procedure PonerTiendaPorDefecto;
protected
procedure DoMainForm;
@ -128,6 +127,7 @@ type
procedure ShowSplashForm;
procedure HideSplashForm;
procedure UpdateSplashForm;
public
constructor Create; virtual;
@ -154,7 +154,6 @@ type
property DoLoadModulesEvent : TDoLoadModulesEvent read GetLoadModulesEvent write SetLoadModulesEvent;
property Terminated : Boolean read GetTerminated;
//TEMPORAL
function getVAR_IDTIENDA : Integer;
procedure setVAR_IDTIENDA (AValue : Integer);
function getVAR_TIENDA : String;
@ -173,9 +172,7 @@ implementation
uses
Dialogs, uDialogUtils, cxControls, uUsuariosViewRegister,
uEmpresasViewRegister, uEjerciciosController, uAppInfoUtils,
//TEMPORAL
IniFiles;
uEmpresasViewRegister, uEjerciciosController, uAppInfoUtils;
procedure TAppFactuGES.CambiarEjercicio(const AIDEmpresa: Integer);
var
@ -220,20 +217,17 @@ begin
FDoLoadModulesEvent();
end;
//TEMPORAL
procedure TAppFactuGES.PonerTiendaPorDefecto;
var
Fichero : String;
AIdTienda: Integer;
ATienda: String;
begin
Fichero := ExtractFileDir(ParamStr(0))+ '\' + 'FACTUGES.INI';
with TIniFile.Create(Fichero) do
begin
VAR_IDTIENDA := ReadInteger ('VARIABLES', 'IdTienda', 0);
VAR_TIENDA := ReadString ('VARIABLES', 'Tienda', 'Todas');
Free;
end;
//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)
UsuariosController.darIDTiendaVendedorUsuario(UsuarioActivo.ID, AIdTienda, ATienda);
VAR_IDTIENDA := AIdTienda;
VAR_TIENDA := ATienda;
end;
constructor TAppFactuGES.Create;