📄 cls_wh_employees.asp
字号:
<%
'文件功能:员工信息--数据逻辑(商业层)
'版权所有:万户网络
'编写人员:房鹏
'编写时间:2003-8-12
'修改人员:房鹏
'修改时间:2003-8-13
'修改目的:修改SaveData函数,修正密码存储错误
%>
<%
Class Cls_wh_employees
'********************************************************************************************
function SaveData(pStr_PK_employee_id, pStr_employee_name, pStr_employee_pwd, pStr_employee_type, pStr_employee_edu, pStr_employee_joindate, pStr_employee_birth, pStr_employee_memo, pStr_employee_right, pStr_dpt_id)
'功能:存储详细数据
'参数:详细数据集合
'返回:错误信息或空
dim Str_ID '系统编码
dim Str_Sql 'SQL语句
Str_ID = trim(pStr_PK_employee_id)
if isdate(pStr_employee_joindate) then
pStr_employee_joindate = "'" + FormatDate(pStr_employee_joindate,"yyyy-mm-dd hh:nn:ss") + "'"
else
pStr_employee_joindate = "null"
end if
if isdate(pStr_employee_birth) then
pStr_employee_birth = "'" + FormatDate(pStr_employee_birth,"yyyy-mm-dd hh:nn:ss") + "'"
else
pStr_employee_birth = "null"
end if
if (Str_ID = "") then
Str_Sql = "insert into wh_employees (" _
+ vbCrlf + " employee_name" _
+ vbCrlf + " ,employee_pwd" _
+ vbCrlf + " ,employee_type" _
+ vbCrlf + " ,employee_edu" _
+ vbCrlf + " ,employee_joindate" _
+ vbCrlf + " ,employee_birth" _
+ vbCrlf + " ,employee_memo" _
+ vbCrlf + " ,employee_right" _
+ vbCrlf + " ,dpt_id" _
+ vbCrlf + " )"
Str_Sql = Str_Sql _
+ vbCrlf + " values (" _
+ vbCrlf + " '" + ConvertSql(pStr_employee_name) + "'" _
+ vbCrlf + " ,'" + ConvertSql(pStr_employee_pwd) + "'" _
+ vbCrlf + " ,'" + ConvertSql(pStr_employee_type) + "'" _
+ vbCrlf + " ,'" + ConvertSql(pStr_employee_edu) + "'" _
+ vbCrlf + " , " +(pStr_employee_joindate) + "" _
+ vbCrlf + " , " +(pStr_employee_birth) + "" _
+ vbCrlf + " ,'" + ConvertSql(pStr_employee_memo) + "'" _
+ vbCrlf + " ,'" + ConvertSql(pStr_employee_right) + "'" _
+ vbCrlf + " ,'" + ConvertSql(pStr_dpt_id) + "'" _
+ vbCrlf + " )"
else
if pStr_employee_pwd="8f00b204e9800998" then
Str_Sql = "Update wh_employees Set" _
+ vbCrlf + " employee_name='" + ConvertSql(pStr_employee_name) + "'" _
+ vbCrlf + " ,employee_type='" + ConvertSql(pStr_employee_type) + "'" _
+ vbCrlf + " ,employee_edu='" + ConvertSql(pStr_employee_edu) + "'" _
+ vbCrlf + " ,employee_joindate=" +(pStr_employee_joindate) + "" _
+ vbCrlf + " ,employee_birth=" +(pStr_employee_birth) + "" _
+ vbCrlf + " ,employee_memo='" + ConvertSql(pStr_employee_memo) + "'" _
+ vbCrlf + " ,employee_right='" + ConvertSql(pStr_employee_right) + "'" _
+ vbCrlf + " ,dpt_id='" + ConvertSql(pStr_dpt_id) + "'" _
+ vbCrlf + " Where employee_id='" + ConvertSql(Str_ID) + "'"
else
Str_Sql = "Update wh_employees Set" _
+ vbCrlf + " employee_name='" + ConvertSql(pStr_employee_name) + "'" _
+ vbCrlf + " ,employee_pwd='" + ConvertSql(pStr_employee_pwd) + "'" _
+ vbCrlf + " ,employee_type='" + ConvertSql(pStr_employee_type) + "'" _
+ vbCrlf + " ,employee_edu='" + ConvertSql(pStr_employee_edu) + "'" _
+ vbCrlf + " ,employee_joindate=" +(pStr_employee_joindate) + "" _
+ vbCrlf + " ,employee_birth=" +(pStr_employee_birth) + "" _
+ vbCrlf + " ,employee_memo='" + ConvertSql(pStr_employee_memo) + "'" _
+ vbCrlf + " ,employee_right='" + ConvertSql(pStr_employee_right) + "'" _
+ vbCrlf + " ,dpt_id='" + ConvertSql(pStr_dpt_id) + "'" _
+ vbCrlf + " Where employee_id='" + ConvertSql(Str_ID) + "'"
end if
end if
'response.write str_sql
'response.end
if (not gCls_DbProcess2.ExecuteSQL(Str_Sql)) then
SaveData = GetUpdateErrMSG
else
SaveData = ""
end if
dim lr
if (Str_ID = "") then
lr="<font color=green>"&now()&"</font> <font color=blue>"&session("name")&"</font>添加<font color=blue>员工("&pStr_employee_name&")</font> IP:<font color=red>"&REQUEST.SERVERVARIABLES("REMOTE_ADDR")&"</font>"
call savelogdata(now(),session("name"),"添加员工("&pStr_employee_name&")",REQUEST.SERVERVARIABLES("REMOTE_ADDR"),1)
else
lr="<font color=green>"&now()&"</font> <font color=blue>"&session("name")&"</font>修改<font color=blue>员工("&pStr_employee_name&")</font> IP:<font color=red>"&REQUEST.SERVERVARIABLES("REMOTE_ADDR")&"</font>"
call savelogdata(now(),session("name"),"修改员工("&pStr_employee_name&")",REQUEST.SERVERVARIABLES("REMOTE_ADDR"),1)
end if
call savelog("../pub/log.htm",lr)
end function
'********************************************************************************************
function GetData(pStr_PK_employee_id)
'功能:读取详细数据
'参数:数据系统编码
'返回:详细数据
dim Str_Sql 'SQL语句
dim Rec_Data '结果集
Str_Sql = "select *" _
+ vbCrlf + " from wh_employees" _
+ vbCrlf + " where employee_id = '" + ConvertSql(pStr_PK_employee_id) + "'"
'response.write str_sql
'response.end
call gCls_DbProcess2.RunSQLSearch(Str_Sql,Rec_Data)
set GetData = Rec_Data
end function
'********************************************************************************************
function SearchData(pStr_OrderBy, pStr_employee_name, pStr_employee_pwd, pStr_employee_type, pStr_employee_joindate, pStr_dpt_id)
'功能:查询资料
'参数:查询条件
'返回:查询结果
dim Str_Sql 'SQL语句
dim Rec_Data '结果集
Str_Sql="1=1"
if trim(pStr_employee_name) <> "" then
Str_Sql = Str_Sql + vbCrlf + " and employee_name like '%" + ConvertSql(pStr_employee_name) + "%'"
end if
if trim(pStr_employee_pwd) <> "" then
Str_Sql = Str_Sql + vbCrlf + " and employee_pwd like '%" + ConvertSql(pStr_employee_pwd) + "%'"
end if
if trim(pStr_employee_type) <> "" then
Str_Sql = Str_Sql + vbCrlf + " and employee_type like '%" + ConvertSql(pStr_employee_type) + "%'"
end if
if isdate(pStr_employee_joindate) then
Str_Sql = Str_Sql + vbCrlf + " and datediff(d,employee_joindate,'" + FormatDate(pStr_employee_joindate,"yyyy-mm-dd") + "')=0"
'ACCESS
'Str_Sql = Str_Sql + vbCrlf + " and datediff('d',employee_joindate,'" + FormatDate(pStr_employee_joindate,"yyyy-mm-dd") + "')=0"
end if
if trim(pStr_dpt_id) <> "" then
Str_Sql = Str_Sql + vbCrlf + " and dpt_id like '%" + ConvertSql(pStr_dpt_id) + "%'"
end if
'排序处理
if trim(pStr_OrderBy) = "" then
pStr_OrderBy = "employee_id"
end if
Str_Sql = "select *" _
+ vbCrlf + " from wh_employees" _
+ vbCrlf + " where " + Str_Sql _
+ vbCrlf + " order by " + pStr_OrderBy
'response.write str_sql
'response.end
call gCls_DbProcess2.RunSQLSearch(Str_Sql,Rec_Data)
set SearchData = Rec_Data
end function
'********************************************************************************************
function DeleteData(pStr_PK_employee_id)
'功能:删除资料
'参数:系统编码集合(如 'A01','A02','A03')
'返回:错误信息或空
dim Str_ID '编码集合
dim Str_Sql 'SQL语句
Str_ID = trim(pStr_PK_employee_id)
if (Str_ID = "") then Str_ID ="''"
if IsUsed(Str_ID) then
DeleteData = GetDeleteErrMSG
exit function
end if
Str_Sql = "delete from wh_employees" _
+ vbCrlf + " Where employee_id in (" + Str_ID + ")"
'response.write str_sql
'response.end
if (not gCls_DbProcess2.ExecuteSQL(Str_Sql)) then
DeleteData = GetDeleteErrMSG
else
DeleteData = ""
end if
dim lr
Str_ID=replace(Str_ID,"'","")
lr="<font color=green>"&now()&"</font> <font color=blue>"&session("name")&"</font>删除<font color=blue>员工(员工ID:"&Str_ID&")</font> IP:<font color=red>"&REQUEST.SERVERVARIABLES("REMOTE_ADDR")&"</font>"
call savelog("../pub/log.htm",lr)
call savelogdata(now(),session("name"),"删除员工(员工ID:"&Str_ID&")",REQUEST.SERVERVARIABLES("REMOTE_ADDR"),1)
end function
'********************************************************************************************
function Count()
'功能:查询数据记录总数
'参数:无
'返回:记录总数
dim Rec_Data '结果集
dim Int_Count '记数
dim Str_Sql 'SQL语句
Str_Sql = "select count(*) as allcount" _
+ vbCrlf + " from wh_employees"
'response.write str_sql
'response.end
call gCls_DbProcess2.RunSQLSearch(Str_Sql,Rec_Data)
if (Rec_Data.eof) then
Int_Count = 0
else
Int_Count = Val(Rec_Data.fields("allcount") & "")
end if
Rec_Data.close
Count = Int_Count
end function
'********************************************************************************************
function IsUsed(pStr_PK_employee_id)
'功能:数据是否已开始使用
'参数:系统编码集合
'返回:是否使用
dim Rec_Data '结果集
dim Int_Count '记数
dim Str_Sql 'SQL语句
dim Str_ID
Str_ID = trim(pStr_PK_employee_id) '编码集合
if (Str_ID = "") then Str_ID="''"
'本句需要根据实际情况进行调整
Str_Sql = "select count(*) as allcount" _
+ vbCrlf + " from wh_employees" _
+ vbCrlf + " where 1=2"
'response.write str_sql
'response.end
call gCls_DbProcess2.RunSQLSearch(Str_Sql,Rec_Data)
if (Rec_Data.eof) then
Int_Count = 0
else
Int_Count = Val(Rec_Data.fields("allcount") & "")
end if
Rec_Data.Close
if (Int_Count>0) then
IsUsed = true
else
IsUsed = false
end if
end function
'********************************************************************************************
function IsExist(pStr_PK_employee_id)
'功能:数据是否存在
'参数:系统编码集合
'返回:是否存在
dim Rec_Data '结果集
dim Str_Data
dim Int_Count1 '记数
dim Int_Count '记数
dim Str_Sql 'SQL语句
dim Str_ID
Str_ID = trim(pStr_PK_employee_id) '编码集合
if (Str_ID = "") then Str_ID="''"
'本句需要根据实际情况进行调整
Str_Sql = "select count(*) as allcount" _
+ vbCrlf + " from wh_employees" _
+ vbCrlf + " where employee_id in ("+Str_ID+")"
'response.write str_sql
'response.end
call gCls_DbProcess2.RunSQLSearch(Str_Sql,Rec_Data)
if (Rec_Data.eof) then
Int_Count = 0
else
Int_Count = Val(Rec_Data.fields("allcount") & "")
end if
Rec_Data.Close
Str_Data = split(cstr(Str_ID),",")
Int_Count1 = ubound(Str_Data)+1
if (Int_Count=Int_Count1) then
IsExist = true
else
IsExist = false
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
filr=readtext(filename)
filr=lr&"<br>"&chr(13)&chr(10)&filr
call savetext(filename,filr)
end sub
sub SaveText(FileName,Data)
'这是一个用于写文本文件的过程
dim fs,path,ts
set fs=createobject("scripting.filesystemobject")
if instr(filename,":\")<>0 then
path=filename
else
path=server.MapPath(FileName)
end if
set ts=fs.createtextfile(path,true)
ts.writeline(data)
ts.close
set ts=nothing
set fs=nothing
end sub
function savelogdata(when,who,action,ip,logtype)
sql="insert wh_logs(log_time,log_who,log_action,log_ip,log_type) values('"&when&"','"&who&"','"&action&"','"&ip&"',"&logtype&")"
conn.execute sql
end function
end Class
dim mCls_wh_employees
set mCls_wh_employees = new Cls_wh_employees
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -