<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FinIQ_Product_Master.aspx.vb" Inherits="FinIQWebApp.FinIQ_Product_Master" MasterPageFile="~/FiniqAppMasterPage.Master" Title="Product Master" MaintainScrollPositionOnPostback="true" %>



<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
    <style type="text/css">
        .tdbrk {
            width: 5px;
        }

        .button {
            Width: 100px;
        }

        .upperdiv {
            padding-top: 6px;
            padding-left: 5px;
            border: none;
        }

        .lowerdiv {
            padding-top: 10px;
        }

        .gridCol {
            width: 160px;
            /*overflow-wrap: break-word !important;
            white-space: pre-wrap !important;*/
            word-wrap: break-word !important;
            white-space: inherit !important;
        }

        .gridCol1 {
            width: 100px;
        }

        .divLoading {
            position: absolute;
            left: 430px;
            top: 60px;
        }

        .auto-style1 {
            width: 94px;
        }

        .EditColWidth {
            min-width: 150px !important;
            max-width: 150px !important;
        }

        /*Added by Bhagyashri B 07-01-2020*/
        .width_8_char {
            width: 8ch;
            max-width: 8ch;
        }

        .width_16_char {
            width: 16ch;
            max-width: 16ch;
        }

        .width_24_char {
            width: 24ch;
            max-width: 24ch;
        }

        .width_32_char {
            width: 32ch;
            max-width: 32ch;
        }

        .width_64_char {
            width: 64ch;
            max-width: 64ch !important;
        }

        .width_40_char {
            width: 40ch;
            max-width: 40ch;
        }

        .width_12_char {
            width: 12ch;
            max-width: 12ch;
        }
        /*End By bhagyashri B*/

        .GridHeader {
            background-color: #ededed !important;
        }
    </style>

    <script type="text/javascript">

        function checkChanged(current) {
            var GridView = current.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");
            var chkAll = document.getElementById("ctl00_MainContent_gvProdMst_ctl01_chkAll");
            var count = 0;
            var checked = 0;
            for (var i = 0; i < inputList.length; i++) {
                if (inputList[i] != chkAll) {
                    if (inputList[i].type == "checkbox") {
                        count = count + 1
                    }
                }
            }
            for (var i = 0; i < inputList.length; i++) {
                if (inputList[i] != chkAll) {
                    if (inputList[i].type == "checkbox") {
                        if (inputList[i].checked) {
                            checked = checked + 1
                        }
                    }
                }
            }
            if (checked = count) {
                $("#ctl00_MainContent_gvProdMst_ctl01_chkAll").prop("checked", true);
            }
            for (var i = 0; i < inputList.length; i++) {

                //var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox") {
                    if (!inputList[i].checked) {
                        $("#ctl00_MainContent_gvProdMst_ctl01_chkAll").prop("checked", false);
                    }
                }
            }
        }
        function checkAll() {
            var chkAll = document.getElementById("ctl00_MainContent_gvProdMst_ctl01_chkAll");
            var GridView = chkAll.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");

            //alert(inputList.length);
            for (var i = 0; i < inputList.length; i++) {

                //var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox" && chkAll != inputList[i]) {
                    if (chkAll.checked) {
                        inputList[i].checked = true;
                    }
                    else {
                        inputList[i].checked = false;
                    }
                }
            }
        }
        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : evt.keyCode;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }

        //Added by Tejaswini On 23-Jan-2019 to restrict . for Product Code and Product Name
        function isKeyDot(evt) {
            var keycode = evt.charCode || evt.keyCode;
            if (keycode == 46) {
                return false;
            }
        }
        //END by Tejaswini

        //function Check_Click(CheckboxRow) {

        //    var row = CheckboxRow.parentNode.parentNode;

        //    var GridView = row.parentNode;

        //    //Get all input elements in Gridview
        //    var inputList = GridView.getElementsByTagName("input");

        //    for (var i = 0; i < inputList.length; i++) {

        //        var headerCheckBox = inputList[0];

        //        var checked = true;
        //        if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {
        //            if (!inputList[i].checked) {
        //                checked = false;
        //                break;
        //            }
        //        }
        //    }
        //    headerCheckBox.checked = checked;
        //}

    </script>

    <%--Added by Bhagyashri B 15-01-2020 BNPINT-269, for session id--%>
    <asp:HiddenField ID="hdnUCPSessionID" runat="server" Value="0" />

    <div class="upperdiv" id="TopContainer">

        <table id="tbMain" runat="server" style="border-spacing: 5px 10px; border-collapse: separate;">
            <tr>
                <td style="text-align: left;">
                    <asp:Label ID="lblProductName" runat="server" CssClass="lbl" Text="Product"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtbxSrchModule" runat="server" onfocus="this.select();" onmouseup="return false;" AutoPostBack="true" Style="width: 62ch;"></asp:TextBox>
                </td>
                <td colspan="2"></td>
                <%--<td class="constantWidth">
                            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="Updatebondblotterpanel"
                               DisplayAfter="0">
                                <ProgressTemplate>                  
                                    <div class="divLoading" >                   
                                        <img alt="Loading" src="../App_Resources/loading.gif" /><span class="lbl">&nbsp;&nbsp;</span>
                                    </div>         
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </td>--%>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnLoad" runat="server" CssClass="btn button" Text="Load" Style="margin-right: 5px;" />
                </td>
                <td>
                    <asp:Button class="btn button" ID="btnRefresh" runat="server" Text="Refresh" Style="margin-right: 7px;" />
                    <%--Visible by TwinkleC 17-01-2020, as per discussion with Hemlata A, BNPINT-269--%>
                    <asp:Button class="btn button" ID="btnNew" runat="server" Text="New" Style="margin-right: 7px;" />
                    <asp:Button class="btn button" ID="btnDelete" runat="server" Text="Delete" Style="margin-right: 7px;" />
                    <asp:Button class="btn button" ID="btnSave" runat="server" Text="Save" Style="margin-right: 7px;" Visible="false" />
                    <asp:Button ID="btnExport" runat="server" CssClass="btn button" Text="Export" Style="margin-right: 7px;" />
                    <%--Hidden by Bhagyashri B 15-01-2020, as per discussion with Hemlata A, BNPINT-269--%>
                    <%--<asp:Button class="btn button" ID="btnCancel" runat="server" Text="Cancel" />--%>
                </td>
                <td>
                    <asp:Label ID="Label2" runat="server" Style="padding-left: 5px;">Row(s) Per Page</asp:Label>
                    <asp:TextBox ID="txtRowsPerPage" Text="99" AutoPostBack="true" runat="server" onfocus="this.select();" onmouseup="return false;" MaxLength="3" Style="width: 35px; text-align: right;" CssClass="txt" onkeypress="return isNumberKey(event)"></asp:TextBox>
                    <asp:Label ID="lblRowCount" runat="server" CssClass="lbl" Style="padding-left: 10px;">Total Record(s): </asp:Label>
                    <asp:Label ID="lblTotRecord" runat="server" CssClass="lbl" Style="padding-right: 10px;"></asp:Label>
                    &nbsp;&nbsp;
                </td>
                <td>

                    <asp:CheckBox ID="chk_ShowColumns" runat="server" AutoPostBack="true"></asp:CheckBox>
                    <asp:Label ID="lblShowColumns" runat="server" CssClass="lbl" Text="Show hidden columns"></asp:Label>

                </td>
                <td>
                    <asp:Label ID="lblErrorMsg" runat="server" CssClass="lblerror" />
                    <asp:Label ID="lblError" runat="server" CssClass="lblerror" />
                </td>
            </tr>
        </table>
    </div>
    <div class="lowerdiv">
        <table id="Table1" runat="server" style="margin-left: 7px;">
            <tr>
                <td>
                    <asp:HiddenField ID="hdnSProductId" runat="server" Value="0" />
                    <asp:GridView ID="gvProdMst" runat="server" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found" BorderWidth="1"
                        rules="All" ShowHeader="true" AllowPaging="True" PageSize="20" PagerStyle-Height="32px"
                        AutoGenerateColumns="false" HeaderStyle-CssClass="GridHeaderTitle" Width="100%"
                        CssClass="Grid" CellPadding="0" RowHeadersWidthSizeMode="DisableResizing;" SelectedRowStyle-Wrap="false"
                        CellSpacing="0">

                        <SelectedRowStyle CssClass="GridItemSelect" />
                        <RowStyle CssClass="GridItem" Wrap="true" />
                        <HeaderStyle CssClass="GridHeader" />
                        <FooterStyle CssClass="GridFooter" />
                        <PagerStyle CssClass="GridPager" />

                        <PagerSettings Mode="NumericFirstLast"
                            FirstPageText="First"
                            LastPageText="Last"
                            Position="Bottom" />

                        <EmptyDataTemplate>
                            <asp:Label ID="lbldatagrid" runat="server" CssClass="lbl" Text="No data found."></asp:Label>
                        </EmptyDataTemplate>
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <asp:CheckBox ID="chkAll" runat="server" AutoPostBack="true" OnCheckedChanged="buttoncheck" onclick="checkAll();" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckboxRow" runat="server" AutoPostBack="true" OnCheckedChanged="buttoncheck" onclick="checkChanged(this);"></asp:CheckBox>
                                </ItemTemplate>
                                <HeaderStyle Wrap="true" HorizontalAlign="Center" VerticalAlign="Middle" />
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="false" />
                            </asp:TemplateField>

                            <asp:CommandField ButtonType="Link" ShowEditButton="true" CancelText="Cancel" UpdateText="Update"
                                EditText="Edit" ItemStyle-CssClass="width_16_char" HeaderStyle-CssClass="width_16_char" ItemStyle-HorizontalAlign="Center"
                                HeaderStyle-HorizontalAlign="Center"></asp:CommandField>

                            <asp:TemplateField HeaderText="Id">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" CssClass="gridCol width_8_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="right" Wrap="false" CssClass="gridCol width_8_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblProductId" CssClass="width_8_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.ProductId").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Code" ItemStyle-CssClass="EditColWidth" HeaderStyle-CssClass="EditColWidth">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" CssClass="gridCol width_16_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" Wrap="false" CssClass="gridCol width_16_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblProductCode" CssClass="width_16_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.ProductCode").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtProductCode" MaxLength="20" CssClass="width_16_char" runat="server" onfocus="this.select();" onmouseup="return false;" onkeypress="return isKeyDot(event)" Text='<%# (DataBinder.Eval(Container, "DataItem.ProductCode"))%>'>
                                    </asp:TextBox>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Name" ItemStyle-CssClass="EditColWidth" HeaderStyle-CssClass="EditColWidth">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" CssClass="gridCol width_24_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" Wrap="false" CssClass="gridCol width_24_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblProductName" CssClass="width_24_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.ProductName").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtProductName" MaxLength="50" CssClass="txt width_24_char" runat="server" onfocus="this.select();" onmouseup="return false;" onkeypress="return isKeyDot(event)" Text='<%# (DataBinder.Eval(Container, "DataItem.ProductName"))%>' />
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Internal Product Class" Visible ="false"><%--Visible ="false" --%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="true" CssClass="gridCol width_16_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" Wrap="false" CssClass="gridCol width_16_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblInternalProductClass" CssClass="lbl width_16_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.InternalProductClass").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlInternalProductClass" CssClass="ddl width_16_char" runat="server" AutoPostBack="true">
                                    </asp:DropDownList>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <%--product_group - Added by Ashwini P on 15-Sept-2020 LGTC21INT-3--%>
                            <asp:TemplateField HeaderText="Product Group" ItemStyle-CssClass="EditColWidth" HeaderStyle-CssClass="EditColWidth" Visible ="false">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" CssClass="gridCol width_16_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" Wrap="false" CssClass="gridCol width_16_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblProductGroup" CssClass="width_16_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.ProductGroup").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtProductGroup" MaxLength="20" CssClass="width_16_char" runat="server" onfocus="this.select();" onmouseup="return false;" onkeypress="return isKeyDot(event)" Text='<%# (DataBinder.Eval(Container, "DataItem.ProductGroup"))%>'>
                                    </asp:TextBox>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Customer Exclude Include" Visible ="false"><%----%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" CssClass="gridCol width_16_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center" Wrap="false" CssClass="gridCol width_12_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblCustomerExcludeInclude" CssClass="lbl width_8_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.CustomerExcludeInclude").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlCustomerExcludeInclude" CssClass="ddl width_12_char" runat="server" AutoPostBack="true">
                                    </asp:DropDownList>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <%--Updated by Bhagyashri B 14-01-2020 BNPINT-269 to update header name and add ddl instead of textbox in edit item--%>
                            <asp:TemplateField HeaderText="Document Type" Visible ="false"><%--Visible ="false" --%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" CssClass="gridCol width_16_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center" Wrap="false" CssClass="gridCol width_12_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblProductDocumentType" CssClass="width_8_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.ProductDocumentType").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlDocumentType" CssClass="ddl width_12_char" runat="server" AutoPostBack="true"></asp:DropDownList>
                                    <%--<asp:TextBox ID="txtProductDocumentType" CssClass="txt width_16_char" runat="server" onfocus="this.select();" onmouseup="return false;" Text='<%# (DataBinder.Eval(Container, "DataItem.ProductDocumentType"))%>' />--%>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Embedded Control" Visible ="false"><%--Visible ="false" --%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" CssClass="gridCol"></HeaderStyle>
                                <%--width_8_char--%>
                                <ItemStyle HorizontalAlign="Center" Wrap="false" CssClass="gridCol width_8_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblTradableProduct" CssClass="width_8_char" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.TradableProduct").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlTradableProduct" CssClass="ddl width_8_char" runat="server" AutoPostBack="true">
                                        <asp:ListItem>Y</asp:ListItem>
                                        <asp:ListItem>N</asp:ListItem>
                                    </asp:DropDownList>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Visibility Map" Visible ="false"><%--Visible ="false" --%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" CssClass="gridCol width_40_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" CssClass="width_40_char" />
                                <ItemTemplate>
                                    <%--Fixed width by Saurabh Kulkarni for long Strings on 02-Nov-2018 --%>
                                    <asp:Label ID="lblVisibilityBitMap" CssClass="lbl gridCol width_40_char" runat="server" Style="text-align: left" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.VisibilityBitMap").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="lnk_VisibilityBitMap" runat="server" CssClass="lbl gridCol width_40_char" Text='<%#Eval("VisibilityBitMap")%>' OnClick="lnk_TabClick"></asp:LinkButton>
                                </EditItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Mapped User Groups" Visible ="false"><%--Visible ="false" --%>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="True" CssClass="gridCol width_64_char"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left" Wrap="True" CssClass="width_64_char" />
                                <ItemTemplate>
                                    <asp:Label ID="lblMappedUserGroups" CssClass="lbl gridCol width_64_char" Style="text-align: left;" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.MappedUserGroups").ToString)%>'>
                                    </asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="lnk_MappedUserGroups" Style="text-align: left" runat="server" CssClass="lbl gridCol width_64_char" Text='<%#Eval("MappedUserGroups")%>' OnClick="lnk_TabClick"></asp:LinkButton>
                                </EditItemTemplate>
                            </asp:TemplateField>


                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    <div id="dialog_Confirm" title="Conformation-box" style="overflow: hidden; display: none; width: 250px; height: 800px;">
        <iframe id="iFrame_Reconfirm" style="overflow: auto; height: 100%; border: 0px;"></iframe>
    </div>
    <script>
        var confo
        function Confirm(title, id) {
            
            var pos = document.getElementById(id).getBoundingClientRect();      //Added by Bhagyashri B 15-01-2020 BNPINT-269
            confo = $("#dialog_Confirm").dialog({
                title: title,
                modal: true,
                autoOpen: true,
                width: 250,
                height: 800,
                position: [0, 0],                                               //Added by Bhagyashri B 15-01-2020 BNPINT-269
                resizable: false,
                close: function () {
                }
            });
            document.getElementById('dialog_Confirm').parentNode.setAttribute("style", "top: " + pos.y + "px; left: " + pos.x + "px;");     //Added by Bhagyashri B 15-01-2020 BNPINT-269
            $("#iFrame_Reconfirm").prop("src", "LayoutDesignControls/FrmAllTabNameList.aspx?sessionId=" + document.getElementById('<%=hdnUCPSessionID.ClientID%>').value);
            confo.dialog('open');
        }
        function applyTabs() {
            __doPostBack('btnTabApply', 'OnClick');
        };
        function closeDia() {
            applyTabs();
            $("#dialog_Confirm").dialog("close");
        }
    </script>
</asp:Content>
