📄 unit_admin.pas
字号:
unit Unit_Admin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls, ExtCtrls,DB, DBClient,Data_DL,Grids;
Type
TuserInfo=Record
LoginName,LoginPwd,UserRule,Name,Addr,Idle,Phone:String;
MaxMoney:Real;
Status:integer;
end;
type
TAdmin=class(TObject)
private
Mydata:TDL_Data;
SCds,MCds:TclientDataSet;
Str:string;
public
constructor Create;
destructor Destroy;override;
//获取所有人员登录名称列表
Function AllAdminList:TStrings;
//验证登录人员密码的正确性
Function AdminEnabled(LoginName,LoginPwd:String):Boolean;
//获取登录人员ID
Function AdminID(LoginName,LoginPwd:String):Integer;
//获取指定ID登录人员的真实姓名
Function AdminName(AdminID:Integer):String;
//获取指定ID登录人员的操作权限
Function AdminRule(AdminID:Integer):String;
//获取指定ID登录人员最大签单金额
Function AdminMaxMoney(AdminID:Integer):Currency;
//获取所有人员的信息表
Function AdminInfoList:OLEVariant;
//修改登录时间
Procedure UpdateLoginTime(AdminID:Integer);
//修改密码
Procedure UpdatePwd(Pwd:String;AdminID:Integer);
//检验老密码的正确性;
Function VerifyPwd(OldPwd:String;ADminID:Integer):Boolean;
end;
implementation
{ TAdmin }
function TAdmin.AdminEnabled(LoginName, LoginPwd: String): Boolean;
begin
Result:=False;
Str:='Select * from Admin_info Where (LoginName='''+Trim(LoginName)+''') And (';
Str:=Str+'LoginPwd='''+Trim(LoginPwd)+''')';
Mcds.Data:=MyData.Open_SQL(Str);
If Mcds.RecordCount<>0 Then Result:=True;
end;
function TAdmin.AdminID(LoginName, LoginPwd: String): Integer;
begin
Result:=-1;
Str:='Select * from Admin_info Where (LoginName='''+Trim(LoginName)+''') And (';
Str:=Str+'LoginPwd='''+Trim(LoginPwd)+''')';
Mcds.Data:=MyData.Open_SQL(Str);
If Mcds.RecordCount<>0 Then Result:=Mcds.FieldByName('ID').AsInteger;
end;
function TAdmin.AdminInfoList: OLEVariant;
begin
Str:='Select * From View_AdminInfo Where 状态='''+'可用'+'''';
// Mcds.Data:=MyData.Open_SQL(Str);
Result:=MyData.Open_SQL(Str);
end;
function TAdmin.AdminMaxMoney(AdminID: Integer): Currency;
begin
Result:=-1;
Str:='Select * from Admin_info Where Id='+IntToStr(AdminID)+'';
Mcds.Data:=MyData.Open_SQL(Str);
If Mcds.RecordCount<>0 Then Result:=Mcds.FieldByName('MaxMoney').AsCurrency;
end;
function TAdmin.AdminName(AdminID: Integer): String;
begin
Result:='';
Str:='Select * From Admin_info Where Id='+IntToStr(AdminID)+'';
Mcds.Data:=MyData.Open_SQL(Str);
if Mcds.RecordCount<>0 Then Result:=Mcds.FieldByName('Name').AsString;
end;
function TAdmin.AdminRule(AdminID: Integer): String;
begin
Result:='';
Str:='Select * From Admin_info Where Id='+IntToStr(AdminID)+'';
Mcds.Data:=MyData.Open_SQL(Str);
if Mcds.RecordCount<>0 Then Result:=Mcds.FieldByName('UserRule').AsString;
end;
function TAdmin.AllAdminList: TStrings;
Var
Tmp:TStrings;
begin
Tmp:=TStringList.Create;
Mcds.Data:=Mydata.Open_SQL('Select * from Admin_Info Order By Id');
While Not MCds.Eof Do
Begin
Tmp.Add(Mcds.FieldByName('LoginName').AsString);
Mcds.Next;
End;
Result:=Tmp;
end;
constructor TAdmin.Create;
begin
Mydata:=TDL_Data.Create(nil);
SCds:=TClientDataSet.Create(nil);
Mcds:=TClientDataSet.Create(nil);
end;
destructor TAdmin.Destroy;
begin
FreeAndNil(MYdata);
FreeAndNil(SCds);
FreeAndNil(Mcds);
inherited;
end;
procedure TAdmin.UpdateLoginTime(AdminID: Integer);
Var
TmpJobStatus:Boolean;
begin
Str:='Select jobStatus From Admin_info Where ID='+IntToStr(AdminID);
Mcds.Data:=Mydata.Open_SQL(Str);
TmpJobStatus:=Mcds.FieldByName('jobStatus').AsBoolean;
if TmpJobStatus then
Begin
Str:='Update Admin_info Set loginTime='''+DateTimeToStr(Now)+''',';
Str:=Str+'JobStatus=0 ';
Str:=Str+'Where ID='+IntToStr(AdminID);
// showmessage(Str);
MyData.Exec_SQL(Str);
End;
end;
procedure TAdmin.UpdatePwd(Pwd:String;AdminID: Integer);
begin
Str:='Update Admin_info Set loginpwd='''+Trim(pwd)+''' ';
Str:=Str+'Where ID='+IntToStr(AdminID);
MyData.Exec_SQL(Str);
end;
function TAdmin.VerifyPwd(OldPwd: String;AdminID:Integer): Boolean;
Var
Tmp:String;
begin
Result:=False;
Str:='Select LoginPwd From Admin_info Where ID='+IntToStr(AdminID);
Mcds.Data:=MyData.Open_SQL(Str);
Tmp:=Mcds.FieldByName('LoginPwd').AsString;
If Trim(OldPwd)=Tmp Then
Result:=True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -