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

📄 unpwd.pas

📁 最简单的Delphi班级管理系统
💻 PAS
字号:
unit UnPwd;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons;

type
  Tlogin = class(TForm)
    Label1: TLabel;
    edtusername: TEdit;
    edtpassword: TEdit;
    Label2: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
   // procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
     function init:boolean;
    { Public declarations }
  end;

var
  login: Tlogin;

implementation

uses UnDB, UnStudent;

{$R *.dfm}

function Tlogin.init; //初始化
begin
  init:=false;
  if Application.FindComponent('login')=nil then
     Application.CreateForm(Tlogin,login);
  init:=true;
end;

procedure Tlogin.SpeedButton1Click(Sender: TObject);
var
  {用户名,密码}
  strUserName,strPassWord:string;
begin
  strUserName:=trim(edtusername.Text);
  strPassWord:=trim(edtpassword.Text);
  // 用户输入控制
  if (length(strusername)=0) or (length(strpassword)=0) then
  begin
    //Showmessage('用户名或密码长度不能为空!');
    edtusername.SetFocus;
    exit;
  end;

  with DataModule1 do
  begin
  //打开数据库连接
    if not ADOCN.Connected then
       ADOCN.Open;
       //设置SQL查询
       with ADOQY do
       begin
         close;
         SQL.clear;
         SQL.add('select * from user_Info where user_PWD=:username and user_Des=:password');
         parameters[0].value:=strusername;
         parameters[1].value:=strpassword;
         open;

         //验证用户和密码
         if recordcount<=0 then
         begin
           //showmessage('用户名或密码错误!');
           EdtUserName.SetFocus;
           Exit;
         end
         else
         begin
           //调用主界界面
           if fm_ClassStudent.init then
           fm_ClassStudent.Show;
           login.Hide;
           Exit;
         end;
       end;
   end;
 end;  
procedure Tlogin.SpeedButton2Click(Sender: TObject);
begin
  Application.Terminate;//结束程序,回收所有资源
end;

end.

⌨️ 快捷键说明

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