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

📄 syslogin.pas

📁 企业端数据申报系统:单位管理模块 单位查询. 业务申报模块 在线数据下载 在线数据上传 在线业务申核 申报业务查询 磁盘数据导出 磁盘数据导入 在线业务模块 在线业务
💻 PAS
字号:
//
//模块名称:系统登录窗口
//参数说明:
//
unit syslogin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, TFlatEditUnit, TFlatComboBoxUnit,typinfo,
  TFlatButtonUnit;
const screenwidth=1024;
const screenheight=768;

type
  Tsyslogin_frm = class(TForm)
    Panel1: TPanel;
    Label3: TLabel;
    FlatButton1: TFlatButton;
    FlatButton2: TFlatButton;
    FlatEdit1: TFlatEdit;
    FlatComboBox1: TFlatComboBox;
    Label2: TLabel;
    Image2: TImage;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FlatButton2Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FlatButton1Click(Sender: TObject);
    procedure FlatComboBox1Change(Sender: TObject);
    procedure FlatComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure FlatEdit1KeyPress(Sender: TObject; var Key: Char);
  private
    k:integer;    //登录的次数
  public
    { Public declarations }
  end;


var
  syslogin_frm: Tsyslogin_frm;

implementation

uses datashare, main;

{$R *.dfm}
procedure Tsyslogin_frm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure Tsyslogin_frm.FlatButton2Click(Sender: TObject);
begin
  if loginflag then
    close
  else begin
    if (application.MessageBox('取消登录,将退出系统,继续吗?','恩普软件',MB_OKCancel+MB_Defbutton2+MB_IconQuestion+MB_SystemModal)=IdOk) then
    begin
      hide;
      close;
      main_frm.Close;
    end;
  end;
end;

procedure Tsyslogin_frm.FormActivate(Sender: TObject);
var
  Str:String;
begin
  //将用户添加入用户名称列表
  try
    with datashare_frm.Query1 do
    begin
      close;
      sql.Clear;
      Str:='select OPNAME from USERS where OPSTAT=:para1';
      sql.Add(Str);
      params[0].AsString:='0';
      prepare;
      open;
      while not eof do
      begin
        FlatComboBox1.Items.Add(fieldbyname('OPNAME').AsString);
        next;
      end;
      FlatCombobox1.ItemIndex:=0;
      params.Clear;
      close;
    end;
  except
    on e:exception do
      application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
  end;
end;

procedure Tsyslogin_frm.FormCreate(Sender: TObject);
{var
  i:integer;}
begin
  k:=0;
  FlatComboBox1.Items.Clear;
  {Scaled:=true;
   if screen.Width<>screenwidth then
   begin
     height:=longint(height)*longint(screen.height) div screenwidth;
     width:=longint(width)*longint(screen.width) div screenwidth;
     scaleby(screen.Width,screenwidth);
     for i:=0 to componentcount-1 do
     with components[i] do
     begin
       if GetPropInfo(ClassInfo, 'font') <> nil  then
        font.size := (screen.Width  DIV screenWidth) * font.size;
     end;
   end;}
end;

procedure Tsyslogin_frm.FlatButton1Click(Sender: TObject);
var
  Str:String;
  Rec_num:integer;
  year,month,day:word;
begin
  if FlatCombobox1.Text='' then
  begin
    application.MessageBox('请选择登录的用户名称!','恩普软件',MB_OK+MB_IconInformation+MB_SystemModal);
    FlatCombobox1.SetFocus;
    exit;
  end;
  //用户身份验证
  try
    with datashare_frm.Query1 do
    begin
      close;
      sql.Clear;
      Str:='select operid,opname,opmang,oppass from USERS where OPNAME=:para1 and OPPASS=:para2 and OPSTAT=:para3';
      sql.Add(Str);
      params[0].AsString:=TRIM(FlatCombobox1.Text);
      params[1].AsString:=Flatedit1.Text;
      params[2].AsString:='0';
      prepare;
      open;
      if (fields[0].value=Null) then
      begin
        inc(k);
        if k=3 then
        begin
          application.MessageBox('用户非法,登录异常!','恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
          close;
          main_frm.Close;
        end else
        begin
          application.MessageBox('登录失败!请检验用户名及密码!','恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
          Flatedit1.SetFocus;
          exit;
        end;
      end else      //登录成功
      begin
        loginflag:=true;

        main_frm.user.OPPASS:=trim(Fieldbyname('oppass').AsString);
        main_frm.user.OPERID:=fieldbyname('operid').AsInteger;
        main_frm.user.OPNAME:=fieldbyname('opname').AsString;
        main_frm.user.OPMANG:=fieldbyname('opmang').AsString;
        Decodedate(date(),year,month,day);
        main_frm.StatusBar1.Panels[0].Text:=copy(main_frm.StatusBar1.Panels[0].Text,1,10)+inttostr(year)+'年'+inttostr(month)+'月'+inttostr(day)+'日';
        main_frm.StatusBar1.Panels[1].Text:=copy(main_frm.StatusBar1.Panels[1].Text,1,10)+fieldbyname('opname').AsString;
        main_frm.StatusBar1.panels[3].text:='在线状态:在线';
        syslogin_frm.close;
      end;
    end;
    //main_frm.SetUserFormState;
  except
    on e:exception do
      application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
  end;
end;

procedure Tsyslogin_frm.FlatComboBox1Change(Sender: TObject);
begin
  //当切换用户,登录失败次数置初态
  k:=0;
end;

procedure Tsyslogin_frm.FlatComboBox1KeyPress(Sender: TObject;
  var Key: Char);
begin
  if key=#13 then
    Flatedit1.SetFocus;
end;

procedure Tsyslogin_frm.FlatEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
    FlatButton1Click(self);
end;

end.

⌨️ 快捷键说明

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