display.jsp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <%@page import="java.sql.ResultSet"%>
  2. <%@page import="java.sql.PreparedStatement"%>
  3. <%@page import="java.sql.DriverManager"%>
  4. <%@page import="java.sql.Connection"%>
  5. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  10. <meta name="viewport" content="width=device-width,initial-scale=1.0,
  11. minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  12. <title>员工信息</title>
  13. <script>
  14. function update(obj){
  15. var ocount = document.getElementById('count');
  16. var oname = document.getElementById('name');
  17. var ogender = document.getElementById('gender');
  18. var otelephone = document.getElementById('telephone');
  19. var omailbox = document.getElementById('mailbox');
  20. var oage = document.getElementById('age');
  21. var odepartemnt = document.getElementById('department');
  22. var oTr = obj.parentNode.parentNode;
  23. var aTd = oTr.getElementsByTagName('td');
  24. rowIndex = obj.parentNode.parentNode.rowIndex;
  25. ocount.value = aTd[1].innerHTML;
  26. oname.value = aTd[2].innerHTML;
  27. ogender.value = aTd[3].innerHTML;
  28. otelephone.value = aTd[4].innerHTML;
  29. omailbox.value = aTd[5].innerHTML;
  30. oage.value = aTd[6].innerHTML;
  31. odepartment.value = aTd[7].innerHTML;
  32. console.log(aTd[4].innerHTML);
  33. }
  34. </script>
  35. <style type="text/css">
  36. *{
  37. margin: 0;
  38. padding: 0;
  39. }
  40. body{
  41. padding: 10px 50px;
  42. }
  43. #wrap{
  44. width: 800px;
  45. margin: 10px auto;
  46. font-family: 'trebuchet MS','Lucida sans',Arial;/*字体效果*/
  47. font-size: 14px;
  48. color: #444;
  49. }
  50. table{
  51. *border-collapse:collapse;/*border-collapse用于表格属性,表示表格的两边框合并成一条*/
  52. border-spacing: 0;/*border-spacing属性设置相邻单元格的边框的距离*/
  53. width: 100%;
  54. }
  55. /*======bordered table======*/
  56. /*-moz代表firefox浏览器私有属性,-ms代表ie浏览器私有属性,-webkit代表safari、chrome私有属性。这些是为了兼容老版本的写法,比较新版本的浏览器都支持直接写:border-radius。*/
  57. .bordered{
  58. border: solid #ccc 1px;
  59. -moz-border-radius:6px;
  60. -webkit-border-radius:6px;
  61. border-radius: 6px; /*添加圆角边框:*/
  62. -wekit-box-shadow:0 1px 1px #ccc;
  63. -moz-box-shadow:0 1px 1px #ccc;
  64. box-shadow: 0 1px 1px #ccc; /*向方框添加阴影。*/
  65. }
  66. .bordered tr{
  67. -o-transition:all 0.1s ease-in-out;/*过渡效果*/
  68. -webkit-transition:all 0.1s ease-in-out;
  69. -moz-transition:all 0.1s ease-in-out;
  70. -ms-transition:all 0.1s ease-in-out;
  71. transition:all 0.1s ease-in-out;
  72. }
  73. .bordered highlight,.bordered tr:hover{background: #fbf8e9;} /*hover:当鼠标经过时会颜色的变化*/
  74. .bordered td,.bordered th{
  75. border-left: 1px solid #ccc;
  76. border-top: 1px solid #ccc;
  77. padding: 10px;
  78. text-align: left; /*左对齐元素中的文本*/
  79. }
  80. .bordered th{
  81. border-color: #dce9f9; /*-webkit safari、chrome私有属性 linear-gradient()函数用于创建一个线性渐变的 "图像"*/
  82. background-image: -webkit-gradient(linear,left top,left bottom,from(#ebf3fc),to(#dce9f9));
  83. background-image: -webkit-linear-gradient(top,#ebf3fc,#dce9f9);
  84. background-image: -moz-linear-gradient(top,#ebf3fc,#dce9f9);
  85. background-image: -ms-linear-gradient(top,#ebf3fc,#dce9f9);
  86. background-image: -o-linear-gradient(top,#ebf3fc,#dce9f9);
  87. background-image: linear-gradient(top,#ebf3fc,#dce9f9);
  88. filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ebf3fc,endColorstr=#dce9f9); /*ie提供的css渲染*/
  89. -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ebf3fc,endColorstr=#dce9f9)";
  90. -webkit-box-shadow:0 1px 0 raba(255,255,255,.8) inset; /*ie提供的css渲染*/
  91. -moz-box-shadow:0 1px 0 raba(255,255,255,.8) inset;
  92. box-shadow:0 1px 0 raba(255,255,255,.8) inset; /*内阴影*/
  93. border-top: none;
  94. text-shadow:0 1px 0 raba(255,255,255,.5);
  95. }
  96. .bordered td:first-child,.bordered th:first-child{
  97. border-left: none;
  98. }
  99. .bordered th:first-child{
  100. -moz-border-radius:6px 0 0 0;
  101. -webkit-border-radius:6px 0 0 0;
  102. border-radius:6px 0 0 0;
  103. }
  104. .bordered th:last-child{
  105. -moz-border-radius:0 6px 0 0;
  106. -webkit-border-radius:0 6px 0 0;
  107. border-radius:0 6px 0 0;
  108. }
  109. .bordered tr:last-child td:first-child{
  110. -moz-border-radius:0 0 0 6px;
  111. -webkit-border-radius:0 0 0 6px;
  112. border-radius:0 0 0 6px;
  113. }
  114. .bordered tr:last-child td:last-child{
  115. -moz-border-radius:0 0 6px 0;
  116. -webkit-border-radius:0 0 6px 0;
  117. border-radius:0 0 6px 0;
  118. }
  119. .a{
  120. color:blue;
  121. }
  122. .button{
  123. background: url(images/button-bg.png) repeat-x top center;
  124. border: 1px solid #999;
  125. -moz-border-radius:4px;
  126. -webkit-border-radius:4px;
  127. border-radius:4px;
  128. padding: 5px;
  129. color: black;
  130. font-weight: bold;
  131. font-size: 13px;
  132. width: 70px;
  133. }
  134. .button:hover{
  135. background: white;
  136. color: black;
  137. }
  138. </style>
  139. </head>
  140. <body>
  141. <h1 align="center">员工信息列表</h1>
  142. <div align="right" >
  143. <input type="button" value="添加员工" class="button"
  144. onclick="javascrtpt:window.location.href = 'add.jsp'">
  145. </div>
  146. <br>
  147. <div align="right">欢迎你,
  148. <a href="login.jsp">退出</a>
  149. </div>
  150. <br>
  151. <form action="update.jsp" class="bordered">
  152. <table align="center">
  153. <tr>
  154. <td>
  155. 姓名:<input type="text" name="name"/>
  156. </td>
  157. <td>
  158. <input type="submit" value="查询" class="button" onclick="javascrtpt:window.location.href = 'update.jsp'"/>
  159. </td>
  160. </tr>
  161. </table>
  162. </form>
  163. <form action="update2.jsp" class="bordered">
  164. <table align="center">
  165. <tr>
  166. <td>
  167. 部门:
  168. <select name="department">
  169. <option value="人力部" >人力部</option>
  170. <option value="生活部" >生活部</option>
  171. <option value="活动部" >活动部</option>
  172. <option value="财务部" >财务部</option>
  173. </select>
  174. </td>
  175. <td>
  176. <input type="submit" value="查询" class="button" onclick="javascrtpt:window.location.href = 'update2.jsp'" />
  177. </td>
  178. </tr>
  179. </table>
  180. </form>
  181. <%
  182. String driver = "com.mysql.cj.jdbc.Driver";
  183. String url = "jdbc:mysql://localhost:3306/edu?characterEncoding=utf-8"
  184. + "&serverTimezone=UTC";
  185. String usr = "root";
  186. String password = "1234";
  187. Class.forName(driver);
  188. Connection conn = DriverManager.getConnection(url, usr, password);
  189. String sqlString = "select * from manager1";
  190. PreparedStatement pstmt = conn.prepareStatement(sqlString);
  191. ResultSet rs = pstmt.executeQuery();
  192. %>
  193. <table border=1 style="margin:auto" class="bordered">
  194. <tr>
  195. <th class="listTable" id="count">序号</th>
  196. <th class="listTable" id="name">姓名</th>
  197. <th class="listTable" id="gender">性别</th>
  198. <th class="listTable" id="telephone">电话</th>
  199. <th class="listTable" id="mailbox">邮箱</th>
  200. <th id="profile" id="age">年龄</th>
  201. <th id="operate" id="department">部门</th>
  202. <th>操作</th>
  203. </tr>
  204. <%
  205. while (rs.next()) {
  206. out.println("<tr>");
  207. out.println("<td >" + rs.getString("count") + "</td>");
  208. out.println("<td >" + rs.getString("name") + "</td>");
  209. out.println("<td>" + rs.getString("gender") + "</td>");
  210. out.println("<td>" + rs.getString("telephone") + "</td>");
  211. out.println("<td>" + rs.getString("mailbox") + "</td>");
  212. out.println("<td>" + rs.getInt("age") + "</td>");
  213. out.println("<td>" + rs.getString("department") + "</td>");
  214. out.println("<td><div><a href='../delete?count=" + rs.getString("count") + "'><button>删除</button></a></div><div><a href='change.jsp?count=" + rs.getString("count") + "'><button>修改</button></a></div></td>");
  215. out.println("</tr>");
  216. }
  217. %>
  218. </table>
  219. </body>
  220. </html>