📄 fun.asp
字号:
<%
'文件功能:定义函数
'版权所有:万户网络
'编写人员:房鹏
'编写时间:2003-8-11
'修改人员:
'修改时间:
'修改目的:
%>
<%
function id2employee(empid)
'功能:将ID转为员工名称
dim sql
sql = "select employee_name from wh_employees where employee_id="&empid
dim rs
set rs=conn.execute(sql)
if not rs.eof then
id2employee = rs("employee_name")
else
id2employee = "查无此人"
end if
set rs = nothing
end function
function id2project(projid)
'功能:将ID转为项目名称
dim sql
sql = "select project_name from wh_projects where project_id="&projid
dim rs
set rs=conn.execute(sql)
if not rs.eof then
id2project = rs("project_name")
else
id2project = "无此项目"
end if
set rs = nothing
end function
function id2department(dptid)
'功能:将ID转为部门名称
dim sql
sql = "select dpt_name from wh_departments where dpt_id="&dptid
dim rs
set rs=conn.execute(sql)
if not rs.eof then
id2department = rs("dpt_name")
else
id2department = "查无此部门"
end if
set rs = nothing
end function
function showright(eright)
'功能:显示员工权限
select case(eright)
case 1
showright = "员工"
case 2
showright = "部门经理"
case 3
showright = "财务"
case 4
showright = "总经理"
end select
end function
function listemployee(dptid,empid)
'功能:下拉菜单显示所选部门员工
'参数:dptid 所属部门ID,dpt=0则显示所有员工,dpt=-1则显示技术部、市场部员工;empid 页面带入员工ID参数,若为空则表现为添加记录,不为空则表现为修改记录
dim sql
dim rs
if len(empid)>0 then
empid=int(empid)
end if
select case(dptid)
case 0
sql = " order by dpt_id"
case -1
sql = " where dpt_id = 1 or dpt_id = 2 order by dpt_id,employee_id"
case else
sql = " where dpt_id = "&dptid
end select
sql = "select employee_name,employee_id from wh_employees"&sql
set rs = conn.execute(sql)
do while not rs.eof
response.write("<OPTION VALUE='"&rs("employee_id")&"'")
if rs("employee_id")=empid then
response.write("selected")
end if
response.write(">"&rs("employee_name")&"</OPTION>")
rs.movenext
loop
set rs = nothing
end function
function listproj(projid)
'功能:下拉菜单显示所有项目
'参数:projid 页面带入项目ID参数,若为空则表现为添加记录,不为空则表现为修改记录
dim sql
dim rs
if len(projid)>0 then
projid=int(projid)
end if
sql = "select project_name,project_id from wh_projects"
set rs = conn.execute(sql)
do while not rs.eof
response.write("<OPTION VALUE='"&rs("project_id")&"'")
if rs("project_id")=projid then
response.write("selected")
end if
response.write(">"&rs("project_name")&"</OPTION>")
rs.movenext
loop
set rs = nothing
end function
function listdepartment(dptid)
'功能:下拉菜单显示所有部门
'参数:dptid 页面带入部门ID参数,若为空则表现为添加记录,不为空则表现为修改记录
dim sql
dim rs
if len(dptid)>0 then
dptid=int(dptid)
end if
sql = "select dpt_name,dpt_id from wh_departments"
set rs = conn.execute(sql)
do while not rs.eof
if session("right")=4 or session("right")<=2 and session("dpt")=rs("dpt_id") or session("right")=3 and session("dpt")=rs("dpt_id") then
response.write("<OPTION VALUE='"&rs("dpt_id")&"'")
if rs("dpt_id")=dptid then
response.write("selected")
end if
response.write(">"&rs("dpt_name")&"</OPTION>")
end if
rs.movenext
loop
set rs = nothing
end function
function getdpt(empid)
'功能:得到员工所属部门ID
'参数:empid 员工ID
dim sql
dim rs
sql = "select dpt_id from wh_employees where employee_id="&empid
set rs = conn.execute(sql)
getdpt=rs("dpt_id")
set rs = nothing
end function
function thisdate()
'功能:显示详细时间
dim getdate
const bigweek0 = "日,一,二,三,四,五,六"
dim bigweek
bigweek = split(bigweek0,",")
getdate = now()
thisdate = year(getdate) & "年" & month(getdate) & "月" & day(getdate) & "日 星期" & bigweek(weekday(getdate)-1)
end function
function checklogin()
'功能:检查是否登陆
if session("enter")<>1 then
dim lr
lr=now()&"有IP:"&REQUEST.SERVERVARIABLES("REMOTE_ADDR")&"的用户未登陆试图进入系统"
call savedatalog(now(),"未知","未登陆试图进入系统",REQUEST.SERVERVARIABLES("REMOTE_ADDR"),2)
call savelog("../pub/error.htm",lr)
response.redirect("../error.asp?msg=1")
end if
end function
function exname(FileNamm) '此函数用于取出一个文件名的扩展名
dim filenama,str
filenama=filenamm
filenama=right(filenama,6)
str=instr(filenama,".")
exname=right(filenama,len(filenama)-str)
end function
function ReadText(FileName)
'这是一个用于读出文本文件的函数
dim adf,path
if UCASE(exname(filename))<>"MDB" AND UCASE(exname(filename))<>"SWF" AND UCASE(exname(filename))<>"FLA" AND UCASE(exname(filename))<>"JPG" AND UCASE(exname(filename))<>"GIF" AND UCASE(exname(filename))<>"PSD" AND UCASE(exname(filename))<>"DOC" AND UCASE(exname(filename))<>"WPS" AND UCASE(exname(filename))<>"DLL" THEN
set adf=server.CreateObject("Adodb.Stream")
if instr(filename,":\")<>0 then
path=filename
else
path=server.MapPath(FileName)
end if
with adf
'response.write path
.Type=2
.LineSeparator=13
.Open
.LoadFromFile (path)
.Charset="GB2312"
.Position=2
ReadText=.ReadText
.Cancel()
.Close()
end with
set adF=nothing
end if
end function
sub savelog(filename,lr)
'记录操作及非法日志
dim filr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -