首页 > 其他分享 >校园社团活动管理系统(20分) --期中考试

校园社团活动管理系统(20分) --期中考试

时间:2022-11-03 18:02:08浏览次数:62  
标签:20 删除 -- 2px alert window 社团活动 活动 页面

考试题目要求实现一个校园社团管理系统

整体框架

sql操作工具类
 package tool;
import java.sql.*;
public class Mysqltool {
	private static Connection con;
	private static PreparedStatement psta;
	private static ResultSet res;
	public static Connection getcon() {
		try {
			Class.forName("com.mysql.cj.jdbc.Driver");
			String url="jdbc:mysql://localhost:3306/school?useUnicode=true&characterEncoding=utf-8";
			con=DriverManager.getConnection(url,"root","111111");
			return con;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	public static ResultSet executequ(Connection Con,String sql,Object[] s) throws SQLException {
		psta=Con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
		for(int i=0;i<s.length;i++) {
			psta.setObject(i+1, s[i]);
		}
		res=psta.executeQuery();
		return res;
	}
	public static ResultSet executequ(Connection Con,String sql) throws SQLException {
		psta=Con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
		res=psta.executeQuery();
		return res;
	}
	public static int executeup(Connection Con,String sql,Object[] s) throws SQLException {
		psta=Con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
		for(int i=0;i<s.length;i++) {
			psta.setObject(i+1, s[i]);
		}
		int row=psta.executeUpdate();
		return row;
	}
	public static int executeup(Connection Con,String sql) throws SQLException {
		psta=Con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
		int row=psta.executeUpdate();
		return row;
	}
	public static void Close() {
		try {
			if(con!=null)
			con.close();
			if(res!=null)
			res.close();
			if(psta!=null)
			psta.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
主界面
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页面</title>
</head>
<body>
<a href="publish.html">发动活动信息</a>
<a href="revise.html">修改活动信息</a>
<a href="delete.html">删除活动信息</a>
<a href="browse.jsp">浏览活动信息</a>
<a href="inquire.html">查询活动信息</a>
</body>
</html>
发布
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>发布活动信息页面</title>
</head>
<body>
<form action="publish.jsp" method="post">
<h3>活动主题</h3>
<p><input type="text" name="theme" onblur="if(!/[\u4e00-\u9fa5]/.test(this.value)||this.value.length>20){value='';alert('请输入长度不超过20个中文');}"></p>
<h3>活动目的</h3>
<p><input type="text" name="aim"  onblur="if(!/[\u4e00-\u9fa5]/.test(this.value)||this.value.length>50){value='';alert('请输入长度不超过50个中文');}"></p>
<h3>活动类型</h3>
<p><input type="radio" name="kind" value="社团竞赛">社团竞赛</p>
<p><input type="radio" name="kind" value="野外采风">野外采风</p>
<p><input type="radio" name="kind" value="校内集会">校内集会</p>
<p><input type="radio" name="kind" value="社团纳新">社团纳新</p>
<h3>活动时间</h3>
<p><input type="text" name="time"></p>
<h3>活动地点</h3>
<p><input type="text" name="place"></p>
<h3>活动对象</h3>
<p><input type="checkbox" name="people1" value="社团成员">社团成员</p>
<p><input type="checkbox" name="people2" value="全体学生">全体学生</p>
<h3>活动内容</h3>
<p><input type="text" name="content" onblur="if(!/[\u4e00-\u9fa5]/.test(this.value)||this.value.length>500){value='';alert('请输入长度不超过500个中文');}"></p>
<h3>活动日程安排</h3>
<p><input type="text" name="plan" onblur="if(!/[\u4e00-\u9fa5]/.test(this.value)||this.value.length>500){value='';alert('请输入长度不超过500个中文');}"></p>
<p><input type="submit" value="提交"></p>
</form>
</body>
</html>
发布
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="java.sql.ResultSet"%>
<%@page import="tool.Mysqltool"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>发布活动信息结果页面</title>
</head>
<body>
<%
	request.setCharacterEncoding("UTF-8");
	String[] s=new String[8];
	s[0]=request.getParameter("theme");
	s[1]=request.getParameter("aim");
	s[2]=request.getParameter("kind");
	s[3]=request.getParameter("time");
	s[4]=request.getParameter("place");
	StringBuilder str=new StringBuilder();
	if(request.getParameter("people1")!=null)
	str.append(request.getParameter("people1"));
	System.out.print(request.getParameter("people1")+" "+request.getParameter("people2"));
	if(request.getParameter("people2")!=null)
    str.append(" "+request.getParameter("people2"));
	s[5]=str.toString();
	System.out.print(s[5]);
	s[6]=request.getParameter("content");
	s[7]=request.getParameter("plan");
	String sql="insert into `activity` values(?,?,?,?,?,?,?,?)";
	int row=Mysqltool.executeup(Mysqltool.getcon(), sql, s);
	if(row<1){
		Mysqltool.Close();
%>
<script type="text/javascript">
window.alert('提交失败');
location.assign("publish.html");
</script>
<%
	}
	else{
		ServletContext con=this.getServletContext();
		con.setAttribute("theme", s[0]);
		Mysqltool.Close();
%>
<script type="text/javascript">
window.alert('提交成功');
location.assign("browse.jsp");
</script>
<%
	}
	
%>
</body>
</html>
修改
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改活动信息页面</title>
</head>
<body>
<form action="revise.jsp" method="post">
<p><input type="text" name="theme"></p>
<p><input type="submit" value="查询"></p>
</form>
</body>
</html>
修改
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改活动信息页面</title>
</head>
<body>
<form action="revise.jsp" method="post">
<p><input type="text" name="theme"></p>
<p><input type="submit" value="查询"></p>
</form>
</body>
</html>
修改
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="tool.Mysqltool"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改信息页面</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String[] s=new String[8];
ServletContext con=this.getServletContext();
s[7]=(String)con.getAttribute("theme");
s[0]=request.getParameter("aim");
s[1]=request.getParameter("kind");
s[2]=request.getParameter("time");
s[3]=request.getParameter("place");
s[4]=request.getParameter("people");
s[5]=request.getParameter("content");
s[6]=request.getParameter("plan");
String sql="update `activity` set  `目的`=?,`类型`=?,`时间`=?,`地点`=?,`对象`=?,`内容`=?,`日程安排`=? where `主题`=?";
Mysqltool.executeup(Mysqltool.getcon(), sql, s);
Mysqltool.Close();
%>
<script type="text/javascript">
alert('修改成功')
</script>
</body>
</html>
删除
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除活动信息页面</title>
</head>
<body>
<form action="delete.jsp" method="post">
<p><input type="text" name="theme"></p>
<p><input type="submit" value="删除"></p>
</form>
</body>
</html>
删除
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="java.sql.ResultSet"%>
<%@page import="tool.Mysqltool"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>删除结果页面</title>
<style type="text/css">
<style type="text/css">
th {
	border:green solid 2px;
}
td {
	border:green solid 2px;
}
</style>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String[] s={request.getParameter("theme")};
String sql="select * from `activity` where`主题`=?";
ResultSet res=Mysqltool.executequ(Mysqltool.getcon(), sql, s);
%>
<table>
  <tr>
    <th>主题</th>
    <th>目的</th>
    <th>类型</th>
    <th>时间</th>
    <th>地点</th>
    <th>对象</th>
    <th>内容</th>
    <th>日程安排</th>
  </tr>

<%
		while(res.next()){
%>
  <tr>
    <td><%=res.getString("主题") %></td>
    <td><%=res.getString("目的") %></td>
    <td><%=res.getString("类型") %></td>
    <td><%=res.getString("时间") %></td>
    <td><%=res.getString("地点") %></td>
    <td><%=res.getString("对象") %></td>
    <td><%=res.getString("内容") %></td>
    <td><%=res.getString("日程安排") %></td>
  </tr>
<%
		}
%>
</table>
<script type="text/javascript">
window.alert('是否删除')
</script>
<%
sql="delete from `activity` where`主题`=?";
Mysqltool.executeup(Mysqltool.getcon(), sql, s);
Mysqltool.Close();
%>
<script type="text/javascript">
window.alert('删除成功')
location.assign("Main interface.html");
</script>
</body>
</html>
浏览
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="java.sql.ResultSet"%>
<%@page import="tool.Mysqltool"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>删除结果页面</title>
<style type="text/css">
<style type="text/css">
th {
	border:green solid 2px;
}
td {
	border:green solid 2px;
}
</style>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String[] s={request.getParameter("theme")};
String sql="select * from `activity` where`主题`=?";
ResultSet res=Mysqltool.executequ(Mysqltool.getcon(), sql, s);
%>
<table>
  <tr>
    <th>主题</th>
    <th>目的</th>
    <th>类型</th>
    <th>时间</th>
    <th>地点</th>
    <th>对象</th>
    <th>内容</th>
    <th>日程安排</th>
  </tr>

<%
		while(res.next()){
%>
  <tr>
    <td><%=res.getString("主题") %></td>
    <td><%=res.getString("目的") %></td>
    <td><%=res.getString("类型") %></td>
    <td><%=res.getString("时间") %></td>
    <td><%=res.getString("地点") %></td>
    <td><%=res.getString("对象") %></td>
    <td><%=res.getString("内容") %></td>
    <td><%=res.getString("日程安排") %></td>
  </tr>
<%
		}
%>
</table>
<script type="text/javascript">
window.alert('是否删除')
</script>
<%
sql="delete from `activity` where`主题`=?";
Mysqltool.executeup(Mysqltool.getcon(), sql, s);
Mysqltool.Close();
%>
<script type="text/javascript">
window.alert('删除成功')
location.assign("Main interface.html");
</script>
</body>
</html>
浏览
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="java.sql.ResultSet"%>
<%@page import="tool.Mysqltool"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>详细信息页面</title>
<style type="text/css">
th {
	border:green solid 2px;
}
td {
	border:green solid 2px;
}
</style>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
ServletContext con=this.getServletContext();
String[] s={(String)con.getAttribute("theme")};
String sql="select * from `activity` where`主题`=?";
ResultSet res=Mysqltool.executequ(Mysqltool.getcon(), sql, s);
%>
<table>
  <tr>
    <th>主题</th>
    <th>目的</th>
    <th>类型</th>
    <th>时间</th>
    <th>地点</th>
    <th>对象</th>
    <th>内容</th>
    <th>日程安排</th>
  </tr>

<%
		while(res.next()){
%>
  <tr>
    <td><%=res.getString("主题") %></td>
    <td><%=res.getString("目的") %></td>
    <td><%=res.getString("类型") %></td>
    <td><%=res.getString("时间") %></td>
    <td><%=res.getString("地点") %></td>
    <td><%=res.getString("对象") %></td>
    <td><%=res.getString("内容") %></td>
    <td><%=res.getString("日程安排") %></td>
  </tr>
<%
}
Mysqltool.Close();
%>
</table>
</body>
</html>
查询
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询页面</title>
</head>
<body>
<form action="browse.jsp" method="post">
<p><input type="text" name="theme"></p>
<p><input type="text" name="time"></p>
<p><input type="text" name="kind"></p>
<p><input type="text" name="people"></p>
<p><input type="submit"></p>
</form>
</body>
</html>

标签:20,删除,--,2px,alert,window,社团活动,活动,页面
From: https://www.cnblogs.com/liyiyang/p/16855004.html

相关文章

  • 【解决方案】智慧供热:智能控制阀监测系统
    一、方案背景随着我国城镇化率愈来愈高,供热面积不断增加,国家节能减排的力度也在不断加大,这给供热节能行业发展提供广阔的市场空间。供热节能成为行业共识,供热智慧化升级是供......
  • 02_vscode自动编译
     生成配置文件tsconfig.jsontsc--init  修改tsconfig.json配置 (以上内容均是学习尚硅谷课程笔记) 启动监视任务终端 > 运行任务 > 监视tsconfig.jso......
  • 报告分享|2022中国游戏电竞圈层营销白皮书
    随着电竞入亚、各地电竞政策相继颁布等背景的推助,电子竞技被推上了新的社会高度。2021年EDG夺冠,电竞赛事从圈内小狂欢发展成为普众大趴体,电竞关注度空前高涨,不仅深受Z世代群......
  • C#中的Convert.FromBase64String(String)方法
    https://www.nhooo.com/note/qa0bsy.htmlC#中的Convert.FromBase64String(String)方法将指定的字符串转换为等效的8位无符号整数数组,该字符串将二进制数据编码为以64位为......
  • Jenkins 线上技术交流
    在Jenkins中文社区微信技术交流群里,看到有人提出各种各样的问题,有一些问题快速得到了解答,有一些则可能由于各种原因没有收到回答。大家都能看出来,在各种群里交流有很多的......
  • 光电效应的小比喻
    在讲解光电效应时候,学生容易二和尚摸不着头脑,难以理解电子吸收光子,此时可以举一个井底之蛙的例子来帮助学生理解。光电效应的方程是hv=W0+1/2mv^2金属表面电子犹如井底之......
  • HDU 1686Oulipo ———————Hash or KMP
    OulipoOulipoTimeLimit:3000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):22302    AcceptedSubmission(s):86......
  • ubuntu20.04修改静态ip不生效问题
    一、前言最近从头开始配置hadoop的时候,由于想切换到NAT模式下配置hadoop,但在修改ip的时候发现设置了静态ip,但ip不生效,查了很多资料,发现由于配置信息写错了。二、解决问......
  • 这款工具不用手写一行代码就能做出网站!
    制作网站用什么,Dreamweaver还是Fireworks?现在,用GPT-3就可以。一位来自旧金山的程序员小哥做了款名为 debuild.co 的网页制作软件,只需要和GPT-3“聊聊天”,它就能帮你......
  • ios AppStore 上架流程(Xcode11.5)
    AppStore上架流程前提已经注册苹果开发者账号登录开发者官网​​https://developer.apple.com/​​点击account进行登录点击Certificates,Identifiers&Profiles1.首先进......