⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library.asp

📁 航空订票系统基于asp.net和sql2005包含数据库和图片
💻 ASP
📖 第 1 页 / 共 2 页
字号:

'===============================================================
'函数名称:日期格式转换
Function FormatDate(vDate,nDateFormat)
  if isdate(vDate) then FormatDate = FormatDateTime(vDate,nDateFormat) else FormatDate = ""
End Function

'===============================================================
'函数:格式化日期(YYYY-MM-DD HH:MI
Function FormatDate16(qDate)
  if isdate(qDate) then 
    FormatDate16 = Year(qDate) & "-" & Right("00" & Month(qDate), 2) & "-" & Right("00" & Day(qDate), 2) & " " & Right("00" & Hour(qDate), 2) & ":" & Right("00" & Minute(qDate), 2)
  else 
    FormatDate16 = " "
  end if
End Function

'===============================================================
'函数:格式化日期为(YYYY-MM-DD HH:MI:SS
Function FormatDate19(qDate)
  if isdate(qDate) then 
    FormatDate19 = Year(qDate) & "-" & Right("00" & Month(qDate), 2) & "-" & Right("00" & Day(qDate), 2) & " " & Right("00" & Hour(qDate), 2) & ":" & Right("00" & Minute(qDate), 2) & ":" & Right("00" & Second(qDate), 2)
  else 
    FormatDate19 = " "
  end if
End Function

'===============================================================
'函数:获取客户端真实IP地址
Function GetClientIP()
  Dim clientIP
  clientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  If clientIP = "" Then clientIP = Request.ServerVariables("REMOTE_ADDR")
  GetClientIP = clientIP
End Function

'===============================================================
'函数名称:产生随机密码(大小写字母+数字)
Function GeneratePassword(nLength)
  Dim strPW, Ran, i
  strPW = ""
  For i = 1 To nLength
    Randomize
    Ran = CInt(Rnd * 2)
    Randomize
    select case Ran
    case 0
      Ran = CInt(Rnd * 25) + 97
      strPW = strPW & UCase(Chr(Ran))
    case 1
      Ran = CInt(Rnd * 9)
      strPW = strPW & Ran
    case 2
      Ran = CInt(Rnd * 25) + 97
      strPW = strPW & Chr(Ran)
    end select
  Next
  GeneratePassword = strPW
End Function


'===============================================================
'函数名称:数值转换成SQL
Function Num2SQL(num)
  if num & "" = "" then
    Num2SQL = "Null"
  else
    Num2SQL = num
  end if
End Function	

'===============================================================
'函数名称:时间转换成SQL 
Function Time2SQL(d)
  if d & "" = "" or not IsDate(d) then
    Time2SQL = "Null"
  else
    Time2SQL = "'" & Year(d) & "-" & Month(d) & "-" & Day(d) & " " & Hour(d) & ":" & Minute(d) & ":" & Second(d) & "'"
  end if
End Function

'===============================================================
'函数名称:空值转换成空格
Function Null2Space(str)
  if str & "" = "" then
    Null2Space = ""
  else
    Null2Space = str
  end if
End Function

'===============================================================
'函数名称:空格转换成空值 
Function Space2Null(str)
  if Trim(str & "") = "" then
    Space2Null = Null
  else
    Space2Null = str
  end if
End Function

'===============================================================
'函数名称:获取字段名称 
Function GetFieldName(fld)
  Dim i
  i = InStr(fld, ".")
  if i = 0 then
    GetFieldName = fld
  else
    GetFieldName = Mid(fld, i + 1)
  end if
End Function

'===============================================================
'函数名称:获取以字段名存储的Dictionary对象
Function GetFieldsDict(sql)
  Dim oRs, oDict
  Set oDict = Server.CreateObject("Scripting.Dictionary")
  Set oRs = oConn_Execute(sql)
  do while not oRs.EOF
    oDict(oRs("id").Value) = oRs("name").Value
    oRs.MoveNext
  loop
  oRs.Close
  Set oRs = Nothing
  Set GetFieldsDict = oDict
  Set oDict = Nothing
End Function

