📄 login_pas.pas
字号:
(先取得题目规则表记录,再根据规则定义抽取题目,下载到本地数据库,同时计算出题目分值)}
procedure TLogin_Frm.Down_Subject_Table(Exam_Name:string; var Error_ID:string);
{Error_ID为错误代码,'0000'表示下载成功,'0001'表示不存在该考试名称}
Var
FName:STRING;
begin
If Exam_Kinds='内部考核' Then FName:=Names;{将Names的类型变成String}
Error_ID:='0000';
With Remote_DataModule Do
begin
{------------------------中间件上日志记录-----------------------------------------}
If Exam_Kinds='内部考核' Then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
+',员工名称: '+ FName,Sales_Department,Department, '动作:准备下载试题。。。');
If Exam_Kinds='招聘考试' then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log(
'考生名称: '+ KSMC+', 身份证号:'+SFZH,'招聘考试','', '动作:准备下载试题。。。');
{------------------------中间件上日志记录-----------------------------------------}
//-----------执行远程存储过程,取出特定考试名称的考试规则记录---------------
Exam_SocketConnection.AppServer.Active_Select_Subject_Rule_SP(Exam_Name);
Remote_DataModule.Select_Subject_Rule_Client.Open;
//-----------执行远程存储过程,取出特定考试名称的考试规则记录---------------
//根据考试规则记录,执行远程存储过程取题目,每条规则取一次,并将取到的题目记录在本地数据库
Select_Subject_Rule_Client.First;
IF Select_Subject_Rule_Client.Eof
Then
begin
{------------------------中间件上日志记录-----------------------------------------}
If Exam_Kinds='内部考核' Then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
+',员工名称: '+ FName,Sales_Department,Department, '动作:不存在该考试名称!');
If Exam_Kinds='招聘考试' then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log(
'考生名称: '+ KSMC+', 身份证号:'+SFZH,'招聘考试','', '动作:不存在该考试名称!');
{------------------------中间件上日志记录-----------------------------------------}
Error_ID:='0001'; {'0001'表示规则表为空,考试名称有误}
end
Else
Begin
{------------------------中间件上日志记录-----------------------------------------}
If Exam_Kinds='内部考核' Then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
+',员工名称: '+ FName,Sales_Department,Department, '动作:正在下载考试试题。。。');
If Exam_Kinds='招聘考试' then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log(
'考生名称: '+ KSMC+', 身份证号:'+SFZH,'招聘考试','', '动作:正在下载考试试题。。。');
{------------------------中间件上日志记录-----------------------------------------}
While Not Select_Subject_Rule_Client.Eof do
begin
{------------执行远程过程去激活取题的存储过程---------------}
Exam_SocketConnection.AppServer.Active_Select_Subject_SP
(Select_Subject_Rule_ClientSpeciality.Value,
Select_Subject_Rule_ClientStyle.Value,
Select_Subject_Rule_ClientDifficulty.Value,
Select_Subject_Rule_ClientSelect_Subject_Count.AsString);
{------------执行远程过程去激活取题的存储过程---------------}
{------------将取到的题目存储到本地数据库中去---------------}
Select_Subject_Client.Open;
Select_Subject_Client.First;
While Not Select_Subject_Client.Eof do
begin
With Client_DataModule.Select_Subject_Table_Insert do
begin
Parameters.ParamByName('Subject_ID').Value:=Select_Subject_ClientID.value;
Parameters.ParamByName('Style').Value:=Select_Subject_ClientStyle.value;
Parameters.ParamByName('Difficulty').Value:=Select_Subject_ClientDifficulty.value;
Parameters.ParamByName('Content').Value:=Select_Subject_ClientContent.value;
Parameters.ParamByName('A_option').Value:=Select_Subject_ClientA_option.value;
Parameters.ParamByName('B_option').Value:=Select_Subject_ClientB_option.value;
Parameters.ParamByName('C_option').Value:=Select_Subject_ClientC_option.value;
Parameters.ParamByName('D_option').Value:=Select_Subject_ClientD_option.value;
Parameters.ParamByName('E_option').Value:=Select_Subject_ClientE_option.value;
Parameters.ParamByName('F_option').Value:=Select_Subject_ClientF_option.value;
ExecSQL;
end;
Select_Subject_Client.Next;
end;
Select_Subject_Client.Close;
{------------将取到的题目存储到本地数据库中去---------------}
Select_Subject_Rule_Client.Next;
end;
{------------------------中间件上日志记录-----------------------------------------}
If Exam_Kinds='内部考核' Then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log('用户名:'+Login_Name
+',员工名称: '+ FName,Sales_Department,Department, '动作:试题下载完毕!');
If Exam_Kinds='招聘考试' then
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log(
'考生名称: '+ KSMC+', 身份证号:'+SFZH,'招聘考试','', '动作:试题下载完毕!');
{------------------------中间件上日志记录-----------------------------------------}
End;
//根据考试规则记录,执行远程存储过程取题目,每条规则取一次,并将取到的题目记录在本地数据库
Select_Subject_Rule_Client.Close;
{------调用远程存储过程,取得某类题型某个难度题目的分值表,同时更新本地题库----------}
Exam_SocketConnection.AppServer.Active_Set_Subject_Point_SP(Exam_Name);
With Remote_DataModule do
begin
Set_Subject_Point_Client.Open;
Set_Subject_Point_Client.First;
While Not Set_Subject_Point_Client.Eof do
begin
With Client_DataModule.Select_Subject_Table_Update do
begin
Parameters.ParamByName('style').Value:=Set_Subject_Point_Clientstyle.Value;
Parameters.ParamByName('difficulty').Value:=Set_Subject_Point_Clientdifficulty.Value;
Parameters.ParamByName('Select_Subject_value').Value:=Set_Subject_Point_Clientpoint.Value;
ExecSQL;
end;
Set_Subject_Point_Client.Next;
end;
end;
{------调用远程存储过程,取得某类题型某个难度题目的分值表,同时更新本地题库----------}
//-------------------------打开本地数据库题目表-------------------------------------
With Client_DataModule do
begin
DanXuan_Subject_Table.Close;
DuoXuan_Subject_Table.Close;
PanDuan_Subject_Table.Close;
DanXuan_Subject_Table.Open;
DuoXuan_Subject_Table.Open;
PanDuan_Subject_Table.Open;
end;
//-------------------------打开本地数据库-------------------------------------
end;
end;
procedure TLogin_Frm.SpeedButton1Click(Sender: TObject);
var
Error_ID:string;
begin
If (KSMC_Edit.Text='')or(SFZH_Edit.Text='')
then StatusBar2.Panels[0].Text:='请正确填写姓名和身份证号!'
else
begin
{隐藏登陆界面}
Login_Frm.Visible:=false;
{将考生姓名和身份证号记录起来}
KSMC:=KSMC_Edit.Text;
SFZH:=SFZH_Edit.Text;
Exam_Kinds:='招聘考试';
Exam_Name:=Exam_ComboBox.text;
{------------------------中间件上日志记录-----------------------------------------}
Remote_DataModule.Exam_SocketConnection.AppServer.Action_Log(
'考生名称: '+ KSMC+', 身份证号:'+SFZH,'招聘考试','', '动作:已经登陆!');
{------------------------中间件上日志记录-----------------------------------------}
{---------------------------------记录该次考试持续时间---------------------------}
With Remote_DataModule do
begin
Select_Exam_name_Client.Open;
Select_Exam_name_Client.First;
While Not Select_Exam_name_Client.Eof do
begin
If Select_Exam_name_ClientExam_name.value=Exam_Name then
Exam_Time:=Select_Exam_name_ClientExam_Time.value;
Select_Exam_name_Client.Next;
end;
Select_Exam_name_Client.Close;
end;
{---------------------------------记录该次考试持续时间---------------------------}
{显示下载提示界面}
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:=250;
StatusBar2.Panels[0].Text:='请正确填写考试名称!';
end;
end;
end;
procedure TLogin_Frm.SpeedButton3Click(Sender: TObject);
var
Check:Boolean;
begin
{将登陆名称和密码记录起来}
Login_Name:=Login_Name_Edit.Text;
Login_Psw:=Login_Psw_Edit.Text;
Exam_Kinds:='内部考核';
Exam_Name:=Exam_ComboBox.text;
{---------------------------------记录该次考试持续时间---------------------------}
With Remote_DataModule do
begin
Select_Exam_name_Client.Open;
Select_Exam_name_Client.First;
While Not Select_Exam_name_Client.Eof do
begin
If Select_Exam_name_ClientExam_name.value=Exam_Name then
Exam_Time:=Select_Exam_name_ClientExam_Time.value;
Select_Exam_name_Client.Next;
end;
Select_Exam_name_Client.Close;
end;
{---------------------------------记录该次考试持续时间---------------------------}
{----------------------------------密码验证----------------------------------------------}
Validity_Check(Login_Psw,Check);{检测密码串合法性}
If Check then Login(Login_Name,Names,Sex,Employee_Code,Sales_Department,Department,Purview)
else StatusBar1.Panels[0].Text:='密码串不合法!';
{----------------------------------密码验证----------------------------------------------}
end;
procedure TLogin_Frm.Exam_ComboBoxDropDown(Sender: TObject);
begin
Exam_ComboBox.Items.Clear;
With Remote_DataModule Do
begin
Select_Exam_name_Client.Open;
while Not Select_Exam_name_Client.Eof do
begin
Exam_ComboBox.Items.Add(Select_Exam_name_ClientExam_name.value);
Select_Exam_name_Client.Next;
end;
Select_Exam_name_Client.Close;
{在中间件上记录动作}
Exam_SocketConnection.AppServer.Action_Log('未知用户',
'未知营业部', '未知部门', '动作:取考试名称');
end;
end;
procedure TLogin_Frm.FormShow(Sender: TObject);
var
Server_Ini: TIniFile;
Host_IP:string;
begin
Login_Frm.Height:=130;
{读出INI文件中中间件服务器的IP地址 }
Server_Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Server.ini');
Host_IP:=Server_Ini.ReadString('Server', 'Host_IP',Host_IP);
Server_Ini.Free;
With Flash_Form do
begin
TiShi_Label.Caption:='正在连接数据库。。。';
Show;
{延迟一段很短的时间}
Application.ProcessMessages;
Sleep(10);
end;
{----------------------连接远程数据库和本地数据库-----------------------------}
Try
With Remote_DataModule Do
begin
Exam_SocketConnection.Host:=Host_IP;
Exam_SocketConnection.Connected:=True;
Exam_SocketConnection.AppServer.Action_Log('未知用户',
'未知营业部', '未知部门', '动作:尝试连接成功');
end;
Except
Showmessage('无法连接服务器,请检查您的配置文件!');
close;
end;
Try
With Client_DataModule do
begin
Client_ADOConnection.Connected:=True;
end;
Except
Showmessage('无法连接本地数据库!');
close;
end;
{----------------------连接远程数据库和本地数据库-----------------------------}
Flash_Form.Close;
{------------------------------初始化参数值-----------------------------------}
Names:='';{姓名}
Sex:='';{性别}
ID_card:='';{身份证号}
Employee_Code:='';{员工代码}
Sales_Department:='';{营业部}
Department:='';{部门}
Purview:='';{权限}
Exam_Specialty:='';{考试专业}
{------------------------------初始化参数值-----------------------------------}
end;
procedure TLogin_Frm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Application.Terminate;
//关闭客户端程序之前清空所有试题记录。
Client_DataModule.Select_Subject_Table_Delete.ExecSQL;
end;
procedure TLogin_Frm.SpeedButton2Click(Sender: TObject);
begin
close;
end;
procedure TLogin_Frm.SpeedButton4Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -