Search This Blog

Thursday, 4 September 2014

24. HTML and JSP Program to Evaluate Salary Details of an Employee and Store in Database

Filename: Employee24.html
<!-- 24. Program to accept Employee Details. -->
<html>
 <head>

 <title>Employee Details</title>
 </head>
 <body>
 <h3>Enter Employee Details:<h3>
 <form action="emp24.jsp" method="POST" >
 <table >
 <tr><td>Employee Name:</td><td><input type="text" name="ename" autofocus></td></tr>
 <tr><td>Employee ID:</td><td><input type="text" name="empid"></td></tr>
 <tr><td>Department:</td><td><input type="text" name="dept"></td></tr>
 <tr><td>Designation:</td><td><input type="text" name="des"></td></tr>
 <tr><td>Basic Salary:</td><td><input type="text" name="bsal"></td></tr>
 <tr><td>TA(%):</td><td><input type="text" name="ta"></td></tr>
 <tr><td>DA(%):</td><td><input type="text" name="da"></td></tr>
 <tr><td>HRA(%):</td><td><input type="text" name="hra"></td></tr>
 <tr><td>PF(%):</td><td><input type="text" name="pf"></td></tr>
 <tr><td>LIC(%):</td><td><input type="text" name="lic"></td></tr>

 <tr><td><input type="submit" value="Evaluate & Store"></td>
 <td><input type="reset" value="Reset"></td></tr>
 </table>
 
 </body>
</html>


Filename: Employee24.jsp
<!-- 24. JSP Program to Evaluate Salary Details of an Employee and Store in Database.-->
<html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">

<%
   
    String ename=request.getParameter("ename");
    String empid=request.getParameter("empid");
    String dept=request.getParameter("dept");
    String des=request.getParameter("des");
    double bsal=Double.valueOf(request.getParameter("bsal"));
    double ta=Double.valueOf(request.getParameter("ta"));
    double ta2=bsal*ta/100;
    double da=Double.valueOf(request.getParameter("da"));
    double da2=bsal*da/100;
    double hra=Double.valueOf(request.getParameter("hra"));
    double hra2=bsal*hra/100;
    double pf=Double.valueOf(request.getParameter("pf"));
    double pf2=bsal*pf/100;
    double lic=Double.valueOf(request.getParameter("lic"));
    double lic2=bsal*lic/100;
    double allowance;
    double deduction;
    double gsal;
    double netsal;

    allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
    deduction = (bsal*pf)/100 + (bsal*lic)/100;
    gsal = bsal + allowance;
    netsal = gsal - deduction;
   
    try
    {
        out.println("<h2>Information Stored Successfully!</h2>");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:emp24");
        Statement st=con.createStatement();
        String s="insert into emp24 values('"+ename+"','"+empid+"','"+dept+"','"+des+"',"
            +bsal+","+ta2+","+da2+","+hra2+","+allowance+","+gsal+","+pf2+","+lic2+","
            +deduction+","+netsal+");";
        st.executeQuery(s);
    }
    catch(Exception e)
    {
        //out.println(e);
    }
%>
</body>
</html>
 


No comments :

Post a Comment

FREE Hit Counters