'===============================================================
'函数名称:取得下拉框
'输入参数:输入一个字符串sql,Value得到一个下拉框
'示例:sql="Select id as value,title From StrTable",15
Function GetOptions(sql,Value)
	dim rs,html
	if isnull(Value) then
	  html = "<option value="""" selected>请选择…</option>"
	end if
	set rs = oConn.Execute(sql)
	do while not rs.eof
		html = html & "<option value=""" & rs("id") & """"
		if value = rs("id") then html = html & " selected "
		html = html & ">" & rs("name") & "</option>"
		rs.movenext
	loop
	rs.close
	set rs = nothing
	GetOptions = html
End Function
'===============================================================
'函数名称:取得某下拉列表的下拉框
'输入值lNum(起点),uNum(终点),Value默认值,
Function GetOptionsNum(lNum,uNum,Value)
	dim html,i
	if isnull(Value) then
	  html = "<option value=""-1"" selected>请选择…</option>"
	end if
	for i = lNum to uNum
      html = html & "<option value=""" & i & """"
	  if value = i then html = html & " selected "
	  html = html & ">" & i & "</option>"
	next
	GetOptionsNum = html
End Function
'===============================================================
'函数名称:判断某条记录是否存在
'-------- 函数:  --------
Function ExistRecord(sql)
    dim rs
	set rs = oConn.Execute(sql)
	if rs.eof then
	  ExistRecord = false
	else
	  ExistRecord = true
	end if
	rs.close
	set rs = nothing
End Function

'===============================================================
'函数名称:从左边截取固定长度的字符串
Function LeftString(str,intlen)
	IF IsEmpty(str) then Exit Function
	If len(str)>intlen Then
		LeftString = Left(str,intlen)&".."
	Else
		LeftString = str
	End if
End Function

'===============================================================
'函数名称:返回信息错误提示,返回上一级页面
Sub InfoErrorWrite(info)
	response.Write("<Script language='Javascript'>alert('"+info+"');history.go(-1);</Script>")
	response.End()
End Sub

'===============================================================
'函数名称:返回信息提示包括错误处理和成功提示,返回指定的登陆地址
Sub InfoErrorDisplay(info,url)
	response.Write("<Script language='Javascript'>alert('"+info+"');location.href='"+url+"';</Script>")
	response.End()
End Sub

'===============================================================
'函数名称:字符串特殊字符转换(使能够插入数据库表)
'参    数:
'----------str ---- 待转换的字符串
'返 回 值:转换后的新字符串
function FormatString(str)
	If str&""="" Then Exit Function
	str = replace(str,chr(39),"’")	'单引号
	str = replace(str,chr(34),"“")	'双引号
	str = replace(str,chr(44),",")	'逗号
	'str = replace(str,chr(32) & chr(32),"&nbsp;&nbsp;")	'双空格
	str = replace(str,chr(62),"&gt;")	'大于号
	str = replace(str,chr(60),"&lt;")	'小于号
	'str = replace(str,vbcrlf,"<br>")	'回车
	'...................
	FormatString = str
end function

'===============================================================
'函数名称:将字符串以HTML格式输入
'参    数:
'----------str ---- 待转换的字符串
'返 回 值:转换后的新字符串
Function FormatStringHTML(str)
	If IsEmpty(str) Then Exit Function
	str = replace(str,chr(32),"&nbsp;")	'双空格
	str = replace(str,vbcrlf,"<br>")	'回车换行
	'...................
	FormatStringHTML = str
End Function

'===============================================================
'函数名称:将日期格式化为需要的格式
'参    数:
'----------strDate ---- 待转换的字符串
'返 回 值:转换后的新字符串
function FormatDate(strDate,Date_Type)
	y = year(strDate)
	m = month(strDate)
	d = day(strDate)
	select case Date_Type
		case 1	'yyyy-m-d 格式
			FormatDate = y & "-" & m & "-" & d
		case 2	'yyyy/m/d 格式
			FormatDate = y & "/" & m & "/" & d
		case 3	'm/d/yyyy 格式
			FormatDate = m & "/" & d & "/" & y
		case 4	'年-月-日 格式
			FormatDate = y & "年" & m & "月" & d & "日"
	end select
end function

'===============================================================
'函数名称:判断是否符合规范
'参    数:
'----------Str ---- 被判断字符串
'----------Type ---- 被判断字符串类型,n-数字,s-字符串,d-日期
'返 回 值:无
function IsNot(InputString,StringType)
	'默认输入不合法
	IsNot = false
	'输入为空时不合法
	if Trim(InputString) = "" then exit function
	'合法输入
	select case StringType
		case "n"
			if IsNumeric(InputString) then IsNot = true
		case "d"
			if IsDate(InputString) then IsNot = true
		case "s"
			IsNot = true
		case else
			IsNot = false	'不可知情况视为不合法
	end select
end function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -