<%--
    Document   : CommonSearchInformationTradingLOV
    Created on : Mar 10, 2016, 2:30:36 AM
    Author     : SUBHAM
--%>

<%@page import="java.sql.PreparedStatement"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="LoginDb.DbHandler"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Customer Information Search</title>
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico" type="image/x-icon" />

        <%
            String searchString1 = "";
            String screenName = "";
            String searchString2 = "";
            String lovKey = "";
            String textIndex = "";

            screenName = request.getParameter("screenName");
            lovKey = request.getParameter("lovKey");
            String pacsId = session.getAttribute("pacsId").toString();
            String productId = request.getParameter("productId");

            String headerQry = null;

            if (screenName.equalsIgnoreCase("assetEntry.jsp") && (lovKey.equalsIgnoreCase("AssetCodeSearch"))) {

                    textIndex = request.getParameter("textIndex");

                    headerQry = "select ID,ASSET_TYPE,TYPE_DESC,ASSET_SUBTYPE,SUBTYPE_DESC from ASSET_MASTER";
                } else if (screenName.equalsIgnoreCase("assetRegister.jsp") && (lovKey.equalsIgnoreCase("assetDetails"))) {

                    //searchString1 = request.getParameter("asset_type");
                    //searchString2 = request.getParameter("asset_subtype");

                    if (searchString1.equalsIgnoreCase("") && searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master";
                    } else if (searchString1.equalsIgnoreCase("") && !searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where asset_type like '%" + searchString2.replace(' ', '%') + "%'";
                    } else if (!searchString1.equalsIgnoreCase("") && searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where asset_type like '%" + searchString1.replace(' ', '%') + "%'";
                    } else {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where asset_type like '%" + searchString1.replace(' ', '%') + "%' and asset_subtype like '%" + searchString2.replace(' ', '%') + "%'";
                    }

                } else if ((screenName.equalsIgnoreCase("assetDisposal.jsp")) && (lovKey.equalsIgnoreCase("assetDisposalDetails"))) {

                   // searchString1 = request.getParameter("asset_id");

                    if (searchString1.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_id,description from asset_register where pacs_id='"+pacsId+"'";
                    } else if (!searchString1.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_id,description from asset_register where pacs_id='"+pacsId+"' and upper(asset_id) like upper('%" + searchString1.replace(' ', '%') + "%') ";
                    }
                } else if ((screenName.equalsIgnoreCase("assetRelocation.jsp")) && (lovKey.equalsIgnoreCase("assetRelocationDetails"))) {

                   // searchString1 = request.getParameter("asset_id");

                    if (searchString1.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_id,description from asset_register where pacs_id='"+pacsId+"'";
                    } else if (!searchString1.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_id,description from asset_register where pacs_id='"+pacsId+"' and upper(asset_id) like upper('%" + searchString1.replace(' ', '%') + "%') ";
                    }
                } else if ((screenName.equalsIgnoreCase("assetRelocation.jsp")) && (lovKey.equalsIgnoreCase("assetRelocationDetails2"))) {

                  //  searchString1 = request.getParameter("pacsName");

                    if (searchString1.equalsIgnoreCase("")) {
                        headerQry = "select p.PACS_ID,p.PACS_NAME from pacs_master p where p.head_pacs_id in (select pm.head_pacs_id from pacs_master pm where pm.pacs_id='"+pacsId+"')";
                      
                    } else if (!searchString1.equalsIgnoreCase("")) {
                        headerQry = "select PACS_ID,PACS_NAME from pacs_master where upper(PACS_NAME) like upper('%" + searchString1.replace(' ', '%') + "%') ";
                    }
                } else if ((screenName.equalsIgnoreCase("Asset_Enquiry.jsp")) && (lovKey.equalsIgnoreCase("Asset_EnquiryDetails"))) {

                  //  searchString1 = request.getParameter("asset_id");

                    if (searchString1.equalsIgnoreCase("")) {
                        headerQry = "select ASSET_MST_ID,ASSET_ID,DESCRIPTION from ASSET_REGISTER order by ASSET_ID";
                    } else if (!searchString1.equalsIgnoreCase("")) {
                        headerQry = "select ASSET_MST_ID,ASSET_ID,DESCRIPTION from ASSET_REGISTER where upper(ASSET_ID) like upper('%" + searchString1.replace(' ', '%') + "%') order by ASSET_ID ";
                    }
                } else if (screenName.equalsIgnoreCase("assetMaster.jsp") && (lovKey.equalsIgnoreCase("assetMasterAmend"))) {

                  //  searchString1 = request.getParameter("asset_typeSearch");
                  //  searchString2 = request.getParameter("asset_subtypeSearch");

                    if (searchString1.equalsIgnoreCase("") && searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master";
                    } else if (searchString1.equalsIgnoreCase("") && !searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where ASSET_SUBTYPE like '%" + searchString2.replace(' ', '%') + "%'";
                    } else if (!searchString1.equalsIgnoreCase("") && searchString2.equalsIgnoreCase("")) {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where asset_type like '%" + searchString1.replace(' ', '%') + "%'";
                    } else {
                        headerQry = "select id,asset_type,type_desc,asset_subtype,subtype_desc from asset_master where asset_type like '%" + searchString1.replace(' ', '%') + "%' and asset_subtype like '%" + searchString2.replace(' ', '%') + "%'";
                    }

                } else if (screenName.equalsIgnoreCase("assetEntry.jsp") && (lovKey.equalsIgnoreCase("gl"))) {
                      //  searchString1 = request.getParameter("glcode"); 
                        searchString2 = request.getParameter("textIndex");
                        
                        headerQry = " select ga.key_1, ga.ledger_name, gp.gl_code, gp.comp1||gp.comp2 as id, gp.gl_name from gl_account ga, gl_product gp where substr(ga.gl_class_code, 9, 2) in ('20', '21', '22') and ga.gl_prod_id = gp.id and ga.pacs_id= '" + pacsId + "' and (gp.gl_code like '%" + searchString1.replace(' ', '%') + "%' or gp.gl_name like upper('%" + searchString1.replace(' ', '%') + "%') or ga.key_1 like '%" + searchString1.replace(' ', '%') + "%') ";  
                
                } else if (screenName.equalsIgnoreCase("crarRiskMaster.jsp") && (lovKey.equalsIgnoreCase("gl"))) {
                       // searchString1 = request.getParameter("glcode"); 
                        searchString2 = request.getParameter("textIndex");
                        
                        headerQry = " select ga.prod_name, substr(ga.glcc,14,5) gl_code, substr(ga.glcc,9,5)||substr(ga.glcc,14,5) id, substr(ga.glcc,9,5)comp1 , substr(ga.glcc,14,5) comp2 from trial_balance_shadow ga where substr(ga.glcc,9,1) ='2' and ga.ledger_dt=(select system_date-1 from system_date) and ga.pacs_id= '" + pacsId + "' and (substr(ga.glcc,14,5) like '%" + searchString1.replace(' ', '%') + "%' or ga.prod_name like upper('%" + searchString1.replace(' ', '%') + "%')) ";  
                
                } else if (screenName.equalsIgnoreCase("crarWorthMaster.jsp") && (lovKey.equalsIgnoreCase("gl"))) {
                       // searchString1 = request.getParameter("glcode"); 
                        searchString2 = request.getParameter("textIndex");
                        
                        headerQry = " select ga.prod_name, substr(ga.glcc,14,5) gl_code, substr(ga.glcc,9,5)||substr(ga.glcc,14,5) id, substr(ga.glcc,9,5)comp1 , substr(ga.glcc,14,5) comp2 from trial_balance_shadow ga where substr(ga.glcc,9,1) ='1' and ga.ledger_dt=(select system_date-1 from system_date) and ga.pacs_id= '" + pacsId + "' and (substr(ga.glcc,14,5) like '%" + searchString1.replace(' ', '%') + "%' or ga.prod_name like upper('%" + searchString1.replace(' ', '%') + "%')) ";  
                }


            Connection conn = DbHandler.getDBConnection();
            PreparedStatement pstmt = null;

            ResultSet resultSet = null;
            String bgColor = null;
            int flag = 1;

            try {
                pstmt = conn.prepareStatement(headerQry);
                resultSet = pstmt.executeQuery();

        %>
    </head>
    <body style="background-image: url('/PacsApplication/img/download.jpg');">
        <form name="commonSearch" action="">

            <%if (screenName.equalsIgnoreCase("assetEntry.jsp") && (lovKey.equalsIgnoreCase("AssetCodeSearch"))) {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>ID</b></th><th style="background-color: #99FF99;"><b>Asset Type</b></th><th style="background-color: #99FF99;"><b>Asset Type Desc</b></th><th style="background-color: #99FF99;"><b>Asset SubType</b></th><th style="background-color: #99FF99;"><b>Asset SubType Desc</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                         <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.getElementById('asset_mst_id<%=textIndex%>').value = document.getElementById('x<%=i%>').innerHTML;
                    opener.document.getElementById('asset_type<%=textIndex%>').value = document.getElementById('y<%=i%>').innerHTML + ':' + document.getElementById('z<%=i%>').innerHTML;
                    opener.document.getElementById('asset_subtype<%=textIndex%>').value = document.getElementById('a<%=i%>').innerHTML + ':' + document.getElementById('b<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.getElementById('asset_mst_id<%=textIndex%>').value = document.getElementById('x<%=i%>').innerHTML;
                    opener.document.getElementById('asset_type<%=textIndex%>').value = document.getElementById('y<%=i%>').innerHTML + ':' + document.getElementById('z<%=i%>').innerHTML;
                    opener.document.getElementById('asset_subtype<%=textIndex%>').value = document.getElementById('a<%=i%>').innerHTML + ':' + document.getElementById('b<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.getElementById('asset_mst_id<%=textIndex%>').value = document.getElementById('x<%=i%>').innerHTML;
                    opener.document.getElementById('asset_type<%=textIndex%>').value = document.getElementById('y<%=i%>').innerHTML + ':' + document.getElementById('z<%=i%>').innerHTML;
                    opener.document.getElementById('asset_subtype<%=textIndex%>').value = document.getElementById('a<%=i%>').innerHTML + ':' + document.getElementById('b<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.getElementById('asset_mst_id<%=textIndex%>').value = document.getElementById('x<%=i%>').innerHTML;
                    opener.document.getElementById('asset_type<%=textIndex%>').value = document.getElementById('y<%=i%>').innerHTML + ':'+document.getElementById('z<%=i%>').innerHTML;
                    opener.document.getElementById('asset_subtype<%=textIndex%>').value = document.getElementById('a<%=i%>').innerHTML + ':' + document.getElementById('b<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.getElementById('asset_mst_id<%=textIndex%>').value = document.getElementById('x<%=i%>').innerHTML;
                    opener.document.getElementById('asset_type<%=textIndex%>').value = document.getElementById('y<%=i%>').innerHTML + ':' + document.getElementById('z<%=i%>').innerHTML;
                    opener.document.getElementById('asset_subtype<%=textIndex%>').value = document.getElementById('a<%=i%>').innerHTML + ':' + document.getElementById('b<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
            <%}else if (screenName.equalsIgnoreCase("assetRegister.jsp") && (lovKey.equalsIgnoreCase("assetDetails"))) {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>Asset_MST_ID</b></th><th style="background-color: #99FF99;"><b>Asset Type</b></th><th style="background-color: #99FF99;"><b>Type Desc</b></th><th style="background-color: #99FF99;"><b>Asset SubType</b></th><th style="background-color: #99FF99;"><b>SubType Desc</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetregister.asset_type.value = document.getElementById('y<%=i%>').innerHTML;
                    opener.document.assetregister.asset_subtype.value = document.getElementById('a<%=i%>').innerHTML;
                    opener.document.assetregister.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetregister.asset_type.value = document.getElementById('y<%=i%>').innerHTML;
                    opener.document.assetregister.asset_subtype.value = document.getElementById('a<%=i%>').innerHTML;
                    opener.document.assetregister.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.assetregister.asset_type.value = document.getElementById('y<%=i%>').innerHTML;
                    opener.document.assetregister.asset_subtype.value = document.getElementById('a<%=i%>').innerHTML;
                    opener.document.assetregister.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.assetregister.asset_type.value = document.getElementById('y<%=i%>').innerHTML;
                    opener.document.assetregister.asset_subtype.value = document.getElementById('a<%=i%>').innerHTML;
                    opener.document.assetregister.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.assetregister.asset_type.value = document.getElementById('y<%=i%>').innerHTML;
                    opener.document.assetregister.asset_subtype.value = document.getElementById('a<%=i%>').innerHTML;
                    opener.document.assetregister.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
           <%} else if ((screenName.equalsIgnoreCase("assetDisposal.jsp")) && (lovKey.equalsIgnoreCase("assetDisposalDetails"))) {%>

            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>ID</b></th><th style="background-color: #99FF99;"><b>ASSET_ID</b></th><th style="background-color: #99FF99;"><b>Description</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                        <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetdisposalform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetdisposalform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                        <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetdisposalform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetdisposalform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                        <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.assetdisposalform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetdisposalform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>
                   </tr>
                <%}%>
            </table>
            <%} else if ((screenName.equalsIgnoreCase("assetRelocation.jsp")) && (lovKey.equalsIgnoreCase("assetRelocationDetails"))) {%>

            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>ID</b></th><th style="background-color: #99FF99;"><b>ASSET_ID</b></th><th style="background-color: #99FF99;"><b>Description</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                        <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetrelocationform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetrelocationform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                        <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetrelocationform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetrelocationform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                        <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.assetrelocationform.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetrelocationform.regid.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>

                </tr>
                <%}%>
            </table>
            <%}else if ((screenName.equalsIgnoreCase("assetRelocation.jsp")) && (lovKey.equalsIgnoreCase("assetRelocationDetails2"))) {%>

            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>PACS ID</b></th><th style="background-color: #99FF99;"><b>PACS NAME</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                        <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetrelocationform.pacsName.value = document.getElementById('x<%=i%>').innerHTML +':'+document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetrelocationform.pacs_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                        <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetrelocationform.pacsName.value = document.getElementById('x<%=i%>').innerHTML+':'+document.getElementById('y<%=i%>').innerHTML;
                            opener.document.assetrelocationform.pacs_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>


                </tr>
                <%}%>
            </table>
            <%} else if ((screenName.equalsIgnoreCase("Asset_Enquiry.jsp")) && (lovKey.equalsIgnoreCase("Asset_EnquiryDetails"))) {%>

            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>ASSET MST ID</b></th><th style="background-color: #99FF99;"><b>ASSET ID</b></th><th style="background-color: #99FF99;"><b>DESCRIPTION</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                        <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.asset_enquiry.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.asset_enquiry.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                        <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.asset_enquiry.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.asset_enquiry.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                        <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.asset_enquiry.asset_id.value = document.getElementById('y<%=i%>').innerHTML;
                            opener.document.asset_enquiry.asset_mst_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>


                </tr>
                <%}%>
            </table>
            <%} else if (screenName.equalsIgnoreCase("assetMaster.jsp") && (lovKey.equalsIgnoreCase("assetMasterAmend"))) {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>Asset_MST_ID</b></th><th style="background-color: #99FF99;"><b>Asset Type</b></th><th style="background-color: #99FF99;"><b>Type Desc</b></th><th style="background-color: #99FF99;"><b>Asset SubType</b></th><th style="background-color: #99FF99;"><b>SubType Desc</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetmaster.asset_typeSearch.value = document.getElementById('y<%=i%>').innerHTML+':'+document.getElementById('z<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_subtypeSearch.value = document.getElementById('a<%=i%>').innerHTML+':'+document.getElementById('b<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetmaster.asset_typeSearch.value = document.getElementById('y<%=i%>').innerHTML+':'+document.getElementById('z<%=i%>').innerHTML;;
                    opener.document.assetmaster.asset_subtypeSearch.value = document.getElementById('a<%=i%>').innerHTML+':'+document.getElementById('b<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.assetmaster.asset_typeSearch.value = document.getElementById('y<%=i%>').innerHTML+':'+document.getElementById('z<%=i%>').innerHTML;;
                    opener.document.assetmaster.asset_subtypeSearch.value = document.getElementById('a<%=i%>').innerHTML+':'+document.getElementById('b<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.assetmaster.asset_typeSearch.value = document.getElementById('y<%=i%>').innerHTML+':'+document.getElementById('z<%=i%>').innerHTML;;
                    opener.document.assetmaster.asset_subtypeSearch.value = document.getElementById('a<%=i%>').innerHTML+':'+document.getElementById('b<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.assetmaster.asset_typeSearch.value = document.getElementById('y<%=i%>').innerHTML+':'+document.getElementById('z<%=i%>').innerHTML;;
                    opener.document.assetmaster.asset_subtypeSearch.value = document.getElementById('a<%=i%>').innerHTML+':'+document.getElementById('b<%=i%>').innerHTML;
                    opener.document.assetmaster.asset_id.value = document.getElementById('x<%=i%>').innerHTML;
                    self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
           <%} else if (screenName.equalsIgnoreCase("assetEntry.jsp") && (lovKey.equalsIgnoreCase("gl"))) {%>
            <% if (!resultSet.isBeforeFirst()) {%>
            <center><p>No Customer found! Close this window & Please recheck the Customer Name selected.</p>
                <input type="button" value="Close Window" onclick="self.close();">
            </center>
            <% } else {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>Account No.</b></th><th style="background-color: #99FF99;"><b>Ledger Name</b></th><th style="background-color: #99FF99;"><b>Gl Code</b></th><th style="background-color: #99FF99;"><b>ID</b></th><th style="background-color: #99FF99;"><b>Gl Name</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.assetentry.glcode<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        opener.document.assetentry.glid<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.assetentry.glcode<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        opener.document.assetentry.glid<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.assetentry.glcode<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        opener.document.assetentry.glid<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>         
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.assetentry.glcode<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        opener.document.assetentry.glid<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.assetentry.glcode<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        opener.document.assetentry.glid<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
            <%}%>
            <%} else if (screenName.equalsIgnoreCase("crarRiskMaster.jsp") && (lovKey.equalsIgnoreCase("gl"))) {%>
            <% if (!resultSet.isBeforeFirst()) {%>
            <center><p>No Customer found! Close this window & Please recheck the Customer Name selected.</p>
                <input type="button" value="Close Window" onclick="self.close();">
            </center>
            <% } else {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>Product Name</b></th><th style="background-color: #99FF99;"><b>GL Code</b></th><th style="background-color: #99FF99;"><b>Gl ID</b></th><th style="background-color: #99FF99;"><b>Comp1</b></th><th style="background-color: #99FF99;"><b>Comp2</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.crarRisk.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarRisk.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarRisk.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarRisk.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.crarRisk.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarRisk.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarRisk.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarRisk.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.crarRisk.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarRisk.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarRisk.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarRisk.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>         
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.crarRisk.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarRisk.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarRisk.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarRisk.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.crarRisk.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarRisk.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarRisk.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarRisk.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
            <%}%>
            <%} else if (screenName.equalsIgnoreCase("crarWorthMaster.jsp") && (lovKey.equalsIgnoreCase("gl"))) {%>
            <% if (!resultSet.isBeforeFirst()) {%>
            <center><p>No Customer found! Close this window & Please recheck the Customer Name selected.</p>
                <input type="button" value="Close Window" onclick="self.close();">
            </center>
            <% } else {%>
            <table border="2">
                <tr><th style="background-color: #99FF99;"><b>Account No.</b></th><th style="background-color: #99FF99;"><b>Ledger Name</b></th><th style="background-color: #99FF99;"><b>Gl Code</b></th><th style="background-color: #99FF99;"><b>ID</b></th><th style="background-color: #99FF99;"><b>Gl Name</b></th></tr>
                <%int i = 0;
                     while (resultSet.next()) {
                         i++;
                         if (flag == 1) {
                             flag = 0;
                             bgColor = "#AFC7C7";
                         } else {
                             flag = 1;
                             bgColor = "#95B9C7";
                         }%>
                <tr><td bgcolor='<%=bgColor%>' id='x<%=i%>' onclick="opener.document.crarWorthMaster.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(1)%></td>
                    <td bgcolor='<%=bgColor%>' id='y<%=i%>' onclick="opener.document.crarWorthMaster.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(2)%></td>
                    <td bgcolor='<%=bgColor%>' id='z<%=i%>' onclick="opener.document.crarWorthMaster.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(3)%></td>         
                    <td bgcolor='<%=bgColor%>' id='a<%=i%>' onclick="opener.document.crarWorthMaster.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(4)%></td>
                    <td bgcolor='<%=bgColor%>' id='b<%=i%>' onclick="opener.document.crarWorthMaster.glcode<%=searchString2%>.value = document.getElementById('x<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.glid<%=searchString2%>.value = document.getElementById('z<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp1<%=searchString2%>.value = document.getElementById('a<%=i%>').innerHTML;
                        opener.document.crarWorthMaster.comp2<%=searchString2%>.value = document.getElementById('b<%=i%>').innerHTML;
                        self.close();" style="cursor:pointer;"><%=resultSet.getString(5)%></td>
                </tr>
                <%}%>
            </table>
            <%}%>
            <%}%>

        </form>
    </body>
    <%
        } catch (Exception ex) {
          //  System.out.println(ex);
        } finally {
            if (resultSet != null) {
                resultSet.close();
            }
            if (pstmt != null) {
                pstmt.close();
            }
            if (conn != null) {
                conn.close();
            }
        }
    %>

</html>
