⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucbase.pas

📁 delphi 控件有需要的可以下载看看,可以用的,希望对你用 帮助
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{-----------------------------------------------------------------------------
 Unit Name: UCBase
 Author:    QmD
 changed:      06-dez-2004
 Purpose: Main Unit
 History: included delphi 2005 support
-----------------------------------------------------------------------------}
unit UCBase;

interface

{$IFDEF VER150}
  {$DEFINE UCACTMANAGER}
{$ELSE}
  {$IFDEF VER170}
    {$DEFINE UCACTMANAGER}
  {$ENDIF}
{$ENDIF}

uses
  {$IFDEF VER130}
   Windows,
  {$ELSE}
   Variants, ExtActns, UCMail,
  {$ENDIF}

  {$IFDEF UCACTMANAGER}
  ActnMan, ActnMenus,
  {$ELSE}
  {$ENDIF}
  SysUtils, Classes, Menus, ActnList, UCMessages, Controls,
  UCConsts,  UCXPSet, Graphics, DB, UCDataInfo, Forms;


function Decrypt(const S: AnsiString; Key: Word): AnsiString;
function Encrypt(const S: AnsiString; Key: Word): AnsiString;

{$IFDEF Ver130}
function StrToBool ( Valor : String) : Boolean;
function BoolToStr ( Valor : Boolean) : String;
{$ENDIF}
const
  llLow = 0;
  llDefault = 1;
  llWarning = 2;
  llCritical = 3;
