<%--
    Document   : TradingStockRegisterEdit
    Created on : Feb 10, 2022, 12:31:09 PM
    Author     : 1242938
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="DataEntryBean.TrandinStockRegisterBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="LoginDb.DbHandler"%>
<% try {
%>

<html>

    <head>
        <title>Trading Stock Register</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="${pageContext.request.contextPath}/js/Calendar.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/TableCSSCode.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/img/favicon.ico?pacs=<%=((new java.util.Date()).getTime())%>" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/styles.css?pacs=<%=((new java.util.Date()).getTime())%>"/>
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/ButtonAndText.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <link rel="stylesheet" type="text/css" href="/PacsApplication/css/info.css?pacs=<%=((new java.util.Date()).getTime())%>" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-ui-1.10.4.custom/development-bundle/jquery-1.10.2.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/chromejs/chrome.js?pacs=<%=((new java.util.Date()).getTime())%>"></script>
        <script type="text/javascript" src="/PacsApplication/js/iFrame_killer.js"></script>

        <script>

            function noBack()
            {
                window.history.forward();
                callSell(trandingstockregister);
            }            
            function submitEdit(trandingstockregister)
            {
                if (checkDiv(trandingstockregister))
                {
                    document.forms[0].handle_id.value = "EditSubmit";
                    document.forms[0].action = '/PacsApplication/TradingStockRegisterServlet';
                    document.forms[0].submit();
                }
            }
            function getDetails(trandingstockregister)
            {
                if( document.forms[0].commoditytypeSearch.value == ""  )
                {
                    alert("Please enter commodity type.");
                    document.forms[0].commoditytypeSearch.focus();
                    return false;
                }
                if( document.forms[0].commoditySubtypeSearch.value == ""  )
                {
                    alert("Please enter commodity sub-type.");
                    document.forms[0].commoditySubtypeSearch.focus();
                    return false;
                }
                
                document.forms[0].handle_id.value = "editStock";
                document.forms[0].action = '/PacsApplication/TradingStockRegisterServlet';
                document.forms[0].submit();

            }
            function PrintBarcode(ind)
            {
                document.forms[0].handle_id.value = "PrintBarCode";
                document.forms[0].indicator.value = ind;
                document.forms[0].action = '/PacsApplication/TradingStockRegisterServlet';
                document.forms[0].submit();
            }
            function searchProduct(width, height, commoditytype,Subtype) 
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "tradingstockregisteredit.jsp";
                var lovKey = "editDetails"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?commoditytype=' + commoditytype + '&Subtype='+Subtype+ '&screenName=' + screenName + '&lovKey=' + lovKey, 'prodDetails', attr);
                popWin.focus();

            }

            function searchGodown(width, height, i) 
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "tradingstockregisteredit.jsp";
                var lovKey = "godownDetails"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?&screenName=' + screenName + '&lovKey=' + lovKey+ '&textIndex=' + i, 'godownDetails', attr);
                popWin.focus();

            }
            function SearchPurchaseOrder(width, height,i)
            {
                if (window.innerWidth) {
                    LeftPosition = (window.innerWidth - width) / 2;
                    TopPosition = ((window.innerHeight - height) / 2) - 20;
                }
                else {
                    LeftPosition = (parseInt(window.screen.width) - width) / 2;
                    TopPosition = ((parseInt(window.screen.height) - height) / 2) - 20;
                }
                attr = 'resizable=yes,scrollbars=yes,width=' + width + ',height=' +
                    height + ',screenX=300,screenY=200,left=' + LeftPosition + ',top=' +
                    TopPosition + '';
                var screenName = "tradingstockregisteredit.jsp";
                var lovKey = "purchaseDetails"
                popWin = open('/PacsApplication/CommonSearchInformationTradingLOV.jsp?&screenName=' + screenName + '&lovKey=' + lovKey+  '&textIndex=' + i,  'purchaseDetails', attr);
                popWin.focus();

            }

            function checkDiv(trandingstockregister)
            {
                var counter = document.forms[0].rowCounter.value; 
                
                for (var i = 1; i <= counter; i++) {
                    try{
                        var purchase_id = document.getElementById("purchase_id" + i).value;
                        var price_unit = document.getElementById("price_unit" + i).value;
                        var quantity = document.getElementById("quantity" + i).value;
                        var quantity_availed = document.getElementById("quantity_availed" + i).value;
                        var quantity_available = document.getElementById("quantity_available" + i).value;
                        var pfm = document.getElementById("pfm" + i).value;
                        var pfnm = document.getElementById("pfnm" + i).value;
                        var selectperish = document.getElementById("selectperish" + i).value;
                        var stkexpiryDate = document.getElementById("stkexpiryDate" + i).value;
                        var stockdesc = document.getElementById("stockdesc" + i).value;
                        var godown_id = document.getElementById("godown_id" + i).value;                        
                        
                        var sum = parseInt(quantity_available)+parseInt(quantity_availed);
                        
                        if (purchase_id == "" || price_unit == "" || quantity == "" || pfm == "" || pfnm == ""|| selectperish == "" || stockdesc == "" || godown_id == "" || quantity_availed =="" || quantity_available == "" ) 
                        {
                            alert("Fill the required fields.");
                            return false;
                        }
                        if (selectperish=="Y" && stkexpiryDate=="")
                        {
                            alert("Please enter Stock Expiry Date.");
                            return false;
                        }    
                        if ( sum != quantity ) 
                        {
                            alert("Quantity(Base) should be summation of Quantity(Availed) and Quantity(Available).");
                            return false;
                        }
                    }
                    catch(e){}
                    document.getElementById("price_unit" + i).value = parseFloat(price_unit).toFixed(2);
                }                
                return true;
            }
            function numbersonly(e){
                    var unicode=e.charCode? e.charCode : e.keyCode
                    if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
                            if (unicode<48||unicode>57) //if not a number
                                    return false //disable key press
                    }
            }

            function checkop()
            {                
                if (document.getElementById("checkOption").value == "checkStock")
                {
                    document.getElementById('checkStock').style.display = 'block';
                    document.getElementById('displayDiv').style.display = 'none';
                }
            }
            function Total(i) 
            {
                var priceDetails = document.getElementById("price" + i).value;
                var quantityDetails = document.getElementById("quantity" + i).value;

                document.getElementById("total" + i).value = priceDetails * quantityDetails;
            }
            function callSell(trandingstockregister) 
            {
                var counter = document.forms[0].rowCounter.value;
                
                for (var i = 1; i <= counter; i++) {    
                    var ppu1 = document.getElementById("price_unit" + i).value;
                    var pfM1 = document.getElementById("pfm" + i).value;
                    var pfNm1 = document.getElementById("pfnm" + i).value;
                    
                    var ppu = parseFloat(ppu1);
                    var pfM = parseFloat(pfM1);
                    var pfNm = parseFloat(pfNm1);
                    
                    var sellM = (((pfM*ppu)/100)+ppu);
                    var sellNm = (((pfNm*ppu)/100)+ppu);

                    document.getElementById("sellPriceM" + i).value = sellM.toFixed(2);
                    document.getElementById("sellPriceNm" + i).value = sellNm.toFixed(2);                    
            }    
            }
            function checkDate(i) 
            {
                var flag = document.getElementById("selectperish" + i).value;
                if(flag=="N"){
                   // document.getElementById("stkexpiryDate" + i).disabled = true;
                    document.getElementById("stkexpiryDate" + i).value = "";
                    document.getElementById("imgr").disabled = true;
                }
                if(flag=="Y"){
                 // document.getElementById("stkexpiryDate" + i).disabled = false;                    
                    document.getElementById("imgr").disabled = false;
                }
            }
        </script>
    </head>
    <body onload="noBack()">

        <%          int count = 1;
                    String error_msg = "";
                    Object error = request.getAttribute("message");
                    if (error != null) {
                        error_msg = error.toString();
                    }
        %>
        <%!
            String blankNull(String s) {
                return (s == null) ? "" : s;
            }
        %>

        <%
                    Object oTrandinStockRegisterBeanObj = request.getAttribute("oTrandinStockRegisterBean");
                    Object alTrandinStockRegisterBeanAppendObj = request.getAttribute("arrTrandinStockRegisterBean");

                    TrandinStockRegisterBean oTrandinStockRegisterBeanApend = new TrandinStockRegisterBean();
                    if (oTrandinStockRegisterBeanObj != null) {
                        oTrandinStockRegisterBeanApend = (TrandinStockRegisterBean) request.getAttribute("oTrandinStockRegisterBean");
                    }

                    ArrayList<TrandinStockRegisterBean> alTrandinStockRegisterBeanAppend = new ArrayList<TrandinStockRegisterBean>();
                    if (alTrandinStockRegisterBeanAppendObj != null) {
                        alTrandinStockRegisterBeanAppend = (ArrayList<TrandinStockRegisterBean>) request.getAttribute("arrTrandinStockRegisterBean");
                    }
        %>

        <%
                    String displayFlag = "";
                    Object display = request.getAttribute("displayFlag");
                    if (display != null) {
                        displayFlag = display.toString();
                    }
        %>

        <jsp:include page="MenuHead_TRADING.jsp" flush="true" />
        <br>
        <fieldset style="border-color: black;  background-image: url('/PacsApplication/img/download.jpg'); border-width: 3px">

            <legend style="padding: 8px; border-radius: 20px; background-color: #006600; color: white">
                Trading Stock Register
            </legend>

            <form id="trandingstockregister" name="trandingstockregister" method="post" action="TradingStockRegisterServlet">

                <%if (!error_msg.equalsIgnoreCase("")) {%>
                <center><div class="info" id="errorMessage"><center><%= error_msg%></center></div></center>
                <% }%>
                <br>

                <center><label style=" font-family: Berlin Sans FB; font-weight:  normal;">Operation Selection:</label>
                    <select id="checkOption" name="checkOption" onchange="checkop()" >
                        <option value="" disabled selected style="display:none;" <%if (blankNull(oTrandinStockRegisterBeanApend.getCheckOption()).equals("")) {%> selected <%}%>>--Select--</option>
                        <option value="checkStock" <%if (blankNull(oTrandinStockRegisterBeanApend.getCheckOption()).equals("checkStock")) {%> selected <%}%>>Edit Stock</option>
                        
                    </select>
                </center>                
                <br>
                <div id="checkStock" style="display: none;">

                    <center>
                        <table>
                            <tr>
                                <td>Enter commodity type:</td>
                                <td><input type="text" name="commoditytypeSearch" id="commoditytypeSearch" onkeypress="return numbersonly(event)" style="text-align:right;" /></td><td></td><td></td><td></td>
                                <td>Enter commodity sub-type:</td>
                                <td><input type="text" name="commoditySubtypeSearch" id="commoditySubtypeSearch" onkeypress="return numbersonly(event)" style="text-align:right;"/></td>
                                <td><input type="button"  value="Search" onclick="javascript:searchProduct(220, 180, document.trandingstockregister.commoditytypeSearch.value, document.trandingstockregister.commoditySubtypeSearch.value)" /></td>
                                <td><input type="button"  value="Submit" onclick="javascript:getDetails(trandingstockregister)" /></td>
                                <td><input type="button" value="Reset" onclick="ShowParent();" /></td>
                            </tr>
                        </table><br>
                        <br>
                    </center>
                </div>
                
                <%if (displayFlag.equalsIgnoreCase("Y")) {%>
                <div id="displayDiv">
                <center>    
                <div style="overflow:scroll; width: 1300px">
                    
                    <table class="NumbersOnly "id="order_list" style="overflow-y: scroll">
                        <thead  class="CSSTableGenerator" >
                            <tr>
                                <td style="text-align:center;">Commodity Type</td>
                                <td style="text-align:center;">Commodity Sub-Type</td>
                                <td style="text-align:center;">Vendor Name</td>
                                <td style="text-align:center;">Stock Entry Date</td>
                                <td style="text-align:center;">Perishable(Y/N)</td>
                                <td style="text-align:center;" colspan="2">Stock Expiry Date</td>
                                <td style="text-align:center;">Price/Unit</td>
                                <td style="text-align:center;">Quantity(Base)</td>
                                <td style="text-align:center;">Quantity(Availed)</td>
                                <td style="text-align:center;">Quantity(Available)</td>
                                <td style="text-align:center;">Profit Factor(Non-Member)</td>
                                <td style="text-align:center;">Sell Price(Non-Member)</td>
                                <td style="text-align:center;">Profit Factor(Member)</td>
                                <td style="text-align:center;">Sell Price(Member)</td>
                                <td style="text-align:center;">Purchase ID</td>
                                <td style="text-align:center;" colspan="2">Godown ID</td>
                                <td style="text-align:center;">Stock Desc</td>
                            </tr>
                        </thead>
                        <tbody style="background-color: white; font-size: 15px">
                            <%
                                oTrandinStockRegisterBeanApend = null;
                                oTrandinStockRegisterBeanApend = new TrandinStockRegisterBean();
                                count= 0;

                                for (int i = 0; i < alTrandinStockRegisterBeanAppend.size(); i++) {
                                    oTrandinStockRegisterBeanApend = alTrandinStockRegisterBeanAppend.get(i);
                                    count++;
                            %>
                            <tr>
                                <td><input readonly size="11" type="text" name="commoditytype<%=count%>" id="commoditytype<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getCommoditytype())%>"/></td>
                                <td><input readonly size="11" type="text" name="commoditysubtype<%=count%>" id="commoditysubtype<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getCommoditysubtype())%>"/></td>
                                <td><input readonly size="11" type="text" name="name<%=count%>" id="name<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getName())%>"/></td>
                                <td><input readonly size="10" style="text-align:center;" id="entDate<%=count%>" type="text" name="entDate<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getEntDate())%>"/></td>                                
                                <td><select style="width:100%"  id="selectperish<%=count%>" name="selectperish<%=count%>" onchange="checkDate(<%=count%>)" >
                                    <option value="Y" <%if (blankNull(oTrandinStockRegisterBeanApend.getSelectperish()).equals("Y")) {%> selected <%}%>>Yes</option>
                                    <option value="N" <%if (blankNull(oTrandinStockRegisterBeanApend.getSelectperish()).equals("N")) {%> selected <%}%>>No</option>
                                <td><input size="10" style="text-align:center;" id="stkexpiryDate<%=count%>" type="text" name="stkexpiryDate<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getStkexpiryDate())%>" onkeypress='return event.charCode >= 47 && event.charCode <= 57' /></td>
                                <td><a href="#" onclick="return ShowCalender(<%=count%>);"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="15" height="15" /></a></td>
                                <td><input size="11" type="text" name="price_unit<%=count%>" id="price_unit<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getPrice_unit())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' onmouseover="callSell(trandingstockregister)" onkeyup="callSell(trandingstockregister)"/></td>
                                <td><input size="11" type="text" name="quantity<%=count%>" id="quantity<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getQuantity())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' onmouseover="callSell(trandingstockregister)" onkeyup="callSell(trandingstockregister)"/></td>
                                <td><input size="11" type="text" name="quantity_availed<%=count%>" id="quantity_availed<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getQuantity_availed())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td><input size="11" type="text" name="quantity_available<%=count%>" id="quantity_available<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getQuantity_available())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td><input size="11" type="text" name="pfnm<%=count%>" id="pfnm<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getPfnm())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47' onmouseover="callSell(trandingstockregister)" onkeyup="callSell(trandingstockregister)"/></td>
                                <td><input readonly size="11" type="text" name="sellPriceNm<%=count%>" id="sellPriceNm<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getSellPriceNm())%>"/></td>
                                <td><input size="11" type="text" name="pfm<%=count%>" id="pfm<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getPfm())%>" onkeypress='return event.charCode >= 46 && event.charCode <= 57 && event.charCode != 47'  onmouseover="callSell(trandingstockregister)" onkeyup="callSell(trandingstockregister)"/></td>
                                <td><input readonly size="11" type="text" name="sellPriceM<%=count%>" id="sellPriceM<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getSellPriceM())%>"/></td>
                                <td><input readonly size="15" type="text" name="purchase_id<%=count%>" id="purchase_id<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getPurchase_id())%>"/></td>
                                <td><input size="15" type="text" name="godown_id<%=count%>" id="godown_id<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getGodown_id())%>" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /></td>
                                <td><input size="4" type="button" value="Search"  onclick="javascript:searchGodown(220, 180, <%=count%>)" /></td>                        
                                <td><input size="11" type="text" name="stockdesc<%=count%>" id="stockdesc<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getStockdesc())%>" onmouseover="callSell(trandingstockregister)"/></td>
                                <td><input type="hidden" name="stock_id<%=count%>" id="stock_id<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getStock_id())%>"></td>
                            </tr>
                            <%}%></tbody>
                    </table>
                </div>        
                            
                            <br><br>                            
                            <center>
                               <input type="button" value="Submit" onclick="javascript:submitEdit(trandingstockregister)"/> 
                               <input type="button" value="Reset" onclick="ShowParent();" /> 
                            </center>
                            <input type="hidden" name="indicator" id="indicator" value="">
                            <input type="hidden" name="rowCounter" id="rowCounter" value="<%=count%>">                            
                            <input type="hidden" name="qty<%=count%>" id="qty<%=count%>" value="<%=blankNull(oTrandinStockRegisterBeanApend.getQuantity())%>">
                            <input type="hidden" name="godownname<%=count%>" id="godownname<%=count%>" value="">
                </center>
                </div>
                <%}%>
                <input type="hidden" name="handle_id" value="" />
                <input type="hidden" name="vendor_id" id="vendor_id"/>                
            </form>
            <script>

                $("#addRow").click(function () 
                {
                    var counter = $("#rowCounter").val();
                    ++counter;
                    $('#order_list tr:last').after('<tr> <td align="center"><input type="checkbox" name="chckbox' + counter + '" id="chckbox' + counter + '" onclick="return checkboxTrue('+counter+')"/></td>\n\
                        <td><input size="8" type="text" id="purchaserefno' + counter + '" name="purchaserefno' + counter + '"/></td>\n\
                        <td style="display: none"><input size="8" type="button" value="Search"  onclick="javascript:SearchPurchaseOrder(720, 380,'+ counter +')" /></td>\n\\n\
                        <td><input size="11" type="text" id="commoditytype' + counter + '" name="commoditytype' + counter + '"/></td>\n\\n\
                        <td><input size="14" type="text" id="commoditysubtype' + counter + '" name="commoditysubtype' + counter + '"/></td>\n\
                        <td><input size="15" type="text" name="purchase_id' + counter + '" id="purchase_id' + counter + '"/></td>\n\
                        <td><input size="8" type="text" name="price_unit' + counter + '" id="price_unit' + counter + '"/></td>\n\
                        <td><input size="8" type="text" id="quantity' + counter + '" name="quantity' + counter + '"/></td>\n\
                        <td><input size="12" type="text" class="numberson" id="pfm' + counter + '" name="pfm' + counter + '"/></td>\n\
                        <td><input size="8" type="text" class="numberson" id="pfnm' + counter + '" name="pfnm' + counter + '"/></td>\n\
                        <td><select style="width:100%" id="selectperish' + counter + '" name="selectperish' + counter + '" onchange="checkDate('+ counter +')"><option value="N">No</option><option value="Y">Yes</option></select></td>\n\
                        <td><input size="8" type="text" id="stkexpiryDate' + counter + '" name="stkexpiryDate' + counter + '"/><a href="#" onclick="return ShowCalender('+counter+' );"><img src="${pageContext.request.contextPath}/img/calendar.jpg" name="imgr" border="0" width="15" height="15" /></a></td>\n\
                        <td><input size="10" type="text" id="stockdesc' + counter + '" name="stockdesc' + counter + '"/></td>\n\
                        <td><input size="15" type="text" name="godown_id' + counter + '" id="godown_id' + counter + '"/></td>\n\\n\
                        <td><input size="4" type="button" value="Search"  onclick="javascript:searchGodown(220, 180,'+ counter +')" /></td>\n\
                        <td style="display: none"><input size="8" type="text" id="godownname' + counter + '" name="godownname' + counter + '"/></td>\n\
                        <td style="display: none"><input type="hidden" name="stock_id' + counter + '" id="stock_id' + counter + '"/></td>\n\\n\
                        </tr>');
                        $("#rowCounter").val(counter);
                });

                $( "#deleteRow" ).click(function() 
                {
                    var len = ($("#order_list tr").length)-1;
                    var counter = $("#rowCounter").val();
                    var chkboxCounter=$("#chkboxCounter").val();
                    //alert(chkboxCounter);
                    counter=counter-chkboxCounter;
                    // alert(counter);
                    if (counter==0){

                        alert("All rows cannot be deleted");
                    }
                    else{

                        if (len ==chkboxCounter) {
                            alert("All rows can not be deleted");
                            return false;
                        }

                        $('input:checkbox:checked').closest('tr').remove();
                        chkboxCounter=0;
                        $("#chkboxCounter").val(chkboxCounter);
                    }
                });
                function checkboxTrue(i)
                {
                    if(document.getElementById("chckbox"+i).checked==true){

                        var counter = $("#chkboxCounter").val();
                        counter++;
                        $("#chkboxCounter").val(counter);
                    }
                    else{

                        var counter = $("#chkboxCounter").val();
                        counter--;
                        $("#chkboxCounter").val(counter);
                    }
                }
                function ShowCalender(i) 
                {
                    getCalendar(document.getElementById("stkexpiryDate" + i));
                }
                function ShowParent()
                {
                    document.forms[0].action = "${pageContext.request.contextPath}/Trading_JSP/TradingStockRegisterEdit.jsp";
                    document.forms[0].submit();
                }

            </script>
        </fieldset>
    </body>
     <script>

                $('table.NumbersOnly').on('keydown','.numberson', function(event) {
        if (event.shiftKey == true) {
            event.preventDefault();
        }

        if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8  || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 46 || event.keyCode == 190 || event.keyCode == 110) {

        } else {
            event.preventDefault();
        }
        if($(this).val().indexOf('.') !== -1 && (event.keyCode == 190 || event.keyCode == 110))
        { event.preventDefault();}
    });
            </script>
</html>
<% 	} catch (Exception e) {
                
            }
%>
