<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.Date" %> 
<%@ page import="java.text.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
 <%!
        Connection con;
        Statement st;
        PreparedStatement pst;
        ResultSet rs;
        String eid,uname,pwd,fn,ln,email,mobile,addr,city,state,cntry,qual,exp;
        int i,i1;
        %>
        <jsp:include page="addemp.jsp"></jsp:include>
        <%
            try{
            uname=request.getParameter("uname");
            pwd=request.getParameter("pwd");
            fn=request.getParameter("fn");
            ln=request.getParameter("ln");
            email=request.getParameter("email");
            mobile=request.getParameter("mobile");
            addr=request.getParameter("addr");
            city=request.getParameter("city");
            state=request.getParameter("state");
            cntry=request.getParameter("cntry");
            qual=request.getParameter("qual");
            exp=request.getParameter("exp");
			 i1=Integer.parseInt(exp);
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","c2t","c2t");
            st=con.createStatement();

            rs=st.executeQuery("select eid.nextval from dual");
            if(rs.next())
            i=rs.getInt(1);
            eid="EMP00"+i;
            pst=con.prepareStatement("insert into employee values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
            pst.setString(1,eid);
            pst.setString(2,uname);
            pst.setString(3,pwd);
            pst.setString(4,fn);
            pst.setString(5,ln);
            pst.setString(6,email);
            pst.setString(7,mobile);
            pst.setString(8,addr);
            pst.setString(9,city);
            pst.setString(10,state);
            pst.setString(11,cntry);
            pst.setString(12,qual);
            pst.setInt(13,i1);
            pst.execute();
        %>
        <div style="position: absolute; width: 380px; height: 29px; z-index: 3; left: 437px; top: 220px" id="layer3">
			<b><font face="Tahoma" size="2" color="#17CA1C"><br>Employee Addedd successfully... </font></b></div>
	<%
        }
        catch(Exception e)
        {
           %>&nbsp;
          <div style="position: absolute; width: 815px; height: 19px; z-index: 2; left: 123px; top: 472px" id="layer2">
	<b><font face="Tahoma" size="2" color="#E4AC03">
            <%out.print(e.getMessage());%>
            "<%=uname%>" Name already Exists! <br>
        </font></b><font color="#E4AC03"> </font></div>
        <%
       }
        %>