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

📄 msg_s.asp

📁 物业管理和办公自动化系统
💻 ASP
字号:
<%@ language="VBScript" %>
<% option explicit%>
<!-- #include file="../u_menu.asp" -->
<!-- include file="../u_menu.asp" -->
<!-- #include file="msg_common.inc" -->

<%
'-----------------------------------------------------------
' Filename: msg_l.asp
'-----------------------------------------------------------
sFileName = "msg_s.asp"
CheckSecurity(sFileName)
%>

<%
Dim sEmpId	 : sEmpId = Session("UserID")		' 员工标识
Dim sEmpName : sEmpName = Session("UserName")	' 员工姓名

' 查询内容
Dim sSubject : sSubject	= GetParam("subject")	' 消息主题
Dim sContent : sContent	= GetParam("content")	' 消息内容
Dim sMsgType : sMsgType	= GetParam("msgtype")	' 消息类型
if IsEmpty(sMsgType) then sMsgType = "-1"


Dim sCommand : sCommand = GetParam("command")	' 操作类型search,delete
Dim nPMSerial : nPMSerial = GetParam("pmserial")
Select Case sCommand
Case Empty
	' do nothing
Case "search"
	' do nothing, will do in function MsgList()
Case "delete"
	if Not IsEmpty(nPMSerial) then
		nPMSerial = CInt(nPMSerial)
		sSQL = "select count(*) as counter from T_PersonalMessage" & _
				" where serial = " & nPMSerial & _
				" and Account_id = " & ToSQL(sEmpId, "Text")
		openrs rs, sSQL
		if GetValue(rs, "counter") > 0 then
			' cn.execute "delete from T_PersonalMessage where serial = " & nPMSerial
			' 暂时只把beRead的值加上100,而没有真正删除,以后如果需要,可以作为垃圾进行回收/清除
			cn.execute "update T_PersonalMessage set beRead = (beRead%100 + 100) where serial = " & nPMSerial
		end if
		Set rs = nothing
	end if
End Select
%>


<%

