<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FinIQ_MPG_ButtonMaster.aspx.vb" Inherits="FinIQWebApp.FinIQ_MPG_ButtonMaster" MasterPageFile="~/FiniqAppMasterPage.Master" Title="MPG Button Master " %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy11" runat="server">
    </asp:ScriptManagerProxy>
    <script src="../FinIQJS/SortFilter_Grid.js"></script>
    <style type="text/css">
        /*.fieldset
        {
            width: 300px;
        }*/


        .Visible {
            display: block;
        }

        .invisible {
            display: none;
        }

        .btnGroupbox {
            width: 65px;
        }
        /*Added By: Tejas V. Bodas on 20/09/2017 to make word wrap*/
        .wrapcol {
            overflow-wrap: break-word;
            white-space: normal;
        }
        /*Added By: Tejas V. Bodas on 28/08/2017 to display usergroupbox at correct position on screen*/
        @media only screen and (min-width: 800px) {

            .groupBoxGrids {
                position: absolute !important;
                background-color: inherit; /*Changed by Pratik S for theme changes || 29-Sept-2021*/
                /*left: 50%;
                top: 20%;*/
                height: 305px !important;
                width: 404px !important;
                border: 1px solid #dddddd;
                /*display: none;*/
            }
        }

        @media only screen and (min-width: 1368px) {

            .groupBoxGrids {
                position: absolute !important;
                 background-color: inherit; /*Changed by Pratik S for theme changes || 29-Sept-2021*/
                /*left:41%;
                top: 17%;*/
                height: 305px !important;
                width: 404px !important;
                border: 1px solid #dddddd;
                /*display: none;*/
            }
        }

        @media only screen and (min-width: 1920px) {

            .groupBoxGrids {
                position: absolute !important;
                 background-color: inherit; /*Changed by Pratik S for theme changes || 29-Sept-2021*/
                /*left:35%;
                top: 13%;*/
                height: 305px !important;
                width: 404px !important;
                border: 1px solid #dddddd;
                /*display: none;*/
            }
        }

        /*End*/

        .btnCommon {
            width: 90px;
        }

        .InnerTable {
            margin-left: -4px;
            width: 100% !important;
        }

        .MainFieldSet {
            width: 90% !important;
            border: none !important;
        }
        /*.GridContainerTab
        {
            width: 464px;
            overflow-y: auto !important;
        }*/
        .GridContainerTD {
            width: 379px;
            height: 255px;
            overflow-y: auto !important;
        }

        .constantWidth {
            width: 5px;
        }

        .Gridview {
            /*table-layout:fixed;*/
            /*width:100%;*/
        }

        .txtUsername {
            width: 208px;
        }

        .btnClose {
            width: 30px;
        }

        .ActiveN {
            background-color: #F7F7F7;
        }

        .divLoading {
            position: absolute;
            top: 48px;
            left: 460px;
        }

        .aspNetDisabled a {
            color: #000000 !important;
        }
        /*Added By: Tejas V. Bodas on 23/08/2017 to add entity label and dropdown*/
        .tdlbl {
            width: 200px;
        }

        .tddrop {
            width: 200px;
        }

        .BlotterCodeDiv {
            float: left;
        }

        .txtBtnCode {
            /*margin-right:6px;*/
        }

        .lblwidth {
            width: 79px;
        }

        .ddlWidth {
            width: 125px;
        }
        /*End*/

        .width1 {
            min-width: 120px;
            max-width: 120px;
        }
    </style>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanelCP"
        DisplayAfter="0">
        <ProgressTemplate>
            <div class="divLoading">
                <img alt="Loading" src="../App_Resources/loading.gif" /><span class="lbl">Loading...&nbsp;&nbsp;</span>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanelCP" runat="server" class="PanelPad">
        <ContentTemplate>
            <table>
                <tr>
                   <td class="lblBlotterPaddingRight">
                        <asp:Label ID="lblError" runat="server" CssClass="lblError"></asp:Label></td> 
                </tr>
            </table>
            <table style="padding-bottom: 10px;">
                <tr>

                    <td class="lblBlotterPaddingRight">
                        <asp:Label runat="server" ID="Label1" Text="Entity Name" Width="74px" />
                    </td>
                    <td class="ctlBlotterPaddingRight ">
                        <asp:DropDownList ID="ddlentity" runat="server" CssClass="ddl" Width="120px" AutoPostBack="true" />
                    </td>
                    <td>
                        <asp:Button ID="BtnLoad" runat="server" Text="Load" CssClass="btn btnCommon" />

                    </td>
                    <%--<td class="constantWidth"></td>--%>
                    <td>
                        <asp:Button ID="BtnAdd" runat="server" Text="Add" CssClass="btn btnCommon" />

                    </td>
                    <%--<td class="constantWidth"></td>--%>
                    <%-- <td>
                <asp:Button ID="BtnDelete" runat="server" Text="Delete" CssClass="btn btnCommon" /></td>--%>

                    <%-- <td class="constantWidth"></td>--%>
                    <td>
                        <asp:Button ID="BtnSave" runat="server" Text="Save" CssClass="btn btnCommon" /></td>
                    <%--<td class="constantWidth"></td>--%>
                    <td style="width: 110px">
                        <asp:Label ID="lblsearchbtncaption" Text="Button Caption :" runat="server" Style="padding-left: 5px;" />
                        <%--Added by Nikhil Mali on 30-01-2020--%>
                    </td>
                    <td>
                        <asp:TextBox ID="txtbtncaption" onkeyup="getenterload()" onkeypress="allowAlphaSpace(event)" AutoPostBack="false" runat="server" Width="121px" />
                        <%--Added by Nikhil Mali on 30-01-2020--%>
                    </td>
                    <td class="lblBlotterPaddingRight">
                        <asp:Label ID="lblTotalRecords" runat="server" Text="Total Record(s):" /></td>
                    <td class="ctlBlotterPaddingRight ">
                        <asp:Label ID="lblCount" runat="server" /></td>
                  
                </tr>


            </table>

            <table style="padding-bottom: 10px;">
                <tr>

                    <td>
                        <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                   <ContentTemplate>--%>
                        <asp:GridView ID="dgvButtonMst" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                            BorderStyle="Solid" BorderWidth="1px" CellPadding="3" CssClass="Grid Gridview" AllowPaging="true" PageSize="20" ShowHeaderWhenEmpty="true">
                            <SelectedRowStyle CssClass="GridItemSelect" />
                            <RowStyle CssClass="GridItem" />
                            <HeaderStyle CssClass="GridHeader" />
                            <FooterStyle CssClass="GridFooter" />
                            <%--Added BY: Tejas V. Bodas on 28/08/2017 to add paging--%>
                            <PagerSettings Mode="NumericFirstLast"
                                FirstPageText="First"
                                LastPageText="Last"
                                Position="Bottom" />
                            <PagerStyle CssClass="GridPager" />
                            <EmptyDataTemplate>
                                <asp:Label ID="lblqueuedatagrid" runat="server" Text="No data found."></asp:Label>
                            </EmptyDataTemplate>
                            <Columns>
                                <%--  <asp:TemplateField> 
                                    <ItemStyle width="20px" /> 
                                        <HeaderStyle width="20px"   />
                                            <ItemTemplate>  
                                                <asp:CheckBox ID="CheckboxRow" runat="server" AutoPostBack="true" ></asp:CheckBox>  
                                            </ItemTemplate>  
                                </asp:TemplateField> --%>

                                <asp:CommandField ButtonType="Link" ShowEditButton="true" CancelText="Cancel" UpdateText=""
                                    EditText="Edit" ItemStyle-Width="40px" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center"
                                    HeaderStyle-HorizontalAlign="Center"></asp:CommandField>



                                <%--<asp:TemplateField  HeaderText="Button ID" Visible="True" ControlStyle-Width="110">
                                    <HeaderStyle Width="120px" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblID"  runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Id").ToString)%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                         <asp:Label ID="lblID1"  runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Id").ToString)%>' />
                                     </EditItemTemplate>
                                </asp:TemplateField>--%>

                                <asp:TemplateField HeaderText="Button ID" Visible="True" ControlStyle-Width="40">
                                    <HeaderStyle Width="50px" Wrap="true" />
                                    <ItemStyle Wrap="true" Width="50px" HorizontalAlign="Right" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblID" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Id").ToString)%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:Label ID="lblID1" runat="server" CssClass="lbl" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Id").ToString)%>'></asp:Label>
                                    </EditItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Button Code" Visible="True" ControlStyle-Width="150">
                                    <HeaderStyle Width="150px" Wrap="true" />
                                    <ItemStyle Wrap="true" Width="150px" HorizontalAlign="left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblButtonCode" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Code").ToString)%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtButtonCode" runat="server" MaxLength="6" CssClass="txt txtBtnCode" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Code").ToString)%>' OnKeyPress=" return AllowCapsAlpha(this)"></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Button Caption" Visible="True" ControlStyle-Width="150">
                                    <HeaderStyle Width="150px" Wrap="true" />
                                    <ItemStyle Wrap="true" Width="150px" HorizontalAlign="left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblButtonCaption" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Caption").ToString)%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtButtonCaption" runat="server" CssClass="txt" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Button_Caption").ToString)%>' OnKeyPress=" return AllowAlphaNumeric(this)"></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Display Priority" Visible="True" ControlStyle-Width="40">
                                    <HeaderStyle Width="40px" Wrap="true" />
                                    <ItemStyle Wrap="true" Width="40px" HorizontalAlign="right" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblDisplayPriority" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Display_Priority").ToString)%>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtDisplayPriority" runat="server" CssClass="txt" Style="text-align: right;" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Display_Priority").ToString)%>' OnKeyPress=" return AllowNumericOnly(this)"></asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="User Group Access Permission" ControlStyle-Width="290">
                                    <HeaderStyle Width="290" Wrap="true" />
                                    <ItemStyle Wrap="true" Width="290" HorizontalAlign="left" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblUsrGrp" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.UserPermission").ToString)%>'>
                                        </asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtUsrGrp" CssClass="txt" Width="290" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.UserPermission").ToString)%>'>
                                        </asp:TextBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Active YN" ControlStyle-Width="30">
                                    <HeaderStyle Wrap="true" Width="40px"></HeaderStyle>
                                    <ItemStyle Wrap="true" Width="40px" HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkActiveYN" CssClass="chk" AutoPostBack="true" runat="server" OnCheckedChanged="chkActiveYN_CheckedChanged"></asp:CheckBox>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:CheckBox ID="chkActiveYN" CssClass="chk" AutoPostBack="true" runat="server" OnCheckedChanged="chkActiveYN_CheckedChanged"></asp:CheckBox>
                                    </EditItemTemplate>
                                </asp:TemplateField>


                            </Columns>
                        </asp:GridView>

                        <%--</ContentTemplate>

    </asp:UpdatePanel>--%>
                    </td>
                </tr>

            </table>


            <asp:Panel ID="grpUsergroup" runat="server" CssClass="groupBoxGrids invisible">
                <fieldset class="MainFieldSet">
                    <table>
                        <tr>
                            <td style="display: none;">
                                <asp:TextBox ID="txtUsername" CssClass="txt txtUsername" runat="server" Text="" onkeydown="return EnterEvent(event)"></asp:TextBox>
                            </td>
                            <td>
                                <asp:Button ID="btnLoadGrp" CssClass="btn btnGroupbox" runat="server" Text="Load" />
                            </td>
                            <td>
                                <asp:Button ID="btnSaveGrp" CssClass="btn btnGroupbox" runat="server" Text="Save" />
                            </td>
                            <td>
                                <asp:Button ID="btnCloseGrp" runat="server" Text="X" CssClass="btn btnClose" />
                            </td>

                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>
                                <div class="GridContainerTD">
                                    <asp:GridView ID="dgvUser" runat="server" AllowSorting="True"
                                        AutoGenerateColumns="false" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
                                        CssClass="Grid" Width="361px" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found">
                                        <HeaderStyle CssClass="GridHeader" />
                                        <RowStyle CssClass="GridItem" />
                                        <PagerStyle CssClass="GridPager" />

                                        <Columns>
                                            <asp:TemplateField HeaderStyle-Wrap="true">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkbox_UserQGrp" runat="server"></asp:CheckBox>
                                                </ItemTemplate>
                                                <HeaderStyle Wrap="true" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="false" />
                                            </asp:TemplateField>

                                            <asp:TemplateField HeaderText="User ID">
                                                <HeaderStyle></HeaderStyle>
                                                <ItemStyle></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblusrId" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.U_ID").ToString)%>' />
                                                </ItemTemplate>
                                            </asp:TemplateField>

                                            <asp:TemplateField HeaderText="User Name">
                                                <HeaderStyle></HeaderStyle>
                                                <ItemStyle></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblusr" CssClass="lbl wrapcol" runat="server" Text='<%# Microsoft.Security.Application.Encoder.HtmlEncode(DataBinder.Eval(Container, "DataItem.Name").ToString)%>' />
                                                </ItemTemplate>
                                            </asp:TemplateField>

                                        </Columns>
                                    </asp:GridView>
                                </div>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </asp:Panel>
            <asp:Button ID="ButtonIDUserMapping" CssClass="btn invisible" runat="server" Text="" />
            <asp:HiddenField ID="hdnActiveYNCheckMode" runat="server" value="0" EnableViewState="true" />           
            <asp:HiddenField ID="hdnEditableMode" runat="server" value="0" EnableViewState="true" />
            <asp:HiddenField ID="hdnAddButtonMode" runat="server" value="0" EnableViewState="true" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <script type="text/javascript">
        //<START>---Added By Shubham Podhade on 27-Jan-2019 for JS Sorting Searching Filters
        //$(document).ready(function () {
        //    debugger;
        //    SetSorting_Filter1();
        //});
        //<END>---Added By Shubham Podhade on 27-Jan-2019 for JS Sorting Searching Filters


        function displayUserBox(RowP) {

            $('#<%=ButtonIDUserMapping.ClientID%>').click();

        }

        //Added By: Tejas V. Bodas on 28/09/2017 to get location of dynamic element
        function getPosition(ctrl) {
            //alert(ctrl);
            var txtbox = document.getElementById(ctrl);
            var p = GetScreenCordinates(txtbox);
            var left = p.x - 400;
            var top = p.y;
            //alert("X:" + p.x + " Y:" + p.y);
            $('.groupBoxGrids').css('top', top);
            $('.groupBoxGrids').css('left', left);
        }
        //Added By: Tejas V. Bodas on 28/09/2017 to get location of dynamic element
        function GetScreenCordinates(obj) {
            var p = {};
            p.x = obj.offsetLeft;
            p.y = obj.offsetTop;
            while (obj.offsetParent) {
                p.x = p.x + obj.offsetParent.offsetLeft;
                p.y = p.y + obj.offsetParent.offsetTop;
                if (obj == document.getElementsByTagName("body")[0]) {
                    break;
                }
                else {
                    obj = obj.offsetParent;
                }
            }
            return p;
        }

        function AllowCapsAlpha(e) {
            var keycode;
            var i;
            if (window.event)
                keycode = window.event.keyCode;
            else if (event)
                keycode = event.keyCode;
            else if (e)
                keycode = e.which;
            else return true;
            for (i = 0 ; i < 6; i++) {
                if ((keycode > 64 && keycode < 91)) {
                    return true;
                }
                else {
                    return false;
                }
            }
            return true;
        }

        function AllowAlphaNumeric(e) {
            var keycode;
            if (window.event)
                keycode = window.event.keyCode;
            else if (event)
                keycode = event.keyCode;
            else if (e)
                keycode = e.which;
            else return true;

            if ((keycode > 47 && keycode < 58) || (keycode > 64 && keycode < 91) || (keycode > 96 && keycode < 123) || (keycode = 32)) {
                return true;
            }
            else {
                return false;
            }
            return true;
        }

        function EnterEvent(e) {
            //alert(e.keyCode)
            if (e.keyCode == 13 || e.keyCode == 9) {
                document.getElementById('<%=btnLoadGrp.ClientID%>').click();
        }
    }

    function getenterload() {             //Added by Nikhil Mali on 30-01-2020
        if (event.keyCode == 13)// Enter
        {
            document.getElementById('ctl00_MainContent_BtnLoad').click();
        }
    }

    function allowAlphaSpace(e) {                          // Added By Nikhil Mali on 30-1-2020
        var code = ('charCode' in e) ? e.charCode : e.keyCode;
        if (!(code == 32) &&               // space
          !(code == 45) &&                 // '-' symbol
          !(code > 64 && code < 91) &&     // upper alpha (A-Z)
          !(code > 96 && code < 123)) {    // lower alpha (a-z)
            //!(code > 47 && code < 58) && // numeric (0-9)
            e.preventDefault();
        }
    }

    </script>


</asp:Content>
