@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); if (request.getParameter("action").equals("Add User Type")) { String userType = request.getParameter("userType"); int actionStatusId = Integer.parseInt(request.getParameter("actionStatusId")); model.pojo.ActionStatus actionStatus = model.ActionStatus.getInstance().getActionStatusById(actionStatusId); model.UserType acs = model.UserType.getInstance(); acs.saveUserType(userType, actionStatus); response.sendRedirect("datafill.jsp"); } if (request.getParameter("action").equals("Update User Type")) { int userTypeId = Integer.parseInt(request.getParameter("userTypeId")); String userType = request.getParameter("userType"); int actionStatusId = Integer.parseInt(request.getParameter("actionStatusId")); model.pojo.ActionStatus actionStatus = model.ActionStatus.getInstance().getActionStatusById(actionStatusId); model.UserType acs = model.UserType.getInstance(); acs.updateUserType(userTypeId, userType, actionStatus); response.sendRedirect("datafill.jsp"); } if (request.getParameter("action").equals("getUserTypes")) { out.write(model.html.UserType.getInstance().getUserTypes()); } }
public String getAllUsers() { List<model.pojo.Gup> dbGupList = model.Gup.getInstance().getGup(); List<model.pojo.UserType> dbUserTypeList = model.UserType.getInstance().getUserType(); List<model.pojo.ActionStatus> dbActionStatusList = model.ActionStatus.getInstance().getActionStatus(); String htmlScript = ""; htmlScript += " <div class=\"col-md-12\">\n"; htmlScript += " <div class=\"panel panel-default\">\n"; htmlScript += " <div class=\"panel-heading\">\n"; htmlScript += " User Account Management\n"; htmlScript += " </div>\n"; htmlScript += " <div class=\"panel-body\">\n"; htmlScript += " <table class=\"table table-responsive table-striped\">\n"; htmlScript += " <thead>\n"; htmlScript += " <tr>\n"; htmlScript += " <th>User ID</th>\n"; htmlScript += " <th>User Name</th>\n"; htmlScript += " <th>Email</th>\n"; htmlScript += " <th>User Type</th>\n"; htmlScript += " <th>Registered Date / Time</th>\n"; htmlScript += " <th>Account Status</th>\n"; htmlScript += " </tr>\n"; htmlScript += " </thead>\n"; htmlScript += " <tbody>\n"; for (model.pojo.Gup gupObj : dbGupList) { htmlScript += "\n"; htmlScript += " <tr>\n"; htmlScript += " <td>"; htmlScript += gupObj.getIdgup(); htmlScript += "</td>\n"; htmlScript += " <td>"; htmlScript += gupObj.getFirstName() + " " + gupObj.getLastName(); htmlScript += "</td>\n"; htmlScript += " <td>"; htmlScript += gupObj.getEmail(); htmlScript += "</td>\n"; htmlScript += " <td>\n"; htmlScript += " <select id=\""; htmlScript += gupObj.getIdgup(); htmlScript += "usrtype\" class=\"form-control\" onchange=\"updateUserType("; htmlScript += gupObj.getIdgup(); htmlScript += ")\">\n"; for (model.pojo.UserType userTypeObj : dbUserTypeList) { htmlScript += "\n"; htmlScript += " <option value=\""; htmlScript += userTypeObj.getIduserType(); htmlScript += '"'; htmlScript += '>'; htmlScript += userTypeObj.getUserType(); htmlScript += "</option>\n"; htmlScript += " "; } htmlScript += "\n"; htmlScript += " </select>\n"; htmlScript += " </td>\n"; htmlScript += " <td>"; htmlScript += gupObj.getRegisteredTime(); htmlScript += "</td>\n"; htmlScript += " <td>\n"; htmlScript += " <select id=\""; htmlScript += gupObj.getIdgup(); htmlScript += "accstatus\" class=\"form-control\" onchange=\"updateUserStatus("; htmlScript += gupObj.getIdgup(); htmlScript += ")\">\n"; htmlScript += " "; for (model.pojo.ActionStatus actionStatusObj : dbActionStatusList) { htmlScript += "\n"; htmlScript += " <option value=\""; htmlScript += actionStatusObj.getIdactionStatus(); htmlScript += '"'; htmlScript += '>'; htmlScript += actionStatusObj.getActionStatus(); htmlScript += "</option>\n"; htmlScript += " "; } htmlScript += "\n"; htmlScript += " </select>\n"; htmlScript += " </td>\n"; htmlScript += " </tr>\n"; htmlScript += " <script>\n"; htmlScript += " $('#"; htmlScript += gupObj.getIdgup(); htmlScript += "usrtype').val("; htmlScript += gupObj.getUserType().getIduserType(); htmlScript += ");\n"; htmlScript += " $('#"; htmlScript += gupObj.getIdgup(); htmlScript += "accstatus').val("; htmlScript += gupObj.getActionStatus().getIdactionStatus(); htmlScript += ");\n"; htmlScript += " </script>\n"; htmlScript += " "; } htmlScript += "\n"; htmlScript += " </tbody>\n"; htmlScript += " </table>\n"; htmlScript += " </div>\n"; htmlScript += " </div>\n"; htmlScript += " </div>\n"; htmlScript += "\n"; return htmlScript; }