📄 ulogin.pas
字号:
unit ULogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UBase, StdCtrls, Buttons, ExtCtrls;
type
TFLogin = class(TFBase)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit_password: TEdit;
ComboBox_KZ: TComboBox;
Login: TSpeedButton;
Logout: TSpeedButton;
Image1: TImage;
Label4: TLabel;
Label_name: TLabel;
Label5: TLabel;
ComboBox_username: TComboBox;
procedure FormCreate(Sender: TObject);
procedure LogoutClick(Sender: TObject);
procedure LoginClick(Sender: TObject);
procedure ComboBox_KZExit(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit_passwordKeyPress(Sender: TObject; var Key: Char);
procedure ComboBox_usernameExit(Sender: TObject);
private
{ Private declarations }
l_count: integer;
public
{ Public declarations }
p_result: boolean;
end;
var
FLogin: TFLogin;
implementation
uses UPublic, UMain;
{$R *.dfm}
procedure TFLogin.FormCreate(Sender: TObject);
begin
inherited;
InitCode('select distinct kz,id from STU_kz order by id',ComboBox_kz.Items);
// ComboBox_KZ.ItemIndex := 0;
l_count := 0;
Label_name.Caption := g_Sys.School;
p_result := False;
end;
procedure TFLogin.LogoutClick(Sender: TObject);
begin
inherited;
Application.Terminate;
end;
procedure TFLogin.LoginClick(Sender: TObject);
begin
inherited;
if ComboBox_KZ.ItemIndex < 0 then begin
ask('科组不能为空,请选择!','提示',MB_INFO);
ComboBox_KZ.SetFocus;
exit;
end;
if ComboBox_username.ItemIndex < 0 then begin
ask('用户名不能为空,请录入!','提示',MB_INFO);
ComboBox_username.SetFocus;
exit;
end;
if trim(Edit_password.Text)='' then begin
ask('密码不能为空,请录入!','提示',MB_INFO);
Edit_password.SetFocus;
exit;
end;
if Edit_password.Text<>g_user.mm then begin
if l_count<2 then
Ask('无效的密码,请重新输入!','错误',MB_OK+MB_STOP)
else begin
Ask('无效的密码,非法操作!','错误',MB_OK+MB_STOP);
Application.Terminate;
end;
Inc(l_count);
Edit_password.SetFocus;
Exit;
end;
g_User.lrsj := now;
g_user.Name := trim(ComboBox_username.Text);
g_User.kz := ComboBox_KZ.Text;
g_User.profile := GetFieldVar('select qx from STU_rrgl where kz='''+g_User.kz+''' and username='''+g_user.Name+'''');
FMain.Caption := FMain.Caption +'-['+g_User.kz+':'+g_user.Name+']';
p_result := True;
close;
end;
procedure TFLogin.ComboBox_KZExit(Sender: TObject);
begin
if trim(ComboBox_KZ.Text)<>'' then
if ComboBox_KZ.ItemIndex < 0 then begin
Ask('无效科组,请重新选择!','错误',MB_OK+MB_STOP);
ComboBox_KZ.SetFocus;
Exit;
end;
InitCode('select username from STU_rrgl where kz='''+ComboBox_KZ.Text+'''', ComboBox_username.Items);
end;
procedure TFLogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
Release;
end;
procedure TFLogin.Edit_passwordKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if key=#13 then Login.Click;
end;
procedure TFLogin.ComboBox_usernameExit(Sender: TObject);
begin
if trim(ComboBox_username.text)='' then exit;
if ComboBox_KZ.ItemIndex < 0 then begin
ask('科组不能为空,请选择!','提示',MB_INFO);
ComboBox_KZ.SetFocus;
exit;
end;
g_User.mm := GetFieldVar('select mm from STU_rrgl where kz='''+ComboBox_KZ.text+''' and username='''+ComboBox_username.Text+'''');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -