-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e00b3bc
commit b40fe63
Showing
54 changed files
with
3,622 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mysqlcheck -u root -p --all-databases --check-upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Criar banco de Dados Menu-> Estrutura | ||
create table crt_menu ( | ||
nome varchar(50) primary key, | ||
descricao varchar(150), | ||
nivel int(1) | ||
); | ||
|
||
// | ||
CREATE TABLE ctrl_usuario ( | ||
nome VARCHAR(20) PRIMARY KEY, | ||
senha VARCHAR(20), | ||
nivel integer | ||
); | ||
/// | ||
|
||
|
||
procedure TForm1.incluiDB(cNOME, cDESCRICAO: string; nNIVEL, nINDICE: integer); | ||
var | ||
qrTMP : TZQuery; | ||
begin | ||
// Faz a inclusão/atualizacao dos itens do menu na base. | ||
// Se o nome existir, atualiza a descricao | ||
qrTMP := TZQuery.Create(self); | ||
qrTMP.Connection:=conexao; | ||
qrTMP.sql.Add('INSERT INTO crt_menu (nome, descricao, nivel, indice)'); | ||
qrTMP.sql.Add('VALUES(:cNOME, :cDESCRICAO, :nNIVEL, :nINDICE ) ON'); | ||
qrTMP.sql.Add('DUPLICATE KEY UPDATE descricao = :cDESCRICAO, indice = :nINDICE'); | ||
qrTMP.ParamByName('cNOME').AsString := cNOME ; | ||
qrTMP.ParamByName('cDESCRICAO').AsString := cDESCRICAO ; | ||
qrTMP.ParamByName('nNIVEL').AsInteger := nNIVEL ; | ||
qrTMP.ParamByName('nINDICE').AsInteger := nINDICE ; | ||
try | ||
qrTMP.ExecSQL; | ||
except | ||
on e: Exception do | ||
begin | ||
ShowMessage('Erro L90 '+#13+e.Message+#13+e.ClassName); | ||
end; | ||
end; | ||
FreeAndNil(qrTMP); | ||
end; | ||
|
||
|
||
|
||
procedure TForm1.protegemenu(nNIVEL: integer); | ||
// Carrega o menu inteiro, durante o carregamento | ||
// verifica o nivel do usuario, se o nivel do usuario | ||
// for menor ou igual ao permitido na base de menu, ele exibe ou nao | ||
var | ||
nITEM, nPRINCIPAL : integer; | ||
begin | ||
for nPRINCIPAL := 0 to MainMenu1.Items.Count-1 do | ||
begin | ||
if nNIVEL <= RetornaNIVEL(MainMenu1.Items[nPRINCIPAL].Name) then | ||
MainMenu1.Items[nPRINCIPAL].Enabled :=true | ||
else | ||
MainMenu1.Items[nPRINCIPAL].Enabled :=false; | ||
for nITEM := 0 to MainMenu1.Items[nPRINCIPAL].Count-1 do | ||
begin | ||
if nNIVEL <= RetornaNIVEL(MainMenu1.Items[nPRINCIPAL].Items[nITEM].Name) then | ||
MainMenu1.Items[nPRINCIPAL].Items[nITEM].Enabled:=true | ||
else | ||
MainMenu1.Items[nPRINCIPAL].Items[nITEM].Enabled:=false; | ||
end; | ||
end; | ||
|
||
end; | ||
|
||
function TForm1.RetornaNIVEL(cNOME:string):integer; | ||
// realiza a pesquisa de nivel, se encontrar o nome | ||
// retorna o nivel cadastrado. | ||
var | ||
qrTMP : TZQuery; | ||
nNIVEL : integer; | ||
begin | ||
qrTMP := TZQuery.Create(self); | ||
qrTMP.Connection := conexao; | ||
qrTMP.sql.Add('select * from crt_menu where nome = :cNOME'); | ||
qrTMP.ParamByName('cNOME').AsString:=cNOME; | ||
qrTMP.Open; | ||
if qrTMP.RecordCount > 0 then | ||
nNIVEL := qrTMP.FieldByName('NIVEL').Value | ||
else | ||
nNIVEL := 1; | ||
FreeAndNil(qrTMP); | ||
result := nNIVEL; | ||
end; | ||
|
||
procedure TForm1.CriaDBmenu; | ||
var | ||
nITEM, nPRINCIPAL, nIndice : Integer; | ||
begin | ||
nIndice := 0; | ||
for nPRINCIPAL := 0 to MainMenu1.Items.Count-1 do | ||
begin | ||
incluiDB(MainMenu1.Items[nPRINCIPAL].Name, | ||
MainMenu1.Items[nPRINCIPAL].Caption, | ||
1, | ||
nIndice); | ||
nIndice:= nIndice+1; | ||
for nITEM := 0 to MainMenu1.Items[nPRINCIPAL].Count-1 do | ||
begin | ||
incluiDB(MainMenu1.Items[nPRINCIPAL].Items[nITEM].Name, | ||
' --'+MainMenu1.Items[nPRINCIPAL].Items[nITEM].Caption, | ||
1, | ||
nIndice); | ||
nIndice:= nIndice+1; | ||
end; | ||
end; | ||
end; | ||
|
||
|
||
|
||
|
||
|
||
|
||
procedure TForm1.Button2Click(Sender: TObject); | ||
begin | ||
protegemenu(strtoint(Edit1.text)); | ||
end; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="11"/> | ||
<General> | ||
<SessionStorage Value="InProjectDir"/> | ||
<MainUnit Value="0"/> | ||
<Title Value="project1"/> | ||
<Scaled Value="True"/> | ||
<ResourceType Value="res"/> | ||
<UseXPManifest Value="True"/> | ||
<XPManifest> | ||
<DpiAware Value="True"/> | ||
</XPManifest> | ||
<Icon Value="0"/> | ||
</General> | ||
<BuildModes Count="1"> | ||
<Item1 Name="Default" Default="True"/> | ||
</BuildModes> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
<UseFileFilters Value="True"/> | ||
</PublishOptions> | ||
<RunParams> | ||
<FormatVersion Value="2"/> | ||
<Modes Count="0"/> | ||
</RunParams> | ||
<RequiredPackages Count="4"> | ||
<Item1> | ||
<PackageName Value="rxnew"/> | ||
</Item1> | ||
<Item2> | ||
<PackageName Value="FCL"/> | ||
</Item2> | ||
<Item3> | ||
<PackageName Value="zcomponent"/> | ||
</Item3> | ||
<Item4> | ||
<PackageName Value="LCL"/> | ||
</Item4> | ||
</RequiredPackages> | ||
<Units Count="3"> | ||
<Unit0> | ||
<Filename Value="project1.lpr"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit0> | ||
<Unit1> | ||
<Filename Value="uprincipal.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
<ComponentName Value="frmPrincipal"/> | ||
<HasResources Value="True"/> | ||
<ResourceBaseClass Value="Form"/> | ||
</Unit1> | ||
<Unit2> | ||
<Filename Value="ulogin.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
<ComponentName Value="frmTelalogin"/> | ||
<ResourceBaseClass Value="Form"/> | ||
</Unit2> | ||
</Units> | ||
</ProjectOptions> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<Target> | ||
<Filename Value="project1"/> | ||
</Target> | ||
<SearchPaths> | ||
<IncludeFiles Value="$(ProjOutDir)"/> | ||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
<Linking> | ||
<Options> | ||
<Win32> | ||
<GraphicApplication Value="True"/> | ||
</Win32> | ||
</Options> | ||
</Linking> | ||
</CompilerOptions> | ||
<Debugging> | ||
<Exceptions Count="4"> | ||
<Item1> | ||
<Name Value="EAbort"/> | ||
</Item1> | ||
<Item2> | ||
<Name Value="ECodetoolError"/> | ||
</Item2> | ||
<Item3> | ||
<Name Value="EFOpenError"/> | ||
</Item3> | ||
<Item4> | ||
<Name Value="EOleException"/> | ||
</Item4> | ||
</Exceptions> | ||
</Debugging> | ||
</CONFIG> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
program project1; | ||
|
||
{$mode objfpc}{$H+} | ||
|
||
uses | ||
{$IFDEF UNIX}{$IFDEF UseCThreads} | ||
cthreads, | ||
{$ENDIF}{$ENDIF} | ||
Interfaces, // this includes the LCL widgetset | ||
Forms, zcomponent, uprincipal; | ||
|
||
{$R *.res} | ||
|
||
begin | ||
RequireDerivedFormResource:=True; | ||
Application.Scaled:=True; | ||
Application.Initialize; | ||
Application.CreateForm(TfrmPrincipal, frmPrincipal); | ||
Application.CreateForm(TfrmTelalogin, frmTelalogin); | ||
Application.Run; | ||
end. | ||
|
Oops, something went wrong.