📄 winlogin.pas
字号:
//* 无
//****************************************************************
procedure TWinlogin.Butok_Click(sender: System.Object; e: System.EventArgs);
var
Yuangongjilu:twinYGjilu;
begin
try
if CheckBox1.Checked=true then
begin
//设置控件基础
if item_check()=false then
begin
exit;
end;
//验证,数据查看
if data_get()=true then
begin
Data_Ent();
end;
end
else
begin
if data_getYG()=false then
begin
messagebox.Show('您输入的用户名或密码错误,请重新输入。','登录');
end
else
begin
//员工记录窗体显示
Yuangongjilu:= twinYGjilu.Create;
Yuangongjilu.ShowDialog;
end;
end;
except
on ex:exception do
begin
messagebox.Show('TWinlogin.Butok_Click:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* Butcannel_Click
//*
//* [参数]
//* 1:系统参数
//* 2:系统参数
//* [返回]
//* 无
//****************************************************************
procedure TWinlogin.Butcannel_Click(sender: System.Object; e: System.EventArgs);
begin
try
self.Close;//关闭窗体
except
on ex:exception do
begin
messagebox.Show('TWinlogin.Butcannel_Click:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 窗体项目清空
//*
//* [参数]
//* 无
//* [返回]
//* 无
//****************************************************************
procedure TWinlogin.item_clear;
begin
try
self.Textuser.text:='Admin';
self.Textpass.Text:='Admin';
except
on ex:exception do
begin
messagebox.Show('TWinlogin.item_clear:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 项目Check
//*
//* [参数]
//* 无
//* [返回]
//* 1:输入ERR有无 (True:ERR没有、 False:ERR有)
//****************************************************************
function TWinlogin.item_check(): boolean;
begin
try
//用户名验证
if check_textuser()=false then
begin
self.Textuser.Focus();
exit;
end;
//密码验证
if check_textpass()=false then
begin
self.Textpass.Focus();
exit;
end;
//返回值设定
result:=true;
except
on ex:exception do
begin
result:=false;
messagebox.Show('TWinlogin.item_check:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 项目Check
//*
//* [参数]
//* 无
//* [返回]
//* 1:输入ERR有无 (True:ERR没有、 False:ERR有)
//****************************************************************
function TWinlogin.check_textuser(): boolean;
var
w_textuser:string;
begin
try
w_textuser:=textuser.Text.Trim();
//输入位数的检查
if w_textuser.Length>10 then
begin
messagebox.Show('输入长度超过最大范围','登陆');
result:=false;
exit;
end;
//必须输入且检查
if w_textuser.length=0 then
begin
messagebox.Show('此项目不可为空','登陆');
result:=false;
exit;
end;
//返回值的设定
result:=true;
except
on ex:exception do
begin
result:=false;
messagebox.Show('TWinlogin.check_textuser:('+ex.message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 密码 项目Check
//*
//* [参数]
//* 无
//* [返回]
//* 1:输入ERR有无 (True:ERR没有、 False:ERR有)
//****************************************************************
function TWinlogin.check_textpass(): boolean;
var
w_textpass:string;
begin
try
w_textpass:=textpass.text.Trim;
//输入并且检查
if w_textpass.length>10 then
begin
messagebox.Show('您输入的密码超出范围,请重新输入!','登陆');
result:=false;
exit;
end;
//不可为空
if w_textpass.Length=0 then
begin
messagebox.show('此项不可为空,必须填写完整!','登陆');
result:=false;
exit;
end;
result:=true;
except
on ex:exception do
begin
result:=false;
messagebox.Show('twinlogin.check_textpass:('+ex.Message+')','考勤管理系统');
end;
end;
end;
//****************************************************************
//* 数据查看
//*
//* [参数]
//* 无
//* [返回]
//* 实行状况
//* True:成功
//* False:失败
//****************************************************************
function TWinlogin.data_get(): boolean;
var
w_sql:string;
w_textuser:string;
w_textpass:string;
begin
try
w_textuser:=textuser.Text.Trim;
w_textpass:=textpass.Text.Trim;
//设置鼠标为等待状态
self.Cursor:=cursors.WaitCursor;
w_sql:='';
w_sql:=w_sql+ ' select *';
w_sql:=w_sql+ ' from 用户表';
w_sql:=w_sql+ ' where 用户名='''+w_textuser+'''';
w_sql:=w_sql+ ' and 密码='''+w_textpass+'''';
myds:=dataset.Create;
//执行sql语句并把记录返回
myds:=clsmain.tclass1.create.cmn_ado_select(w_sql);
if myds.Tables[0].Rows.count=0 then
begin
messagebox.Show('用户名和密码不正确!','登陆');
textuser.Focus();
self.Cursor:=cursors.Default;
exit;
end
else
begin
clsmain.quanxian:=clsmain.TClass1.Create.getItemValueS(myds,0,'权限').ToString;
end;
//保存登陆用户名
clsmain.username:=w_textuser;
self.Hide();
self.Cursor:=cursors.Default;
//返回值设定
result:=true;
except
on ex:exception do
begin
result:=false;
messagebox.Show('TWinlogin.data_get:(' + ex.message+')' , '考勤管理系统');
end;
end;
end;
//****************************************************************
//* 数据插入到员工出勤管理中
//*
//* [参数]
//* 无
//* [返回]
//* 实行状况
//* True:成功
//* False:失败
//****************************************************************
function TWinlogin.data_Ent: boolean;
var
w_SQL:string;
time1:string;
begin
try
//设置当前光标为忙等待状态
self.Cursor:=cursors.WaitCursor;
time1:=system.DateTime.Now.toString;
w_SQL :='';
w_SQL := w_SQL + ' SELECT *';
w_SQL := w_SQL + ' FROM 员工出勤表';
// w_SQL := w_SQL + ' WHERE 日期=left('''+time1+''',10)';
w_SQL := w_SQL + ' where left(日期,10)=format(Date(),''yyyy-mm-dd'')';
myds:=dataset.Create;
//执行sql语句并把记录返回
myds:=clsmain.tclass1.create.cmn_ado_select(w_SQL);
if myds.Tables[0].Rows.count=0 then
begin
w_SQL :='';
w_SQL := w_SQL + 'INSERT INTO 员工出勤表(';
w_SQL := w_SQL + '员工编号,';
w_SQL := w_SQL + '姓名,';
w_SQL := w_SQL + '部门名称,';
w_SQL := w_SQL + '日期,';
w_SQL := w_SQL + '上班时间,';
w_SQL := w_SQL + '迟到,';
w_SQL := w_SQL + '下班时间,';
w_SQL := w_SQL + '早退,';
w_SQL := w_SQL + '请假类型,';
w_SQL := w_SQL + '请假总时间,';
w_SQL := w_SQL + '加班总时间,';
w_SQL := w_SQL + '是否出差,';
w_SQL := w_SQL + '备注)';
w_SQL := w_SQL + ' SELECT 员工编号,';
w_SQL := w_SQL + ' 姓名,';
w_SQL := w_SQL + ' 部门名称,';
w_SQL := w_SQL + ' FORMAT(DATE(),''yyyy-mm-dd'') as 日期,';
w_SQL := w_SQL + ' ''00:00'' as 上班时间,';
w_SQL := w_SQL + ' '''' as 迟到,';
w_SQL := w_SQL + ' ''00:00'' as 下班时间,';
w_SQL := w_SQL + ' '''' as 早退,';
w_SQL := w_SQL + ' '''' as 请假类型,';
w_SQL := w_SQL + ' ''00:00'' as 请假总时间,';
w_SQL := w_SQL + ' ''00:00'' as 加班总时间,';
w_SQL := w_SQL + ' '''' as 是否出差,';
w_SQL := w_SQL + ' '''' as 备注';
w_SQL := w_SQL + ' FROM 员工基本信息表';
clsmain.TClass1.Create.begintrans(); //开始事务
clsmain.TClass1.Create.Cmn_Ado_Execute(w_SQL); //执行SQL语句
clsmain.TClass1.Create.Commit(); //提交事务
end;
//设置当前光标为默认状态
self.Cursor := Cursors.Default;
//返回值设定
result:= True;
except
on ex:exception do
begin
result:= false;
messagebox.Show('TWinlogin.data_Ent:(' + ex.message+')' , '考勤管理系统');
end;
end;
end;
//****************************************************************
//* 数据查看 员工登陆时的姓名和密码(员工编号)
//*
//* [参数]
//* 无
//* [返回]
//* 实行状况
//* True:成功
//* False:失败
//****************************************************************
function TWinlogin.data_getYG: boolean;
var
w_sql:string;
w_textuser:string;
w_textpass:string;
begin
try
w_textuser:=textuser.Text.Trim;
w_textpass:=textpass.Text.Trim;
//设置鼠标为等待状态
self.Cursor:=cursors.WaitCursor;
w_sql:='';
w_sql:=w_sql+ ' select *';
w_sql:=w_sql+ ' from 员工基本信息表';
w_sql:=w_sql+ ' where 姓名='''+w_textuser+'''';
w_sql:=w_sql+ ' and 员工编号='''+w_textpass+'''';
myds:=dataset.Create;
//执行sql语句并把记录返回
myds:=clsmain.TClass1.Create.cmn_ado_select(w_sql);
if myds.Tables[0].Rows.count=0 then
begin
messagebox.Show('您输入的用户名和密码不正确!请重新输入。','登陆');
textuser.Focus();
self.Cursor:=cursors.Default;
exit;
end;
//保存员工登陆用户名
clsmain.YGusername:=w_textuser;
//保存员工登陆时的密码=员工编号
clsmain.YGpass:= w_textpass;
//保存员工的所在部门
//clsmain.YGbumen:=clsmain.TClass1.Create.getItemValueS(dgds,0,'部门').ToString;
self.Hide();
self.Cursor:=cursors.Default;
//返回值设定
result:=true;
except
on ex:exception do
begin
result:=false;
messagebox.Show('TWinlogin.data_get:(' + ex.message+')' , '考勤管理系统');
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -