Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit usenha;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, jpeg, ExtCtrls, Inifiles, _libmysq, DB,
- ZAbstractRODataset, ZAbstractDataset, ZDataset, ZConnection, Grids,
- DBGrids, HashAlg_U, HashAlgMD5_U;
- type
- TFormSenha = class(TForm)
- Panel1: TPanel;
- EdSenha: TEdit;
- Image1: TImage;
- Labsenha: TLabel;
- query_u: TZReadOnlyQuery;
- DataSource1: TDataSource;
- _md5: THashAlgMD5;
- query_uID: TIntegerField;
- query_uNOME: TStringField;
- query_uFUNCAO: TStringField;
- query_uLOGIN: TStringField;
- query_uSENHA: TStringField;
- query_uCONFERE: TIntegerField;
- query_uADM: TIntegerField;
- query_uATIVO: TIntegerField;
- procedure EdSenhaKeyPress(Sender: TObject; var Key: Char);
- procedure checa_senha;
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- public
- usuario_id: integer;
- usuario_nome: string;
- end;
- var
- FormSenha: TFormSenha;
- senha: string;
- _senha : THashArray;
- usuario_excluir, usuario_processamento, usuario_notas, usuario_web, usuario_copiar, usuario_cad_usuario, usuario_cad_lotes: integer;
- implementation
- uses uMain;
- {$R *.dfm}
- procedure TFormSenha.EdSenhaKeyPress(Sender: TObject; var Key: Char);
- begin
- case key of
- #27: begin
- application.terminate;
- close;
- end;
- #13: checa_senha;
- end;
- end;
- procedure TFormSenha.checa_senha;
- var qtos,i:integer;
- begin
- _senha := _md5.HashString(edsenha.text);
- senha := _md5.hashtodisplay(_senha);
- query_u.sql.clear;
- query_u.SQL.add('SELECT * from USUARIOS WHERE senha='+quotedstr(senha));
- query_u.Active := true;
- if query_u.recordcount < 1 then begin
- labsenha.Caption := 'Senha Inválida';
- labsenha.visible := True;
- edsenha.text := '';
- exit;
- end;
- if (not query_u.fieldbyname('ativo').AsInteger = 1) then begin
- labsenha.Caption := 'Esta conta ainda não foi ativada';
- labsenha.visible := True;
- edsenha.text := '';
- exit;
- end;
- FormSenha.Close;
- if query_uid.AsInteger = 0 then Application.Terminate;
- usuario_id := query_uid.AsInteger;
- { SETAR AS OPÇÕES DISPONÍVEIS }
- {
- if (query_u.fieldbyname('adm').AsInteger = 1) then FormMain.caduser.Visible := True else FormMain.caduser.Visible := False;
- if (query_u.fieldbyname('confere').AsInteger = 1) then FormMain.editaindice.Visible := True else FormMain.editaindice.Visible := False;
- if (query_u.fieldbyname('financeiro').AsInteger = 1)then formmain.TabFinanc.Visible := True
- else formmain.TabNF.Visible := False;
- if (query_u.fieldbyname('rh').AsInteger = 1)then formmain.TabContrato.Visible := True
- else formmain.TabContrato.Visible := False;
- }
- formMain.visible := True;
- Application.showmainform := True;
- end;
- procedure TFormSenha.FormCreate(Sender: TObject);
- var
- AppIni: TIniFile;
- _host, _user, _pass, _db, digipath: string;
- tempcd, drivecd, _dbfile, dbfile, _pasta: string;
- begin
- AppIni := TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) );
- { ********* SESSAO MYSQL ***************}
- {
- _dbfile := AppIni.ReadString( 'dat', 'dbfile', ' ');
- _host := AppIni.ReadString( 'dat', 'host', '');
- _user := AppIni.ReadString( 'dat', 'user', 'root');
- _pass := AppIni.ReadString( 'dat', 'pass', '');
- _db := AppIni.ReadString( 'dat', 'db', 'lotes');
- _drive:= StrToInt(AppIni.ReadString( 'configura', 'drive', '0'));
- _pasta:= AppIni.ReadString( 'configura', 'pasta', '\imagens');
- _pastaenvelopes := AppIni.ReadString( 'configura', 'envelopes', '\imagens');
- { ************ FIM SECAO MYSQL **************** }
- { ********* SECAO FIREBIRD ***************}
- digipath := 'c:\temp\diginotas';
- ForceDirectories(digipath);
- tempcd := copy(AppIni.Filename,1,1);
- drivecd := tempcd[1];
- dbfile := AppIni.ReadString( 'dat', 'dbfile', 'milenio.fdb');
- _host := AppIni.ReadString( 'dat', 'host', '');
- _user := AppIni.ReadString( 'dat', 'user', 'SYSDBA');
- _pass := AppIni.ReadString( 'dat', 'pass', 'masterkey');
- _db := AppIni.ReadString( 'dat', 'db', digipath+'\'+dbfile);
- if not FileExists (pchar(digipath+'\'+dbfile)) then begin
- copyfile(pchar(dbfile), pchar(digipath+ '\'+ dbfile), false);
- FileSetAttr(digipath+ '\'+ dbfile, FaArchive);
- end;
- { ************ FIM SECAO FIREBIRD **************** }
- formmain.mysql1.connected := False;
- formmain.mysql1.User := _user;
- formmain.mysql1.Password := _pass;
- formmain.mysql1.HostName := _host;
- formmain.mysql1.Database := _db;
- formmain.mysql1.connect;
- end;
- procedure TFormSenha.FormShow(Sender: TObject);
- begin
- senha:='';
- Labsenha.Visible := False;
- Edsenha.SetFocus;
- end;
- end.
Add Comment
Please, Sign In to add comment