Bueno pues aqui el código pendiente: Habilitar o Deshabilitar las opciones del menú de acuerdo a la configuración almacenada en la tabla SEG_MENU_OPC_CONFIG
Código SQL
[-]
CREATE TABLE SEG_MENU_OPC_CONFIG (
MENU_TIPO_ID NUMERIC(2,0) NOT NULL,
NODO_PADRE INTEGER NOT NULL,
NIVEL INTEGER,
NODO INTEGER NOT NULL,
OPC_VISIBLE VARCHAR(5),
OPC_DESCRIPCION VARCHAR(60),
OPC_TAG INTEGER,
OPC_ABSOLUTE_INDEX INTEGER
);
Dentro del formulario principal:
Código Delphi
[-]procedure TfrmMenu.FormShow(Sender: TObject);
var
s:string;
i:integer;
begin
qryUsuario.close;
qryUsuario.Open;
VerInfoRes:=TVerInfoRes.Create(Application.ExeName);
frmMenu.Caption:='Sistema Control de Inventarios - Menu Principal Ver.'+Copy(VerInfoRes.FileVersion,1,14);
ToolBar1.Width:=frmMenu.Width;
DateTimeToString(s,'dddddd',now);
stBar.Panels[0].Text:=s;
stBar.Panels[1].Text:='Usuario: '+qryUsuario.FieldByName('usu_id').AsString;
stBar.Panels[2].Text:='Rol: '+qryUsuario.FieldByName('rol_id').AsString;
stBar.Panels[3].Text:='Tipo Menu: '+qryUsuario.FieldByName('menu_descrip').AsString;
stBar.Panels[4].Text:=qryUsuario.FieldByName('nombre').AsString;
qryTipoMenu.Close;
qryTipoMenu.Open;
for i:=0 to MainMenu1.Items.Count -1 do
begin
ActivarOPCMenu(MainMenu1.Items[i]);
end;
for i:=0 to ToolBar1.ButtonCount -1 do
begin
qryBotones.Close;
qryBotones.ParamByName('TAG').AsInteger:=ToolBar1.Buttons[i].Tag;
qryBotones.Open;
if qryBotones.FieldByName('OPC_VISIBLE').AsInteger=0 then
ToolBar1.Buttons[i].Enabled:=False
else
ToolBar1.Buttons[i].Enabled:=True;
end;
end;
Aquí el código del Procedimiento "ActivarOPCMenu":
Código Delphi
[-]procedure TfrmMenu.ActivarOPCMenu(V_MENU : TMenuItem);
var
i:integer;
begin
qryTipoMenu.First;
While not(qryTipoMenu.Eof) do
begin
for i:=0 to ComponentCount-1 do
begin
if Components[i] is TMenuItem then
begin
if TMenuItem(Components[i]).Tag = qryTipoMenu.FieldByName('OPC_TAG').AsInteger then
begin
if qryTipoMenu.FieldByName('OPC_VISIBLE').AsInteger=0 then
TMenuItem(Components[i]).Visible:=False
else
TMenuItem(Components[i]).Visible:=True;
end;
end;
end;
qryTipoMenu.Next;
end;
end;
Espero sea de utilidad para los demás compañeros de este club.
Saludos