📄 pubfun.asp
字号:
<%
'**************页面说明****************************
'功能:'系统公共函数代码
'开发者:金寿吉
'首次开发时间:2001-9-4
'最后一次修改时间:
'**********************************************
Function GetUser() '得到当前的用户名
dim username '用户名
dim syspath '系统路径
username=Session("username")
if username="" then
if Application("sysPath")="" then
Application.lock
Application("syspath")="http://"+Request.ServerVariables("LOCAL_ADDR")+"/GojoinCRM"
Application.unlock
end if
syspath=Application("SysPath")
response.redirect(syspath+"/default.asp") '转用户登录界面
response.end
else
GetUser=username
end if
End Function
Function TableCheck(TableName,UserName)
'功能:判断用户对表是否具有审核权,假如返回1则标是有审核权限
dim visitor '表示访问者的权限
dim lcValue '表示值
dim AdoRs
dim lcSql
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_WebPageAdmin where TableName='"+TableName+"'"
visitor=0
AdoRS.Open lcSql,PubConn,1,1
if not AdoRS.eof then
lcValue=AdoRS("checkeds")
if Not ISNULL(lcValue) then
tempa=split(lcValue,",")
for each lcitem in tempa
if lcase(lcitem)=lcase(username) then
visitor=1
exit for
end if
next
end if
end if
TableCheck=visitor '返回用户的审核权
End Function
Function TableVisitor(TableName,UserName)
'功能:判断用户对表的访问权限
'1,2,3分别表示用户具备读者、作者、编辑者
dim visitor '表示访问者的权限
dim syspath '表示系统路径
dim afield(3) '表示数据库中的字段名
dim lcValue '表示值
dim AdoRs
dim lcSql
afield(1)="readers"
afield(2)="author"
afield(3)="editors"
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_WebPageAdmin where TableName='"+TableName+"'"
visitor=0
AdoRS.Open lcSql,PubConn,1,1
if not AdoRS.eof then
for i=3 to 1 step -1
lcValue=AdoRS(afield(i))
if Not ISNULL(lcValue) then
tempa=split(lcValue,",")
for each lcitem in tempa
if lcase(lcitem)=lcase(username) then
visitor=i
exit for
end if
next
end if
if visitor<> 0 then exit for
next
end if
Set Adors=Nothing
'if visitor=0 then
'syspath=Application("SysPath")+"/Novisitor.asp"
'response.write("你没有访问的权限!")
'response.redirect(syspath) '转提示没有权限页面
'response.end
'end if
'visitor=3
TableVisitor=visitor '返回用户的权限级别
End Function
Function GetFieldValue(TableName,SourceField,TargetField,SourceValue)
'功能:得到表的字段值
'TableName:表名 SourceField:关键字段
'TargetField:目标字段 SourceValue:关键字段的值
'函数说明:只能用于关键字段为字符型
dim AdoRs
dim lcSql
dim targetvalue
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from "+TableName+" where "+SourceField+"='"+SourceValue+"'"
AdoRS.Open lcSql,PubConn,1,1
if not AdoRS.eof then
TargetValue=Adors(TargetField)
else
TargetValue=" "
end if
Set Adors=Nothing
GetFieldValue=TargetValue
End Function
Sub DelTableData(TableName,KeyField,KeyValue) '删除表的数据记录
'功能:删除表的记录
'TableName:表名 KeyField:关键字段 KeyValue 关键字段的数值
'注意:关联字段只能是字符型的数据
dim AdoRs,ChildAdoRS 'ChildAdors表示子记录集合
dim lcSql,ChildSql '查询语句和子查询语句
dim ChildTable,ChildField '子表名和子表关联字段
Dim DelTable(100),DelField(100) '连动删除的子表名和字段名
dim DelCount '表示要删除的子表记录
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_TableRelation where ParentTable='"+TableName+"'and ParentField='"+KeyField+"' and DelLimit='1'"
AdoRS.Open lcSql,PubConn,1,1
if not adors.eof then
DelCount=Adors.RecordCount
i=1
Do while not Adors.eof
DelTable(i)=Adors("ChildTable")
DelField(i)=Adors("ChildField")
i=i+1
Adors.Movenext
Loop
else
DelCount=0
end if
set Adors=Nothing
Pubconn.BeginTrans
if DelCount>0 then
For i=1 to DelCount '删除相关的子记录
' ChildSql="delete from "+DelTable(i)+" where "+DelField(i)+"='"+KeyValue+"'"
ChildSql="Update "+DelTable(i)+" set delflag='1' where "+DelField(i)+"='"+KeyValue+"'"
PubConn.execute(ChildSql)
Next
end if
if keyField<>"ID" then
'sql="delete from "+TableName+" where "+KeyField+"='"+KeyValue+"'"
sql="Update "+TableName+" set delflag='1' where "+ keyField +"='"+KeyValue+"'"
else
'sql="delete from "+TableName+" where "+KeyField+"="+KeyValue
sql="Update "+TableName+" set delflag='1' where "+ keyField +"="+KeyValue
end if
PubConn.Execute(sql)
pubConn.CommitTrans '执行结束
End Sub
Sub DelTableData1(TableName,KeyField,KeyValue) '删除表的数据记录
'功能:删除表的记录
'TableName:表名 KeyField:关键字段 KeyValue 关键字段的数值
'注意:关联字段只能是字符型的数据
dim AdoRs,ChildAdoRS 'ChildAdors表示子记录集合
dim lcSql,ChildSql '查询语句和子查询语句
dim ChildTable,ChildField '子表名和子表关联字段
Dim DelTable(100),DelField(100) '连动删除的子表名和字段名
dim DelCount '表示要删除的子表记录
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_TableRelation where ParentTable='"+TableName+"'and ParentField='"+KeyField+"' and DelLimit='1'"
AdoRS.Open lcSql,PubConn,1,1
if not adors.eof then
DelCount=Adors.RecordCount
i=1
Do while not Adors.eof
DelTable(i)=Adors("ChildTable")
DelField(i)=Adors("ChildField")
i=i+1
Adors.Movenext
Loop
else
DelCount=0
end if
set Adors=Nothing
Pubconn.BeginTrans
if DelCount>0 then
For i=1 to DelCount '删除相关的子记录
' ChildSql="delete from "+DelTable(i)+" where "+DelField(i)+"='"+KeyValue+"'"
ChildSql="Update "+DelTable(i)+" set delflag='1' where "+DelField(i)+"='"+KeyValue+"'"
PubConn.execute(ChildSql)
Next
end if
if keyField<>"ID" then
sql="delete from "+TableName+" where "+KeyField+"='"+KeyValue+"'"
'sql="Update "+TableName+" set delflag='1' where "+ keyField +"='"+KeyValue+"'"
else
sql="delete from "+TableName+" where "+KeyField+"="+KeyValue
'sql="Update "+TableName+" set delflag='1' where "+ keyField +"="+KeyValue
end if
PubConn.Execute(sql)
pubConn.CommitTrans '执行结束
End Sub
Function CheckDelTableData(TableName,KeyField,KeyValue) '检查表的数据记录能否删除
'功能:删除表的记录
'TableName:表名 KeyField:关键字段 KeyValue 关键字段的数值
'注意:关联字段只能是字符型的数据
dim AdoRs,ChildAdoRS 'ChildAdors表示子记录集合
dim lcSql,ChildSql '查询语句和子查询语句
dim ChildTable,ChildField '子表名和子表关联字段
Dim DelCount '限制删除的数据
Dim DelFlag '能否删除的标志
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
if KeyField<>"ID" then
lcsql="select * from A_TableRelation where ParentTable='"+TableName+"'and ParentField='"+KeyField+"' and DelLimit='0'"
else
lcsql="select * from A_TableRelation where ParentTable='"+TableName+"'and ParentField="+KeyField+" and DelLimit='0'"
end if
DelCount=0
AdoRS.Open lcSql,PubConn,1,1
if not AdoRS.eof then '有限制的字表
Do while not Adors.eof
ChildTable=Adors("ChildTable")
ChildField=Adors("ChildField")
set ChildAdoRs=Server.CreateObject("AdoDB.RecordSet")
ChildSql="select * from "+ChildTable+" where "+ChildField+"='"+KeyValue+"'"
ChildAdoRS.Open ChildSql,PubConn,1,1
DelCount=DelCount+ChildAdors.RecordCount
Set ChildAdors=Nothing
if DelCount>0 Then Exit Do '发现了限制删除的子记录,退出循环
Adors.Movenext
Loop
end if
Set Adors=Nothing '释放Adors资源
if DelCount>0 then '不能删除表的数据
DelFlag=0
else '可以删除表的数据
DelFlag=1
end if
CheckDelTableData=DelFlag
End Function
Function GetProfile(lcKey)
'功能:得到配置信息的值
dim lcResult
lcResult=""
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select NumValue from A_ConfigInfo Where Subject='"+lcKey+"'"
AdoRS.Open lcSql,PubConn,1,1
if not Adors.eof then
lcResult=Adors("NumValue")
end if
Set Adors=Nothing
GetProfile=lcResult
End Function
Function GetOkNum(TableName,lcField,lcKind)
'功能:得到合适的用户编号
'参数的说明:TableName,表示表名,lcField 表示编号的字段,lcKind表示种类
'其中1--表示为单据类型,编号规则为“时间六位”+“流水号”
'其中0--表示位流水类型,编号规则位“流水号”
dim lcTime,lcYear,lcMonth,lcDay
dim oldnum,newnum '分别表示老的编号和新的编号
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from "+TableName+" order by "+lcField+" Desc"
AdoRS.Open lcSql,PubConn,1,1
if not adors.eof then
oldnum=Adors(lcField)
else
oldnum=""
end if
set AdoRs=Nothing
if lcKind="1" then
'计算年/月/日
lcYear=cstr(Year(now))
lcMonth=Month(now)
if lcMonth<10 then
lcMonth="0"+cstr(lcMonth)
else
lcMonth=cstr(lcMonth)
end if
lcDay=day(now)
if lcDay<10 then
lcDay="0"+cstr(lcDay)
else
lcDay=cstr(lcDay)
end if
lcTime=lcYear+lcMonth+lcDay
if oldnum="" then '当表中没有一个数据时
newnum=lcTime+"0001"
else
'oldtime=left(newnum,6)
oldtime=left(oldnum,8)
if oldtime<>lcTime then '表示新的一天的开始
newnum=lcTime+"0001"
else
'newnum=cstr(ccur(mid(lcTime,7))+1)
'if len(newnum)<4 then
' for i=1 to 4-len(newnum)
' tempnew="0"+tempnew
' next
' newnum=tempnew+newnum
'end if
dd=right(oldnum,6)+1
newnum=oldtime&right(dd,4)
end if
end if
else
if oldnum="" then
oldnum="0"
end if
newnum=oldnum+1
newnum=cstr(newnum)
if len(newnum)<6 then
for i=1 to 6-len(newnum)
tempnew="0"+tempnew
next
newnum=tempnew+newnum '补充额外的空格
end if
end if
GetOkNum=newnum
End Function
Sub DelProduct(keyCode)
Dim firstcode
Dim secondcode
Dim thirdcode
Dim lcSql
Dim AdoRs
firstcode = Mid(keyCode, 1, 2)
secondcode = Mid(keyCode, 3, 2)
thirdcode = Mid(keyCode, 5, 2)
'删除产品的三级编码
lcSql = "delete from A_ProductCode3 where firstcode='" + firstcode + "' and secondcode='" + secondcode + "' and thirdcode='" + thirdcode + "'"
pubConn.Execute (lcSql)
'删除产品的二级编码
lcSql = "select firstcode from A_ProductCode3 where firstcode='" + firstcode + "' and secondcode='" + secondcode + "'"
Set AdoRs = Server.CreateObject("Adodb.RecordSet")
AdoRs.Open lcSql, pubConn, 1, 1
If AdoRs.EOF Then
lcSql = "delete from A_ProductCode2 where firstcode='" + firstcode + "' and secondcode='" + secondcode + "'"
pubConn.Execute (lcSql)
End If
Set AdoRs = Nothing
'删除产品的一级编码
lcSql = "select firstcode from A_ProductCode2 where firstcode='" + firstcode + "'"
Set AdoRs = Server.CreateObject("adodb.RecordSet")
AdoRs.Open lcSql, pubConn, 1, 1
If AdoRs.EOF Then
lcSql = "delete from A_ProductCode1 where firstcode='" + firstcode + "'"
pubConn.Execute (lcSql)
End If
Set AdoRs = Nothing
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -