2013年11月13日 星期三

jsp-mysql 2



<%
  if (session.isNew() || session.getAttribute("Login") == null ){
response.sendRedirect("index.jsp");
}
%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.*" %>

<%
String connectionURL = "jdbc:mysql://localhost/hr?useUnicode=true&characterEncoding=UTF8";
String mActive="";
String mLeave="";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(connectionURL, "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select sum(Case when status ='A' Then 1 ELSE 0 end ) AS active,"+
"sum(Case when status ='T' Then 1 ELSE 0 end ) AS term from employee;");
if(rs.next()) {
mActive=rs.getString(1).trim();
mLeave=rs.getString(2).trim();
}
}catch(Exception e1){}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="js/modalPopLite.js" type="text/javascript"></script>
<script src="js/JavaScriptUtil.js"></script>
<script src="js/jquery-ui-1.10.3.custom.js"></script>
<script src="js/Parsers.js"></script>
<script src="js/InputMask.js"></script>
<script src="input.js"></script>
<script src="js/udf2.js"></script>
<link href="css/payroll.css" rel="stylesheet" type="text/css" />
<style type="text/css">
td {vertical-align:top;}
body {background: url(images/bg.png) repeat;}
</STYLE>
</head>
<!-- body  class="bodyClass" -->
<body>
<div class="captionLine">
<span>Action Box</span>
</div>
<br>
<div id="content" style="width:100%; ">
<div style="border:solid 1px black; height:200px; width:49%;float:left">
<span style="width:100% ; margin-left:2px; float:left;height:20px; color:white; background-color:rgb(67,120,182); margin-bottom:0;">Employee</span>
New Hires and employee data.
<table style="margin-top:20px;">
<tr>
<td> Active:</td><td><input  style="width:30%" type="text" name="active" id="active" value="<%=mActive%>" readonly ></td>
</tr>
<tr>
<td> Leave: </td><td><input  style="width:30%" type="text" name="leave" id="leave" value="<%=mLeave%>" readonly></td>
</tr>
<tr>
<td> Terminated (for the current Year) : </td><td><input  style="display:none"  style="width:30%" type="text" name="terminated" value="5" readonly></td>
</tr>
<tr>
<td> Terminated (for the last Year) : </td><td><input  style="display:none"  style="width:30%" type="text" name="terminated" value="15" readonly></td>
</tr>
</table>
</div>
</div>
</body>

沒有留言:

張貼留言