type

  TUserDef = class(TComponent) //classe para armazenar usuario logado = currentuser
    public
     UserID, Profile : Integer;
     Username, LoginName, Password, Email : String;
     Privilegiado : Boolean;
  end;

  TCadastroUsuarios = class(TPersistent) // armazenar menuitem ou action responsavel pelo cadastro de usuarios
    private
      FActCadUsu: TAction;
      FMenuCadUsu: TMenuItem;
      FUsaPriv: Boolean;
      FLockADM: Boolean;
      procedure SetActCadUsu(const Value: TAction);
      procedure SetMenuCadUsu(const Value: TMenuItem);
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property Action : TAction read FActCadUsu write SetActCadUsu;
      property MenuItem : TMenuItem read FMenuCadUsu write SetMenuCadUsu;
      property UsePrivilegedField : Boolean read FUsaPriv write FUsaPriv;
      property ProtectAdmin : Boolean read FLockADM write FLockADM;
  end;

  TPerfilUsuarios = class(TPersistent) // armazenar menuitem ou action responsavel pelo Perfil de usuarios
    private
      FPerfUsuAtive: Boolean;
      FActPerfUsu: TAction;
      FMenuPerfUsu: TMenuItem;
      procedure SetActPerfUsu(const Value: TAction);
      procedure SetMenuPerfUsu(const Value: TMenuItem);
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property Active : Boolean read FPerfUsuAtive write FPerfUsuAtive;
      property Action : TAction read FActPerfUsu write SetActPerfUsu;
      property MenuItem : TMenuItem read FMenuPerfUsu write SetMenuPerfUsu;
  end;

  TTrocarSenha = class(TPersistent) // armazenar menuitem ou action responsavel pelo Form trocar senha
    private
      FForcePass: Boolean;
      FPassLen: Integer;
      FActChgPass: TAction;
      FMenuChgPassUsu: TMenuItem;
      procedure SetActChgPassUsu(const Value: TAction);
      procedure SetMenuChgPassUsu(const Value: TMenuItem);
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property Action : TAction read FActChgPass write SetActChgPassUsu;
      property MenuItem : TMenuItem read FMenuChgPassUsu write SetMenuChgPassUsu;
      property ForcePassword : Boolean read FForcePass write FForcePass;
      property MinPasswordLength  : Integer read FPassLen write FPassLen;
  end;


  TUCAutoLogin = class(TPersistent) // armazenar configuracao de Auto-Logon
    private
      FActive : Boolean;
      FAutoUser, FAutoPassword : String;
      FMessageOnError: Boolean;
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property Active : Boolean read FActive write FActive;
      property User : String read FAutoUser write FAutoUser;
      property Password : String read FAutoPassword write FAutoPassword;
      property MessageOnError : Boolean read FMessageOnError write FMessageOnError;
  end;

  TInitialLogin = class(TPersistent) // armazenar Dados do Login que sera criado na primeira execucao do programa.
    private
      FIniUser: String;
      FIniPass: String;
      FPermIni: TStrings;
      FEmail: String;
      procedure SetFPermIni(const Value: TStrings);
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property User : String read FIniUser write FIniUser;
      property Email : String read FEmail write FEmail;
      property Password : String read FIniPass write FIniPass;
      property InitialRights :  TStrings read FPermIni write SetFPermIni;
    end;
  TGetLoginName = (lnNone, lnUserName, lnMachineName);
  TLogin = class(TPersistent)
    private
      FAutoLogin: TUCAutoLogin;
      FPassNTry: Integer;
      FLoginInicial: TInitialLogin;
    FGetLoginName: TGetLoginName;
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property AutoLogon : TUCAutoLogin read FAutoLogin write FAutoLogin;
      property InitialLogin : TInitialLogin read FLoginInicial write FLoginInicial;
      property MaxLoginAttempts : Integer read FPassNTry write FPassNTry;
      property GetLoginName : TGetLoginName read FGetLoginName write FGetLoginName;
  end;


  TNaoPermitidos = class(TPersistent) // Ocultar e/ou Desabilitar os itens que o usuario nao tem acesso
    private
      FMenuVisible, FActionVisible : Boolean;
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property MenuVisible : Boolean read FMenuVisible write FMenuVisible;
      property ActionVisible : Boolean read FActionVisible write FActionVisible;
  end;

  TLogControl = class(TPersistent) // Responsavel pelo Controle de Log
    private
      FLogActive: Boolean;
      FTableLog: String;
      FMenuLog: TMenuItem;
      FActLog: TAction;
      procedure SetFMenuLog(const Value: TMenuItem);
      procedure SetFActLog(const Value: TAction);
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property Action : TAction read FActLog write SetFActLog;
      property Active : Boolean read FLogActive write FLogActive;
      property TableLog : String read FTableLog write FTableLog;
      property MenuItem : TMenuItem read FMenuLog write SetFMenuLog;
  end;


  TUCControlRight = class(TPersistent) // Menu / ActionList/ActionManager ou ActionMainMenuBar a serem Controlados
    private
      FActionList: TActionList;
      FMainMenu: TMenu;
      {$IFDEF UCACTMANAGER}
      FActionManager: TActionManager;
      FActionMainMenuBar : TActionMainMenuBar;
      {$ENDIF}
      procedure SetActionList(const Value: TActionList);
      procedure SetMainMenu(const Value: TMenu);
      {$IFDEF UCACTMANAGER}
      procedure SetActionManager(const Value: TActionManager);
      procedure  SetActionMainMenuBar(const Value: TActionMainMenuBar);
      {$ENDIF}
    public
      constructor Create(AOwner : TComponent);
      destructor Destroy; override;
      procedure Assign(Source : TPersistent);override;
    published
      property ActionList : TActionList read FActionList write SetActionList;
      property MainMenu : TMenu read FMainMenu write SetMainMenu;
      {$IFDEF UCACTMANAGER}
      property ActionManager : TActionManager read FActionManager write SetActionManager;
      property ActionMainMenuBar : TActionMainMenuBar read FActionMainMenuBar write SetActionMainMenuBar;
      {$ENDIF}

    end;


  TOnLogin = procedure (Sender : TObject; var User, Password : String) of object;
  TOnLoginSucess = procedure (Sender : TObject; IdUser : integer; Usuario, Nome, Senha, Email : String;
                              Privilegiado : Boolean) of object;
  TOnLoginError = procedure (Sender : TObject; Usuario, Senha : String) of object;
  TOnApplyRightsMenuIt = procedure (Sender : TObject; MenuItem : TMenuItem) of object;
  TOnApllyRightsActionIt = procedure (Sender : TObject; Action : TAction) of Object;
  TCustomCadUsuarioForm = procedure (Sender : TObject; var CustomForm : TCustomForm) of Object;
  TCustomPerfilUsuarioForm = procedure (Sender : TObject; var CustomForm : TCustomForm) of Object;
  TCustomLoginForm = procedure (Sender : TObject; var CustomForm : TCustomForm) of Object;
  TCustomTrocarSenhaForm = procedure (Sender : TObject; var CustomForm : TCustomForm) of Object;
  TCustomLogControlForm = procedure (Sender : TObject; var CustomForm : TCustomForm) of Object;
  TCustomInicialMsg = procedure (Sender : TObject; var CustomForm : TCustomForm; var Msg : TStrings) of Object;
  TOnAddUser = procedure (Sender : TObject; var Login, Password, Name, Mail : String; var Profile : Integer; var Privuser : Boolean) of Object;
  TOnChangeUser = procedure (Sender : TObject; IDUser: Integer; var Login, Name, Mail : String; var Profile : Integer; var Privuser : Boolean) of Object;
  TOnDeleteUser = procedure (Sender : TObject; IDUser: Integer; var CanDelete : Boolean; var ErrorMsg : String) of Object;
  TOnAddProfile = procedure (Sender : TObject; var Profile : String) of Object;
  TOnDeleteProfile = procedure (Sender : TObject; IDProfile : Integer; var CanDelete : Boolean; var ErrorMsg : String) of Object;
  TOnChangePassword = procedure (Sender : TObject; IDUser : Integer; Login, CurrentPassword, NewPassword : String) of Object;
  TOnLogoff = procedure (Sender : TObject; IDUser : integer) of Object;

  TUCSettings = class;

  TUCAboutVar=String[10];


  TUCCollection = class;

  TUCRun = class;

  TUCControls = class;

  TUCAppMessage = class;

  TUCLoginMode = (lmActive, lmPassive);

  //data connector
  TUCDataConn = class(TComponent)
  private
  protected
  public
    procedure UCExecSQL(FSQL : String); virtual; abstract;
    function UCGetSQLDataset(FSQL: String): TDataset; dynamic; abstract;
    function UCFindTable(const Tablename : String) : Boolean; virtual; abstract;
    function UCFindDataConnection : Boolean; virtual; abstract;
    function GetDBObjectName : String; virtual; abstract;
    function GetTransObjectName : String; virtual; abstract;
  published

  end;

  TUserControl = class(TComponent) // Classe principal
  private
    FUser : TUserDef;
    FUserSettings : TUserSettings;
    FAplID : String;
    FNaoPermitidos : TNaoPermitidos;
    FOnLogin: TOnLogin;
    FOnStartApp: TNotifyEvent;
    FOnLoginError: TOnLoginError;
    FOnLoginSucess: TOnLoginSucess;
    FOnApplyRightsActionIt: TOnApllyRightsActionIt;
    FOnApplyRightsMenuIt: TOnApplyRightsMenuIt;
    FLogControl: TLogControl;
{$IFDEF VER130}
{$ELSE}
    FMailUserControl: TMailUserControl;
{$ENDIF}
    FEncrytKey: Word;
    FCadUsuarios: TCadastroUsuarios;
    FLogin: TLogin;
    FPerfUsuarios: TPerfilUsuarios;
    FTrocarSenha: TTrocarSenha;
    FUCControlRight: TUCControlRight;
    FOnCustomCadUsuarioForm: TCustomCadUsuarioForm;
    FCustomLogControlForm: TCustomLogControlForm;
    FCustomLoginForm: TCustomLoginForm;
    FCustomPerfilUsuarioForm: TCustomPerfilUsuarioForm;
    FCustomTrocarSenhaForm: TCustomTrocarSenhaForm;
    FOnAddProfile: TOnAddProfile;
    FOnAddUser: TOnAddUser;
    FOnChangePassword: TOnChangePassword;
    FOnChangeUser: TOnChangeUser;
    FOnDeleteProfile: TOnDeleteProfile;
    FOnDeleteUser: TOnDeleteUser;
    FOnLogoff: TOnLogoff;
    FCustomInicialMsg: TCustomInicialMsg;
    FAbout: TUCAboutVar;
    FRightItems: TUCCollection;
    FThUCRun : TUCRun;
    FAutoStart: Boolean;
    FTableRights: TUCTableRights;
    FTableUsers: TUCTableUsers;
    FMode: TUCLoginMode;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -