?? function.asp
字號:
<%
'自動獲得唯一編號
'取年月日小時分秒
FUNCTION GetAutoID()
GetAutoID = Right(CStr(Year(Date())),1)&Month(Date())&Day(Date())&hour(Time())&Minute(Time())&Second(Time())
END FUNCTION
'**********************************************************************
'Comment: Replace T-SQL special character
'Input: (must)theString - The String that need to Insert or Update DateBase
' (must)IsGetSql - if need to replace '
'Returns: The String that can use in T-SQL
'Modify: # delete some transform "--, Chr(34)"
' # remove some invalid char
'**********************************************************************
FUNCTION CheckStrInput(theString)
DIM pI
IF IsNull(theString) or isEmpty(theString) THEN
CheckStrInput = ""
Exit FUNCTION
END IF
CheckStrInput = TRIM(theString)
'remove invalid char
FOR pI = 0 TO 31
IF pI<>9 AND pI<>10 AND pI<>13 THEN CheckStrInput = Replace(CheckStrInput,CHR(pI),"")
NEXT
CheckStrInput = Replace(CheckStrInput,"'"," ")
END FUNCTION
'字符加密
FUNCTION encrypt(strsource)
dim intkey,intoffset,i,strback,lngasc,intlength
intkey=119
Randomize
intoffset = Int(101 * Rnd + 100) '設置偏移量
strback = Hex(intoffset) '把偏移量轉換為16進制
If Len(strback) = 1 Then strback = "0" & strback '偏移量為2位,不足的補齊
For i = 1 To Len(strsource)
lngasc = Asc(Mid(strsource, i, 1)) + intoffset
lngasc = lngasc Xor intkey
intlength = Len(Hex(lngasc))
strback = strback & intlength & Hex(lngasc)
Next
encrypt=strback
END FUNCTION
'字符解密
FUNCTION decrypt(strsource)
dim intkey,i,strtemp,intpos,flag,intlength,intnumber,lngasc,strback,intoffset
intkey=119
'取出偏移量
strtemp = " &H" & Left(strsource, 2)
intoffset =clng(strtemp)
intpos = 3
flag = True
For i = 3 To Len(strsource)
If flag = True Then
intlength = cint(Mid(strsource, i, 1))
intnumber = 0
intpos = i + 1
flag = False
Else
intnumber = intnumber + 1
If intnumber = intlength Then
strtemp = " &H" & Trim(Mid(strsource, intpos, intlength))
lngasc = clng(strtemp)
lngasc = lngasc Xor intkey
lngasc = lngasc - intoffset
strback = strback & Chr(lngasc)
flag = True
End If
End If
Next
decrypt=strback
END FUNCTION
''根據id 顯示操作者名稱
Function showoperatorname(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select * from [user] where UserID="&id
rec.open sql_show,conn,3
if not rec.eof then
showoperatorname=rec("Username")
else
showoperatorname=""
end if
set rec=nothing
End Function
''根據id 顯示客戶名稱
Function showclientname(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select * from client where clientid="&id
rec.open sql_show,conn,3
if not rec.eof then
showclientname=rec("clientname")
else
showclientname=""
end if
set rec=nothing
End Function
''根據id顯示部門
Function showsection(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select * from section where sectionid="&id
rec.open sql_show,conn,3
if not rec.eof then
showsection=rec("sectionname")
else
showsection=""
end if
set rec=nothing
End Function
''按照客戶統計金額
Function showsellsum_c(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellmoney) as total_s from sell where sellclientid="&id
rec.open sql_show,conn,3
if not rec.eof then
showsellsum_c=rec("total_s")
else
showsellsum_c=""
end if
set rec=nothing
End Function
'''按照操作者統計金額
Function showsellsum_o(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellmoney) as total_s from sell where sellcreatorid="&id
rec.open sql_show,conn,3
if not rec.eof then
showsellsum_o=rec("total_s")
else
showsellsum_o=""
end if
set rec=nothing
End Function
'''按照產品統計金額
Function showsellsum_p(id)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellmoney) as total_s from sell where sellproduct='"&id&"'"
rec.open sql_show,conn,3
if not rec.eof then
showsellsum_p=rec("total_s")
else
showsellsum_p=""
end if
set rec=nothing
End Function
''按照銷售單統計金額
Function showsellsum_x(id,topic)
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellmoney) as total_x from sell where sellclientid="&id&" and selltopic='"&topic&"'"
rec.open sql_show,conn,3
if not rec.eof then
showsellsum_x=rec("total_x")
else
showsellsum_x=""
end if
set rec=nothing
End Function
''統計總金額
Function showselltotalmoney()
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellmoney) as total_x from sell "
rec.open sql_show,conn,3
if not rec.eof then
showselltotalmoney=rec("total_x")
else
showselltotalmoney=""
end if
set rec=nothing
End Function
''統計總數量
Function showselltotalsum()
dim rec
set rec = server.createobject("adodb.recordset")
sql_show= "select sum(sellproductnum) as total_x from sell"
rec.open sql_show,conn,3
if not rec.eof then
showselltotalsum=rec("total_x")
else
showselltotalsum=""
end if
set rec=nothing
End Function
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -