<%@ page language="java" import="java.sql.*, java.io.*, java.util.*, users.databases.*" errorPage="error.jsp" %> <% /***** VARIABLE DECLARATION and INITIALIZATION *****/ String strMainDB = "product_pgpClientInfoDB"; String strCompanyName = "", strPrevBtn = "", strNextBtn = ""; String [] arrCPName, arrCPID, arrCPPos; // CONTAINER FOR CONTACT PERSON NAME, POSITION, AND ID NUMBER String strCPTitle = ""; // USE TO INDICATE IF THERE ARE STILL REMAINING CONTACT PERSONS TO BE DELETED int ctr = 0, total = 0; // USE FOR COUNTING TOTAL NUMBER OF CONTACT PERSONS int batchModifier = 5; // IF EQUAL TO UNITS OF LAST BATCH, IT'LL BE COMBINED WITH SECOND TO LAST BATCH int batchMaxUnit = 20; // MAXIMUM NUMBER OF CONTACT PERSONS THAT WOULD BE DISPLAYED PER PAGE int intUserID = Integer.parseInt(request.getParameter("uid")); int intCompanyID = Integer.parseInt(request.getParameter("cid")); byte bytBtnID = Byte.parseByte(request.getParameter("did")); int intBegPoint = Integer.parseInt(request.getParameter("p1")); int intEndPoint = Integer.parseInt(request.getParameter("p2")); /***** END OF VARIABLE DECLARATION *****/ String SQLstmt = "SELECT LogOnStatus FROM tblLogOn WHERE Usr_ID=" + intUserID + ";"; users.connect(strMainDB); ResultSet rs = users.listQuery(SQLstmt); byte bytLogStatus = 0; while (rs.next()) { bytLogStatus = rs.getByte("LogOnStatus"); } if (bytLogStatus != 1) { // LOG CHECK RESULT - LOG-OUT, DISPLAYS HOME PAGE %> <% } else { // LOG CHECK RESULT - LOG-ON, PROCEED DISPLAYING ACTUAL PAGE SQLstmt = "SELECT Co_Name FROM tblCompanyInfo WHERE Co_ID=" + intCompanyID + ";"; rs = users.listQuery(SQLstmt); while (rs.next()) { // GET NAME OF COMPANY strCompanyName = rs.getString("Co_Name"); } SQLstmt = "SELECT CPx_ID, CPx_FirstN, CPx_LastN, CPx_Position FROM tblOtherCPs" + " WHERE Co_ID=" + intCompanyID + " ORDER BY CPx_ID;"; rs = users.listQuery(SQLstmt); while (rs.next()) { ctr++; // COUNTS TOTAL NUMBER OF CONTACT PERSONS } total = ctr; if (intEndPoint > ctr) { // TOTAL CONTACT PERSONS TO BE DISPLAYED IS LESS THAN MAXIMUM arrCPName = new String[(ctr-intBegPoint)]; arrCPPos = new String[(ctr-intBegPoint)]; arrCPID = new String[(ctr-intBegPoint)]; } else { if ((ctr-intEndPoint) <= batchModifier) { arrCPName = new String[ctr-intBegPoint]; arrCPPos = new String[ctr-intBegPoint]; arrCPID = new String[ctr-intBegPoint]; } else { arrCPName = new String[(intEndPoint-intBegPoint)]; arrCPPos = new String[(intEndPoint-intBegPoint)]; arrCPID = new String[(intEndPoint-intBegPoint)]; } } if (intBegPoint==0) { // NO PREVIOUS DATA TO DISPLAY strPrevBtn = ""; } else { // PREVIOUS BUTTON IS ACTIVATED strPrevBtn = ""; } if (intEndPoint > (ctr-batchModifier)) { // NO REMAINING DATA CAN BE DISPLAYED strNextBtn = ""; } else { // NEXT BUTTON IS ACTIVATED strNextBtn = ""; } if (intBegPoint==0) { // SINCE RESULTSET METHOD ABSOLUTE DOES NOT WORK WITH VALUE EQUAL TO ZERO rs.beforeFirst(); } else { rs.absolute(intBegPoint); } ctr = 0; while (rs.next()) { String strFirstName = rs.getString("CPx_FirstN"); String strLastName = rs.getString("CPx_LastN"); arrCPName[ctr] = strFirstName + " " + strLastName; arrCPPos[ctr] = rs.getString("CPx_Position"); arrCPID[ctr] = rs.getString("CPx_ID"); ctr++; if (ctr==(arrCPName.length)) { break; } } if (ctr==0) { strCPTitle = "NO REMAINING CONTACT PERSON TO BE DELETED"; } else { strCPTitle = "SELECT CONTACT PERSON TO BE DELETED"; } /***** MERGING WITH MAIN HTML CODES STARTS HERE *****/ %> Delete - Contact Persons

COMPANY PROFILE
Company: <%= strCompanyName %>


<%= strCPTitle %>

<% for (int i=0; i Name: <%= arrCPName[i] %>, Position: <%= arrCPPos[i] %> <% if ((i+1)==ctr && ctr != 1) { %>

showing <%= intBegPoint + 1 %>-<%= intBegPoint + ctr %> of <%= total %>

<% } else { %>
<% } %> <% } %>

<% if (intBegPoint == 0 && intEndPoint >= (total-batchModifier)) { %> <% } else { %> <%= strPrevBtn %> <%= strNextBtn %> <% } %> <% if (ctr != 0) { // TABLE IS NOT EMPTY OF CONTACT PERSON %> <% } %>

<% } // END OF LOG CHECK %>