📄 cls_function2.1.asp
字号:
<%
'文件功能:公用函数
'文件版本:2.1
%>
<%
' *********************************
' *********************************
' *** ***
' *** 数据转换函数 ***
' *** ***
' *********************************
' *********************************
'****************************************************************************
function AddZero(pStr_Data,pInt_Length)
'功能:资料前加零
'参数:资料,总长度
'返回:加零后的资料
dim Str_Data
Str_Data=trim(Cstr(pStr_Data))
Str_Data=Right(String(pInt_Length,"0")+Str_Data,pInt_Length)
AddZero=Str_Data
end function
'****************************************************************************
function ConvertSql(pStr_Sql)
'功能:替换SQL资料中的引号
'参数:SQL资料
'返回:替换后的资料
ConvertSql=replace(pStr_Sql,"'","''")
end function
'****************************************************************************
function FormatDate(pStr_Date,pStr_Format)
'功能:日期格式转换
'参数:日期,显示格式(yyyy年mm月dd日hh时nn分ss秒
'返回:日期格式
dim Str_Date
dim Str_Year
dim Str_Month
dim Str_Day
dim Str_Hour
dim Str_Minute
dim Str_Second
on error resume next
if not isdate(pStr_Date) then
FormatDate=""
exit function
end if
Str_Year = Year(pStr_Date)
Str_Month = AddZero(Month(pStr_Date),2)
Str_Day = AddZero(Day(pStr_Date),2)
Str_Hour = AddZero(Hour(pStr_Date),2)
Str_Minute = AddZero(Minute(pStr_Date),2)
Str_Second = AddZero(Second(pStr_Date),2)
if trim(pStr_Format)=empty then
Str_Date = "yyyy-mm-dd"
else
Str_Date = lcase(pStr_Format)
end if
Str_Date = replace(Str_Date,"yyyy",Str_Year)
Str_Date = replace(Str_Date,"mm",Str_Month)
Str_Date = replace(Str_Date,"dd",Str_Day)
Str_Date = replace(Str_Date,"hh",Str_Hour)
Str_Date = replace(Str_Date,"nn",Str_Minute)
Str_Date = replace(Str_Date,"ss",Str_Second)
FormatDate = Str_Date
end function
'****************************************************************************
function Val(pStr_Data)
'功能:转换成数值
'参数:原数值
'返回:数值
dim Str_Data
Str_Data = trim(pStr_Data & "")
on error resume next
Val = 0
if IsNumeric(Str_Data) then
Val = cdbl(Str_Data)
end if
end function
'****************************************************************************
' *********************************
' *********************************
' *** ***
' *** 数据判断函数 ***
' *** ***
' *********************************
' *********************************
'****************************************************************************
function IsEmail(pStr_Email)
'功能:判断邮件的有效性
'参数:邮件
'返回:是否
if instr(pStr_Email,"@")>0 and instr(pStr_Email,".")>0 then
IsEmail=true
else
IsEmail=false
end if
end function
'****************************************************************************
' *********************************
' *********************************
' *** ***
' *** 数据读取函数 ***
' *** ***
' *********************************
' *********************************
'****************************************************************************
function GetCountPerPage()
'功能:读取每页显示的记录数
'参数:无
'返回:记录数
GetCountPerPage = gInt_CountPerPage
end function
'****************************************************************************
function GetDeleteErrMSG()
'功能:读取数据删除的错误信息
'参数:无
'返回:数据删除的错误信息
GetDeleteErrMSG = gStr_DeleteErrMSG
end function
'****************************************************************************
function GetFileMaxSize()
'功能:读取文件上传最大字节数
'参数:无
'返回:字节数
GetFileMaxSize = gLog_FileMaxSize
end function
'****************************************************************************
function GetRemoteIP()
'功能:读取远端IP
'参数:无
'返回:远端IP
GetRemoteIP=trim(Request.ServerVariables("REMOTE_ADDR"))
end function
'****************************************************************************
function GetStyleFile()
'功能:读取CSS样式文件名
'参数:无
'返回:无
GetStyleFile = gStr_StyleFile
end function
'****************************************************************************
function GetTableBorder()
'功能:读取表格边框的显示样式
'参数:无
'返回:显示样式
GetTableBorder = gStr_TableBorder
end function
'****************************************************************************
function GetUpdateErrMSG()
'功能:读取数据新增、修改的错误信息
'参数:无
'返回:数据新增、修改的错误信息
GetUpdateErrMSG = gStr_UpdateErrMSG
end function
'****************************************************************************
function GetWebDSN()
'功能:读取数据库联接串
'参数:无
'返回:联接串
GetWebDSN = gStr_WebDSN
end function
'****************************************************************************
' *********************************
' *********************************
' *** ***
' *** 数据显示函数 ***
' *** ***
' *********************************
' *********************************
'****************************************************************************
function ShowPage(pInt_TotalCount,pInt_PerPage,pInt_CurPage,pStr_TableStyle)
'功能:显示页数
'参数:总记录数,每页记录数,当前页,表格显示样式
'返回:无
dim Int_Count
dim Int_PageCount
dim Int_BeginPage
dim Int_EndPage
'计算页数
if (pInt_TotalCount=0 or pInt_PerPage=0) then
Int_PageCount = 1
else
Int_PageCount = round(pInt_TotalCount / pInt_PerPage+0.4999999)
end if
if (Int_PageCount < pInt_CurPage) then pInt_CurPage = 1
'计算开始页和结束页
if (pInt_PerPage=0) then
Int_BeginPage = 1
else
Int_BeginPage = int((pInt_CurPage-1) / 10)*10+1
end if
Int_EndPage = Int_BeginPage+9
if (Int_EndPage>Int_PageCount) then Int_EndPage = Int_PageCount
%>
<TABLE BORDER='0' STYLE="<% = pStr_TableStyle %>">
<TR>
<TD ALIGN=LEFT WIDTH=*>
<% if (pInt_CurPage > 1) then %>
<A HREF='javascript:getpage(<% = (pInt_CurPage-1) %>)' CLASS=PageLink>上一页</A>
<% else %>
上一页
<% end if %>
<% if (Int_BeginPage > 10) then %>
<A HREF='javascript:getpage(<% = (Int_BeginPage-10) %>)' CLASS=PageLink>上十页</A>
<% else %>
上十页
<% end if %>
<% for Int_Count=Int_BeginPage to Int_EndPage %>
<A HREF='javascript:getpage(<% = (Int_Count) %>)' CLASS=PageLink <% if (pInt_CurPage = Int_Count) then response.write " class=PageSelect " %>><% = Int_Count %></A>
<% next %>
<% if (Int_EndPage < Int_PageCount) then %>
<A HREF='javascript:getpage(<% = (Int_BeginPage+10) %>)' CLASS=PageLink>下十页</A>
<% else %>
下十页
<% end if %>
<% if (pInt_CurPage < Int_PageCount) then %>
<A HREF='javascript:getpage(<% = (pInt_CurPage+1) %>)' CLASS=PageLink>下一页</A>
<% else %>
下一页
<% end if %>
</TD>
<TD ALIGN=RIGHT>
直接跳转到第
<SELECT STYLE='WIDTH:50' ONCHANGE='javascript:getpage(this.value)'>
<OPTION VALUE='1' SELECTED>1</OPTION>
<% for Int_Count=2 to Int_PageCount %>
<OPTION VALUE='<% =(Int_Count) %>' <% If (pInt_CurPage = Int_Count) then Response.write " SELECTED" %>><%= (Int_Count)%></OPTION>
<% next %>
</SELECT>页
</TD>
</TR>
<TR>
<TD ALIGN=LEFT COLSPAN=2>
注:符合条件的记录数有 <FONT CLASS="PageCount"><% = pInt_TotalCount %></FONT> 条,
每页显示 <FONT CLASS="PageCount"><% = pInt_PerPage %></FONT> 条记录,
共有 <FONT CLASS="PageCount"><% = Int_PageCount %></FONT> 页,
您现在正查看第 <FONT CLASS="PageCount"><% = pInt_CurPage %></FONT> 页的记录!
</TD>
</TR>
</TABLE>
<%
end function
'****************************************************************************
function ShowOptionList(pInt_ShowBegin,pInt_ValueBegin,pInt_Count,pInt_Value)
'功能:显示下拉框
'参数:显示值开始,实际值开始,显示个数,当前值
'返回:无
dim Int_Count
dim Int_ShowBegin
dim Int_ValueBegin
dim Int_Value
Int_ShowBegin = Val(pInt_ShowBegin)
Int_ValueBegin = Val(pInt_ValueBegin)
Int_Value = Val(pInt_Value)
for Int_Count = 0 to Val(pInt_Count)-1
response.write "<OPTION VALUE='" & (Int_ValueBegin + Int_Count) & "'"
if ((Int_ValueBegin + Int_Count) = Int_Value) then response.write " SELECTED "
response.write ">" & (Int_ShowBegin + Int_Count) & "</OPTION>"+vbCrlf
next
end function
'****************************************************************************
' *********************************
' *********************************
' *** ***
' *** 数据其它函数 ***
' *** ***
' *********************************
' *********************************
'****************************************************************************
function DeleteFile(pStr_FileName)
'功能:删除文件
'参数:文件名称
'返回:错误信息或空
Dim Cls_FileObject
dim Str_FileName
on error resume next
Set Cls_FileObject = Server.CreateObject("Scripting.FileSystemObject")
Str_FileName = Server.MapPath(pStr_FileName)
If (Cls_FileObject.FileExists(Str_FileName)) Then
Cls_FileObject.DeleteFile Str_FileName
End If
if Err then
DeleteFile = Err.description
exit function
end if
end function
'****************************************************************************
function GetUserID
'功能:读取用户系统编码
'参数:无
'返回:系统编码
GetUserID=trim(session("UserID"))
if GetUserID="" then
call ShowMess(16,"对不起,您需要重新登录!")
call WindowFrame("../menu/index.asp","_parent")
end if
'GetUserID="A000000001"
end function
'****************************************************************************
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -