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

📄 login_pas.pas

📁 证券公司考试系统,三层架构,从题库自动产生试卷,全部主观题
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit login_pas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg, ComCtrls,IniFiles, Buttons;

type
  TCharacter = 'a'..'z';
  Cell=array[0..35,0..3] of Char;//第一二行前26个字符是字母,后10个字符是数字
  TLogin_Frm = class(TForm)
    Panel1: TPanel;
    No_Password_Panel: TPanel;
    Password_Panel: TPanel;
    StatusBar1: TStatusBar;
    StatusBar2: TStatusBar;
    Bevel1: TBevel;
    Bevel2: TBevel;
    Panel2: TPanel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Panel3: TPanel;
    label1: TLabel;
    SFZH_Edit: TEdit;
    KSMC_Edit: TEdit;
    Label2: TLabel;
    Panel4: TPanel;
    SpeedButton4: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Panel5: TPanel;
    Label7: TLabel;
    Login_Name_Edit: TEdit;
    Label6: TLabel;
    Login_Psw_Edit: TEdit;
    Panel6: TPanel;
    Label5: TLabel;
    Exam_ComboBox: TComboBox;
    Panel7: TPanel;
    ZhaoPin_RadioButton: TRadioButton;
    NeiBu_RadioButton: TRadioButton;
    procedure Down_Subject_Table(Exam_Name:string;var Error_ID:string);
    procedure Validity_Check(var Password:string;Var Check:Boolean);
    procedure Label3Click(Sender: TObject);
    procedure Login(Login_Name:string;var Names,Sex,Employee_Code,Sales_Department,Department,Purview:Variant);
    procedure FormCreate(Sender: TObject);
    procedure MiYao_Biao(MiYao:string;Var Cells:Cell);
    procedure JiaMi(MiYao,MingWen:string;var MiWen:string);
    procedure JieMi(MiYao,MiWen:string;var MingWen:string);
    procedure ZhaoPin_RadioButtonClick(Sender: TObject);
    procedure NeiBu_RadioButtonClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure Exam_ComboBoxDropDown(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
  private
    { Private declarations }
  public

    { Public declarations }
  end;

var
  Login_Frm: TLogin_Frm;
  KSMC,SFZH:STRING;//考生名称和考生身份证号码
  Login_Name,Login_Psw:STRING;//登陆名称和登陆密码
  Exam_Kinds:string;//考试种类(招聘考试或内部考核)
  Exam_Name:string;//考试名称

  Names{姓名}, Sex{性别}, ID_card{身份证号}, Employee_Code{员工代码},
  Sales_Department{营业部}, Department{部门},Purview{权限},
  Exam_Specialty{考试专业}:Variant;{考生成绩录入的各个属性}
  
  Achievement{成绩}:string;

  Begin_Exam_Datetime:string;{开考时间}

  Exam_Time:integer;{考试持续时间}

  MiYao:string='ilovegreatchina';

  Host_IP:string;
implementation

uses Client_Main_Frm, Client_Data_Module, Client_BenDi_DataModule,
  Flash_Frm;



{$R *.dfm}
procedure TLogin_Frm.Validity_Check(var Password:string;Var Check:Boolean);
{密码串的合法性检查,如果有大写字母则转换成小写字母,如果包含数字和字母以外的字符
 则表示该字符串非法}
Var
  i:integer;
begin
  for i := 1 to Length(Password) do
   begin
    if (Ord(Password[i])<=90)and(Ord(Password[i])>=65)
      then Password[i]:= Char(Ord(Password[i])+32);
    if ((Ord(Password[i])>=48)and(Ord(Password[i])<=57))
       or((Ord(Password[i])>=97)and(Ord(Password[i])<=122))
     then Check:=True
     else begin
           Check:=False;
           Break;
          end;
   end;
end;

procedure TLogin_Frm.MiYao_Biao(MiYao:string;Var Cells:Cell);
//根据密钥值生成对应的密钥表,Cells是存放三表的数组
var
  FMiyao: set of TCharacter; //没有重复字符的密钥字符集合,动态变化的
  S:string;  //去除重复字符后的密钥字符集合
  i,j,k:integer;
begin
//------------------------------初始化------------------------------------------
   for i := 0 to 25 do Cells[i, 0] := char(Ord('a') + i );
   for i := 26 to 35 do Cells[i, 0] := char(Ord('0') + i - 26 );
//------------------------------初始化------------------------------------------


//-----------------去掉相同的字母,S是密钥行,不含相同字符-----------------------
  FMiyao := [];
  for i := 1 to Length(MiYao) do
    if not (MiYao[i] in FMiyao) then
    begin
      S := S + MiYao[i];
      FMiyao := FMiyao + [Miyao[i]];
    end;
//-----------------去掉相同的字母,S是密钥行,不含相同字符-----------------------


//-------------------------------第一密文行-------------------------------------

 //字母
 k:=round(Length(s)/2);  //k是取密钥的一半长度
 for i:=1 to k do
  begin
   Cells[i-1,1]:=s[i];
  end;
 for i:=1 to Length(s)-k do
  begin
   Cells[25-(Length(s)-k)+i,1]:= s[k+i];
  end;

  //剩下的字母
  for i := 1 to 26 do
    if not (char(Ord('a') + i - 1) in FMiyao) then
    begin
      FMiyao := FMiyao + [char(Ord('a') + i - 1)];
      Cells[k, 1] := char(Ord('a') + i - 1);
      inc(k);
    end;
  //数字
  for i:= 0 to 9 do Cells[i+26, 1]:=Char(i+48);

//-------------------------------第一密文行-------------------------------------


//------------------------------第二密文行--------------------------------------

  j:=0;
  for i:=35 downto 0 do
   begin
    Cells[j,2]:= Cells[i,1];
    inc(j)
   end;

//------------------------------第二密文行--------------------------------------


//-----------------------------第三密文行---------------------------------------

  for i:=0 to 35 do
   begin
    if i mod 2=0
     then begin
            Cells[i+1,3]:=Cells[i,2];
          end
     else begin
            Cells[i-1,3]:=Cells[i,2]
          end;
   end;


//-----------------------------第三密文行---------------------------------------
end;

procedure TLogin_Frm.JiaMi(MiYao,MingWen:string;var MiWen:string);
//参数分别是:密钥,明文,密文 [三表加密算法]
var
  Cells:Cell;
  i,j:integer;
begin
 MiYao_Biao(MiYao,Cells);
//-------------------------------加密过程---------------------------------------
  MiWen:='';
  for i:=1 to Length(Mingwen) do
   begin
    if i mod 3=1 then
      begin
       for j:=0 to 35 do if Cells[j,0]=Mingwen[i] then break;
       MiWen:=MiWen+ Cells[j,1]
      end;
    if i mod 3=2 then
      begin
       for j:=0 to 35 do if Cells[j,0]=Mingwen[i] then break;
       MiWen:=MiWen+ Cells[j,2]
      end;
    if i mod 3=0 then
      begin
       for j:=0 to 35 do if Cells[j,0]=Mingwen[i] then break;
       MiWen:=MiWen+ Cells[j,3]
      end;
   end;
end;

procedure TLogin_Frm.JieMi(MiYao,MiWen:string;var MingWen:string);
//参数分别是:密钥,密文 ,明文[三表解密算法]
var
  Cells:Cell;
  i,j:integer;
begin
 MiYao_Biao(MiYao,Cells);
//-------------------------------解密过程---------------------------------------
  Mingwen:='';
  for i:=1 to Length(Miwen) do
   begin
    if i mod 3=1 then
      begin
       for j:=0 to 35 do if Cells[j,1]=Miwen[i] then break;
       Mingwen:=Mingwen+ Cells[j,0]
      end;
    if i mod 3=2 then
      begin
       for j:=0 to 35 do if Cells[j,2]=Miwen[i] then break;
       Mingwen:=Mingwen+ Cells[j,0]
      end;
    if i mod 3=0 then
      begin
       for j:=0 to 35 do if Cells[j,3]=Miwen[i] then break;
       Mingwen:=Mingwen+ Cells[j,0]
      end;
   end;
end;

procedure TLogin_Frm.Label3Click(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TLogin_Frm.Login(Login_Name:string;
          var Names,Sex,Employee_Code,Sales_Department,Department,Purview:Variant);
{调用远程接口函数验证登陆用户身份,如果count值为0的话,该用户不存在}
var
  Login_Password{服务器端已经加密过的密码串},Count:Variant;
  Password:string;
  Error_ID:string;
  FName:string;
begin
Try   //尝试连接中间件服务器
  with Remote_DataModule do
   begin
    Exam_SocketConnection.Connected:=True;
    {调用远程过程}
    Exam_SocketConnection.AppServer.Employee_Login
     (Login_Name,Login_Password,Names,Sex,Sales_Department,Department,Purview,Employee_Code,Count);
   end;
 Except
  Showmessage('无法连接中间件服务器!');
  Application.Terminate;
 End;


  JiaMi(MiYao,Login_Psw,Password);
  if Count='0'
   then
    begin

    {------------------------中间件上日志记录-----------------------------------------}
     Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name,
       '未知营业部', '未知部门', '动作:登陆失败!原因:不存在该用户名');
    {------------------------中间件上日志记录-----------------------------------------}

     StatusBar1.Panels[0].Text:='不存在该用户!';
    end
   else
     if Login_Password=Password then
      begin

       {------------------------中间件上日志记录-----------------------------------------}

       FName:=Names; {将Name的类型变成STRING}
       Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
          +',员工名称: '+ FName,Sales_Department,Department, '动作:已经登陆!');

       {------------------------中间件上日志记录-----------------------------------------}

        {密码正确}
        Login_Frm.Visible:=false;{隐藏登陆界面}
        Flash_Form.Show;{显示下载提示界面}
        Flash_Form.TiShi_Label.Caption:='题目下载中,请稍候。。。';
        {延迟一段很短的时间}
        Application.ProcessMessages;
        Sleep(10);
        Down_Subject_Table(Exam_Name,Error_ID); {下载题目}

        If Error_ID='0000' then
         begin
          {关闭下载提示界面}
          Flash_Form.close;
          Main_Frm.Show;{显示主界面}
         end;
        If Error_ID='0001' then  {不存在该考试名称}
         begin
          Login_Frm.Visible:=true;{显示登陆界面}
          Login_Frm.Height:=280;
          StatusBar1.Panels[0].Text:='请正确填写考试名称!';
         end;
      end
     else
      begin

       {------------------------中间件上日志记录-----------------------------------------}

       FName:=Names; {将Name的类型变成STRING}
       Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
          +',员工名称: '+ FName,Sales_Department,Department, '动作:登陆失败, 原因:密码错误');

       {------------------------中间件上日志记录-----------------------------------------}

       StatusBar1.Panels[0].Text:='密码错误!';
      end;
end;


procedure TLogin_Frm.FormCreate(Sender: TObject);
begin
  Login_Frm.Height:=30;
end;

procedure TLogin_Frm.ZhaoPin_RadioButtonClick(Sender: TObject);
begin
 Login_Frm.Height:=250;
 No_Password_Panel.Visible:=TRUE;
 Password_Panel.Visible:=False;

end;

procedure TLogin_Frm.NeiBu_RadioButtonClick(Sender: TObject);
begin
 Login_Frm.Height:=258;
 No_Password_Panel.Visible:=False;
 Password_Panel.Visible:=True;
end;

{抽取下载题目过程

⌨️ 快捷键说明

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