'-----------------------------------------------------------
' 获取满足条件的消息列表
'-----------------------------------------------------------
sub MsgList()
	Dim rs
	Dim sSQL	 : sSQL = ""						' 构造SQL查询语句
	Dim sWhere	 : sWhere = ""
	Dim sOrder	 : sOrder = ""

	Dim iSort	 : iSort = ""						' 排序
	Dim iSorted	 : iSorted = ""
	Dim sDirection	: sDirection = ""

	Dim iTotalRecords	: iTotalRecords = 0			' 分页
	Dim iRecordsPerPage	: iRecordsPerPage = 10
	Dim iTotalPages		: iTotalPages = 0
	Dim iCurrentPage	: iCurrentPage = 1
	Dim iCounter		: iCounter = 0
	Dim iPrevPage, iNextPage
	Dim bEof			: bEof = false

	Dim sFormParams		: sFormParams = ""
	Dim sSortParams		: sSortParams = ""
	
	Dim sTemp

	sFormParams = "subject=" & sSubject & "&content=" & sContent & "&msgtype=" & sMsgType & "&"
	'--------------------------------------
	' Build ORDER BY statement
	'--------------------------------------
	sOrder = " order by pmserial desc"
	iSort = GetParam("Sorting")
	iSorted = GetParam("Sorted")
	if IsEmpty(iSort) then
		iSort = ""
	elseif iSort<>"beread" and iSort<>"msgtype" and iSort<>"subject" and iSort<>"content" and iSort<>"sendtime" then
		iSort = ""
	else
		if iSort = iSorted then	' 这一列是上次排序的列,则将iSorted的值置空""(降序排列),否则置iSort的值(升序排列)
			sDirection = " desc"
			sSortParams = "Sorting=" & iSort & "&Sorted=" & iSorted & "&"
			iSorted = ""
		else
			sDirection = " asc"
			sSortParams = "Sorting=" & iSort & "&Sorted=" & "&"
			iSorted = iSort
		end if
	end if
	if iSort <> "" then
		sOrder = " order by " & iSort & sDirection
	end if

	
	'--------------------------------------
	' Build base SQL statement
	'--------------------------------------
	sSQL = "select T1.serial as pmserial, T1.beRead as beread, T2.serial as mserial, T2.message_type as msgtype, T2.Subject, T2.Content, T2.send_time as sendtime from T_PersonalMessage T1, T_Message T2" & _
		" where T1.message_serial = T2.serial" & _
		" and T1.Account_id = " & ToSQL(sEmpId, "Text") & _
		" and T1.beRead < 10"

	'--------------------------------------
	' Build Where statement
	'--------------------------------------
	sSubject = Trim(sSubject)
	if sSubject = "" then
		sWhere = sWhere & " and ( subject like '%' or subject is null )"
	else
		sWhere = sWhere & " and subject like " & ToSQL("%"&sSubject&"%","Text") 
	end if
	
	sContent = Trim(sContent)
	if sContent = "" then
		sWhere = sWhere & " and ( content like '%' or content is null )"
	else
		sWhere = sWhere & " and content like " & ToSQL("%"&sContent&"%","Text")
	end	if

	Select Case sMsgType
	Case "-1"
		' do nothing
	Case else	' that is, sMstType equals to 0, 1, 3 or 4
		sWhere = sWhere & " and T2.message_type = " & sMsgType
	End Select

	'--------------------------------------
	' Assemble full SQL statement
	'--------------------------------------
	sSQL = sSQL & sWhere & sOrder
		
	'--------------------------------------
	' Write header of the table
	'--------------------------------------
	Response.write "<tr>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600' href='" & sFileName & "?Sorting=beread&Sorted=" & iSorted & "&" & "'>状态</td>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600' href='" & sFileName & "?Sorting=msgtype&Sorted=" & iSorted & "&" & "'>类型</td>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600' href='" & sFileName & "?Sorting=sendtime&Sorted=" & iSorted & "&" & "'>发送时间</td>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600' href='" & sFileName & "?Sorting=subject&Sorted=" & iSorted & "&" & "'>主题</td>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600'>查看</td>"
	Response.write "<td class=tdHead><a style='color:green;font-weight:600'>删除</td>"
	Response.write "</tr>"

	'--------------------------------------
	' Get record count and totalpages
	'--------------------------------------
	iTotalRecords = TotalRecords(sSQL)
	if iTotalRecords = 0 then
		Response.write "<tr><td colspan=4>( 没有任何记录 )</td></tr>"
		exit sub
	end if

	' calculate totalpages
	if iTotalRecords mod iRecordsPerPage = 0 then
		iTotalPages = int(iTotalRecords / iRecordsPerPage)
	else
		iTotalPages = int(iTotalRecords / iRecordsPerPage) + 1
	end if

	' 获取数据
	openrs rs, sSQL 

	iCurrentPage = GetParam("Page")
	if IsEmpty(iCurrentPage) then
		iCurrentPage = 1
	end if
	if Not isNumeric(iCurrentPage) then
		iCurrentPage = 1
	end if
	iCurrentPage = CInt(iCurrentPage)				' 转化成整数再与iTotalPages比较,否则就是比较出来的结果是不正确的
	if iCurrentPage > iTotalPages then
		iCurrentPage = iTotalPages
	end if
	rs.Move (iCurrentPage - 1) * iRecordsPerPage	' 将记录定位到你翻到的页面的第一个记录

	while not rs.EOF and iCounter < iRecordsPerPage
		response.write "<tr>"
		
		' 是否新消息
		if GetValue(rs,"beread") = 0 then
			response.write "<td align=center><img border=0 src='../images/msgnew.gif'>&nbsp;</td>"
		else
			response.write "<td align=center><img border=0 src='../images/msgread.gif'>&nbsp;</td>"
		end if
		
		' 消息类型
		sTemp = GetValue(rs, "msgtype")
		Select Case sTemp
		Case conMsgBulletin
			response.write "<td align=center>公告</td>"
		Case conMsgCommon		
			response.write "<td align=center>普通</td>"
		Case conMsgTaskRemind
			response.write "<td align=center>提醒</td>"
		Case conMsgRMRemind
			response.write "<td align=center>例会</td>"
		Case else
			response.write "<td align=center>&nbsp;</td>"
		End Select

		' 消息发送时间
		sTemp = GetValue(rs, "sendtime")
		if sTemp <> "" then sTemp=FormatDateTime(sTemp,vbShortDate) & "&nbsp;" & FormatDateTime(sTemp,vbShortTime)
		response.write "<td align=center>&nbsp;" & sTemp & "</td>"

		' 消息主题
		response.write "<td align=center>&nbsp;" & GetValue(rs, "subject") & "</td>"
		
		' 查看和删除
		response.write "<td align=center><a target=_new href='u_messageinfo.asp?pmserial=" & GetValue(rs, "pmserial") & "'><img border=0 src='../images/property.gif'></a></td>"
		'response.write "<td align=center><a OnClick=""JavaScript:deleteMessage(" &GetValue(rs, "pmserial"& ")"" href='msg_s.asp?command=delete&pmserial=" & GetValue(rs, "pmserial") & "'><img border=0 src='../images/delete.gif'></a></td>"
		response.write "<td align=center><a OnClick='VBScript:call deleteMessage(" & GetValue(rs, "pmserial") & ",""" & GetValue(rs, "subject") & """)'><img border=0 src='../images/delete.gif'></a></td>"
		response.write "</tr>"
		iCounter = iCounter + 1
		rs.movenext
	wEnd
	' 首页、前页、后页、尾页链接

	bEof = rs.eof
	Response.write "<tr><td colspan=6 align=right>"
	call WritePageInfor(bEof, sFileName, sFormParams, sSortParams, iCurrentPage, iTotalPages)
	Response.write "&nbsp;</td></tr>"

	rs.close
	Set rs = Nothing
end sub
%>

<html>
<head><title></title>
<style type="text/css">
<!-- @import url(../common.css); -->
</style>
</head>

<script language="VBScript">
Sub OnPageLoad()
	formSearch.msgtype.value = "<%=sMsgType%>"
End Sub
function deleteMessage(msgid, b)
	dim bDelete : bDelete = window.confirm("真的要删除消息[" + msgSubject + "]?")
	if ( bDelete = true ) then
		formSearch.pmserial.value = msgid
		formSearch.command.value = "delete"
		formSearch.submit()
	end if
End function
</script>

<body OnLoad="VBScript:OnPageLoad()">

<p align=center>
<span class="pageTitle">消 息 查 询</span>
<form method=post name="formSearch" action="msg_s.asp">
消息类型:	<select name="msgtype" style="width:80px;color:black">
		<option value="-1"> 全 部</option>
		<option value="0"> 公 告</option>
		<option value="1"> 普 通</option>
		<option value="3"> 提 醒</option>
		<option value="4"> 例 会</option></select>&nbsp;&nbsp;&nbsp;&nbsp;
主题中包含:<input type="text" name="subject" value="<%=sSubject%>" size="10" class=RimInput>&nbsp;&nbsp;&nbsp;&nbsp;
正文中包含:<input type="text" name="content" value="<%=sContent%>" size="10" class=RimInput>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="查询" class=FlatBtn>
<input type="hidden" name="command" value="search">
<input type="hidden" name="Sorting" value="<%=GetParam("Sorting")%>">
<input type="hidden" name="Sorted" value="<%=GetParam("Sorted")%>">
<input type="hidden" name="Page" value="<%=GetParam("Page")%>">
<input type="hidden" name="pmserial" value="<%=GetParam("pmserial")%>">
</form>

<table cellspacing=0 cellpadding=0 align=center border=1 width=700>
<!--tr><td class=tblTitle colspan=6>消 息 查 询 结 果</td></tr-->
<%call MsgList() %>
</table>

<p align=center>
<a href="msgtree.asp"><img border=0 src="../images/tree.gif">&nbsp;以树型结构显示消息</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="u_SendMessage.asp"><img border=0 src="../images/writemsg.gif">&nbsp;发送消息</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="u_SendBulletin.asp"><img border=0 src="../images/writebtn.gif">&nbsp;发送公告</a>
</body>
</html>

<% Set cn = nothing %>

⌨️ 快捷键说明

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