G
getchar
Unregistered / Unconfirmed
GUEST, unregistred user!
基础类:TBaseForm
......
private
FEmpCode: string; //员工编码
FEmpName: string; //员工姓名
FUserName: string; //登录帐号
FUserPwd: string; //登陆密码
FDptCode: string; //部门编号
FDptName: string; //部门名称
protected
procedure SetEmpCode(EmpCode: string);
procedure SetEmpName(EmpName: string);
procedure SetUserName(UserName: string);
procedure SetUserPwd(UserPwd: string);
procedure SetDptCode(DptCode: string);
procedure SetDptName(DptName: string);
published
property EmpCode:string read FEmpCode write SetEmpCode; //员工编码
property EmpName:string read FEmpName write SetEmpName; //员工姓名
property UserName:string read FUserName write SetUserName; //登录帐号
property UserPwd:string read FUserPwd write SetUserPwd; //登陆密码
property DptCode:string read FDptCode write SetDptCode; //部门编号
property DptName:string read FDptName write SetDptName; //部门名称
var
BaseForm: TBaseForm;
implementation
{$R *.dfm}
procedure TBaseForm.SetEmpCode(EmpCode: string);
begin
Self.FEmpCode := EmpCode;
end;
procedure TBaseForm.SetEmpName(EmpName: string);
begin
Self.FEmpName := EmpName;
end;
procedure TBaseForm.SetUserName(UserName: string);
begin
Self.FUserName := UserName;
end;
procedure TBaseForm.SetUserPwd(UserPwd: string);
begin
Self.FUserPwd := UserPwd;
end;
procedure TBaseForm.SetDptCode(DptCode: string);
begin
Self.FDptCode := DptCode;
end;
procedure TBaseForm.SetDptName(DptName: string);
begin
Self.FDptName := DptName;
end;
TLoginForm从继承TBaseForm继承过来的,在登陆的事件里写如下代码:
正常登陆,但是属性值没写进去。
procedure TLoginForm.btnLoginClick(Sender: TObject);
begin
Qry.Close;
Qry.SQL.Text :=
'select E.emp_code, E.user_name, E.emp_name, E.emp_pwd, '+
'D.dpt_code, D.dpt_name '+
'from tbl_emp_info E '+
'left join tbl_dpt_info D on upper(E.dpt_id)=upper(D.id) '+
'where E.user_name = '''+Trim(edtUser.Text)+''' and '+
'E.emp_pwd = '''+EntryStr(edtPwd.Text)+''' ';
Qry.Prepared;
Qry.Open;
if Qry.RecordCount = 1 then
begin
SetEmpCode(Qry.FieldByName('emp_code').AsString);
SetEmpName(Qry.FieldByName('emp_name').AsString);
SetUserName(Qry.FieldByName('user_name').AsString);
SetUserPwd(Qry.FieldByName('emp_pwd').AsString);
SetDptCode(Qry.FieldByName('dpt_code').AsString);
SetDptName(Qry.FieldByName('dpt_name').AsString);
end;
end;
......
private
FEmpCode: string; //员工编码
FEmpName: string; //员工姓名
FUserName: string; //登录帐号
FUserPwd: string; //登陆密码
FDptCode: string; //部门编号
FDptName: string; //部门名称
protected
procedure SetEmpCode(EmpCode: string);
procedure SetEmpName(EmpName: string);
procedure SetUserName(UserName: string);
procedure SetUserPwd(UserPwd: string);
procedure SetDptCode(DptCode: string);
procedure SetDptName(DptName: string);
published
property EmpCode:string read FEmpCode write SetEmpCode; //员工编码
property EmpName:string read FEmpName write SetEmpName; //员工姓名
property UserName:string read FUserName write SetUserName; //登录帐号
property UserPwd:string read FUserPwd write SetUserPwd; //登陆密码
property DptCode:string read FDptCode write SetDptCode; //部门编号
property DptName:string read FDptName write SetDptName; //部门名称
var
BaseForm: TBaseForm;
implementation
{$R *.dfm}
procedure TBaseForm.SetEmpCode(EmpCode: string);
begin
Self.FEmpCode := EmpCode;
end;
procedure TBaseForm.SetEmpName(EmpName: string);
begin
Self.FEmpName := EmpName;
end;
procedure TBaseForm.SetUserName(UserName: string);
begin
Self.FUserName := UserName;
end;
procedure TBaseForm.SetUserPwd(UserPwd: string);
begin
Self.FUserPwd := UserPwd;
end;
procedure TBaseForm.SetDptCode(DptCode: string);
begin
Self.FDptCode := DptCode;
end;
procedure TBaseForm.SetDptName(DptName: string);
begin
Self.FDptName := DptName;
end;
TLoginForm从继承TBaseForm继承过来的,在登陆的事件里写如下代码:
正常登陆,但是属性值没写进去。
procedure TLoginForm.btnLoginClick(Sender: TObject);
begin
Qry.Close;
Qry.SQL.Text :=
'select E.emp_code, E.user_name, E.emp_name, E.emp_pwd, '+
'D.dpt_code, D.dpt_name '+
'from tbl_emp_info E '+
'left join tbl_dpt_info D on upper(E.dpt_id)=upper(D.id) '+
'where E.user_name = '''+Trim(edtUser.Text)+''' and '+
'E.emp_pwd = '''+EntryStr(edtPwd.Text)+''' ';
Qry.Prepared;
Qry.Open;
if Qry.RecordCount = 1 then
begin
SetEmpCode(Qry.FieldByName('emp_code').AsString);
SetEmpName(Qry.FieldByName('emp_name').AsString);
SetUserName(Qry.FieldByName('user_name').AsString);
SetUserPwd(Qry.FieldByName('emp_pwd').AsString);
SetDptCode(Qry.FieldByName('dpt_code').AsString);
SetDptName(Qry.FieldByName('dpt_name').AsString);
end;
end;