<%@page contentType="text/html" pageEncoding="UTF-8"
import="model.Employee,dao.EmployeeDao,java.util.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            EmployeeDao edao=new EmployeeDao();
            List<Employee>lst=edao.GetAllEmployees();
        %>
        <h1>Employee!!!</h1>
        <form method="post">
            <table>
                <tr>
                     <td>Employee Id</td>
                     <td><input type="text" name="txtid"/></td>
                </tr>
                 <tr>
                     <td>Employee Name</td>
                     <td><input type="text" name="txtname"/></td>
                </tr>
                 <tr>
                     <td>Designation</td>
                     <td><input type="text" name="txtdesignation"/></td>
                </tr>
                 <tr>
                     <td>Salary</td>
                     <td><input type="text" name="txtsalary"/></td>
                </tr>
                 <tr>
                      <td><input type="submit" value="Submit"/></td>
                </tr>
            </table>
        </form>
        <%
            String msg="";
            if(request.getMethod().equals("POST"))
            {
                int id=Integer.parseInt(request.getParameter("txtid"));
                String name=request.getParameter("txtname");
                String des=request.getParameter("txtdesignation");
                float sal=Float.parseFloat(request.getParameter("txtsalary"));
                Employee emp=new Employee(id, name, des, sal);
                msg=edao.AddEmployee(emp);
                lst=edao.GetAllEmployees();
            }
        %>
        <h4><%=msg %></h4>
        <hr/>
        <table border="1">
            <thead>
                <tr>
                     <th>Employee Id</th>
                     <th>Employee Name</th>
                      <th>Designation</th>
                      <th>Salary</th>
                      <th>Action</th>
                 </tr>
            </thead>
            <tbody>
                 <%
                      for(Employee e:lst)
                      {
                 %>
                 <tr>
                      <td><%=e.getEmployee_id() %></td>
                      <td><%=e.getEmployee_name() %></td>
                      <td><%=e.getDesignation() %></td>
                      <td><%=e.getSalary() %></td>
                      <td>
                           <a href="UpdateEmployee.jsp?employee_id=<
%=e.getEmployee_id() %>">update</a>
                           <a href="DeleteEmployee.jsp?employee_id=<
%=e.getEmployee_id() %>">Delete</a>
                      </td>
                 </tr>
                 <%
                      }
                 %>
            </tbody>
        </table>
    </body>
</html>