<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/FiniqAppMasterPage.Master"
    CodeBehind="ConfigSettingMaster.aspx.vb" Inherits="FinIQWebApp.FiniQ_ConfigSettingMaster"
    Title="Config Setting Master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy21" runat="server">
        <%-- <Scripts>
            <asp:ScriptReference Path="~/FinIQJS/FixFocus.js" />
        </Scripts>--%>
    </asp:ScriptManagerProxy>
    <%--Start by Swati for header freezing--%>
    <link href="../FinIQJS/FreezeGrid.css" type="text/css" rel="stylesheet">
    <script src="../FinIQJS/FreezeGrid.js" type="text/javascript"></script>
    <%--  end by swati--%>
    <style type="text/css">
        .buttonsWidth {
            width: 70px;
        }

        .FilterPad {
            padding: 3px 6px 3px 0px;
            /*margin-bottom: 6px;*/
        }

        /*.GridItem td:nth-child(3)
        {
            min-width: 500px !important;
        }

        .GridItem td:nth-child(5)
        {
            min-width: 300px !important;
        }*/

        .DateWidth {
            min-width: 160px !important;
            max-width: 160px !important;
        }

        .GridLongCol {
            min-width: 350px !important;
            max-width: 350px !important;
            word-wrap: break-word;
        }

        .GridCOlWidth {
            min-width: 100px !important;
            max-width: 100px !important;
        }
    </style>
    <script type="text/javascript">

        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : evt.keyCode;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }

        // Added By Ruchira M on 6-june-2018
        var dialogConfirmed = false;
        function ViewDialogDuplicate(obj, title, dialogText) {
            if ($("#pageName").html() != null) {
            }
            if (!dialogConfirmed) {
                $('html').append(String.Format("<div id='dialog' title='{0}'><p style='float:left;'><span class='ui-icon ui-icon-alert' style='float:left; margin:0 5px 20px 0;'></span>{1}</p></div>", title, dialogText));
                $('#dialog').dialog
                    ({
                        height: 180,
                        width: 350,
                        modal: true,
                        resizable: false,
                        draggable: true,
                        close: function (event, ui) { $('html').find('#dialog').remove(); },
                        buttons:
                        {
                            'Yes': function () {
                                $("#ctl00_MainContent_btnConfirmation").click();
                                $(this).dialog('close');
                            },
                            'No': function () {
                                $(this).dialog('close');
                                $('html').find("#dialog").remove();
                                return false;
                            }
                        }
                    });
            }

            return dialogConfirmed;
            $(".ui-widget-overlay").height($("body").height());

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

        //Added by SwatiP for keyboard shortcuts
        document.onkeyup = function (e) {
            if (e.ctrlKey && e.shiftKey && e.key == "E") {
                document.getElementById('<%= btnExcel.ClientID %>').click();
            }
        }
    </script>

    <asp:UpdatePanel ID="Updatepanel1" runat="server">
        <ContentTemplate>
            <table>
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td colspan="6">
                                    <asp:Label ID="lblError" runat="server" CssClass="lblerror"></asp:Label>
                                    <asp:Label ID="lblInfo" runat="server" CssClass="lblInfo"></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table style="border-spacing: 5px">
                            <%--Start JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP --%>
                            <tr>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Label ID="Label2" runat="server" CssClass="lbl" Text="Setting Name" />
                                </td>
                                <td style="padding-top: 5px">
                                    <asp:TextBox ID="txt_Search" runat="server" TabIndex="1" CssClass="txt" Width="240px" onkeydown="return EnterEvent(event)"></asp:TextBox>
                                </td>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Button ID="btnSearch" runat="server" Text=""
                                        TabIndex="2" CssClass="btnSearch" />
                                </td>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Button CssClass="buttonsWidth btn" ID="btnRefresh" runat="server" Text="Refresh"
                                        TabIndex="5" />
                                </td>

                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Button CssClass="Export2Excel" Width="100px" ID="btnExcel" runat="server"
                                        TabIndex="6" ToolTip="Export Excel (Ctrl+Shift+e)" />
                                </td>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Label ID="lblrecord" Text="Total Record(s) :   " runat="server" Width="90px" CssClass="lbl"></asp:Label>
                                </td>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Label ID="totalcount" runat="server" CssClass="lbl"></asp:Label>
                                    <asp:Button ID="btnSetPageSize" runat="server" Style="display: none"></asp:Button>
                                </td>

                                <%-- UI Changes done by SwatiP <UBPINT-144>--%>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:Label ID="lblrowsperpage" runat="server" Text="Record(s) per Page" Width="110px" CssClass="lbl"></asp:Label>
                                </td>
                                <td style="padding-right: 15px; padding-top: 5px">
                                    <asp:TextBox ID="TxRowsPerPage" runat="server" Width="27px" MaxLength="2" CssClass="txt RightAlign" onkeypress="return isNumberKey(event)"></asp:TextBox>
                                </td>


                                <%--   <td style="padding-left: 30px">
                                    <asp:Label ID="lblRowsperpage" runat="server" CssClass="lbl" Text="Record(s) Per Page:" />
                                </td>
                                <td style="padding-left: 10px">
                                    <asp:TextBox ID="txtrowsperpage" runat="server" CssClass="txt" MaxLength="2" Style="text-align: center;" AutoPostBack="true" Width="20px" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
                                </td>
                                <td style="padding-left: 30px">
                                    <asp:Label ID="LblRowCountName" runat="server" CssClass="lbl" Text="Record(s) Count : "></asp:Label>
                                </td>
                                <td style="padding-left: 10px">
                                    <asp:Label ID="LblRowCount" runat="server" CssClass="lbl" Text="Row Count"></asp:Label>
                                </td>--%>
                            </tr>
                            <%--End JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP --%>
                            <tr>

                                <%-- <td>
                                                <asp:Button CssClass="buttonsWidth btn" ID="btnAdd" runat="server" Text="Add"
                                                    TabIndex="3" />
                                            </td>--%>
                                <%--  <td>
                                                <asp:Button CssClass="buttonsWidth btn" ID="btnEdit" runat="server" Text="Edit" Enabled="false"
                                                    TabIndex="4" />
                                            </td>--%>
                                <%-- <td>
                                                <asp:Button CssClass="buttonsWidth btn" ID="btnDelete" runat="server" Text="Delete"
                                                    TabIndex="4" />
                                                <ajaxToolkit:ConfirmButtonExtender ID="ExtenderDelete" runat="server" TargetControlID="btnDelete" ConfirmText="Are you sure you want to delete selected Config Setting Master record?"></ajaxToolkit:ConfirmButtonExtender>
                                            </td>--%>
                            </tr>
                        </table>
                    </td>

                </tr>
                <%--  <tr>
                    <td>
                        <asp:Panel ID="pnlAddSetting" runat="server" Visible="false">
                            <table>
                                <tr>
                                    <td>
                                        <asp:Label ID="lblconfigname" runat="server" CssClass="lbl" Text="Setting Name" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblconfiglevel" runat="server" CssClass="lbl" Text="Setting Level" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblconfigdefaultvalue" runat="server" CssClass="lbl" Text="Default Value" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblconfigsection" runat="server" CssClass="lbl" Text="Setting Section" />
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 375px;">
                                        <asp:TextBox ID="txtconfigname" runat="server" MaxLength="45" CssClass="txt" Width="330px" TabIndex="6" />
                                    </td>
                                    <td style="width: 168px;">
                                        <asp:DropDownList ID="ddlconfiglevel" runat="server" CssClass="ddl" Width="152px" TabIndex="7">
                                            <asp:ListItem Value="ENTITY">ENTITY</asp:ListItem>
                                            <asp:ListItem Value="SYSTEM">SYSTEM</asp:ListItem>
                                            </asp:DropDownList>
                                    </td>
                                    <td style="width: 255px;">
                                        <asp:TextBox ID="txtconfigdefaultvalue" runat="server" CssClass="txt" Width="240px" TabIndex="8" />
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtconfigsectionname" runat="server" MaxLength="45" Width="100px" CssClass="txt"
                                            TabIndex="9" />
                                    </td>
                                    <td>
                                        <asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator4" ControlToValidate="txtrowsperpage"
                                            ValidationExpression="^[0-9]+$" ErrorMessage="Please enter only numbers." Font-Size="Smaller"> </asp:RegularExpressionValidator></td>

                                   

                                </tr>


                            </table>
                        </asp:Panel>
                    </td>
                </tr>--%>
            </table>
            <table>
                <tr>
                    <td>
                        <%--  <asp:GridView ID="dgvConfigMaster" runat="server" AutoGenerateColumns="false" AllowSorting="false" CssClass="Grid"
                            BorderStyle="None" AllowPaging="true" PageSize="10" Width="500px" DataKeyField="Setting_Id" ViewStateMode="Enabled" ShowFooter="true" >
                        
                            <RowStyle CssClass="GridItem" />
                            <HeaderStyle CssClass="GridHeader" />
                            <FooterStyle CssClass="GridFooter" />
                            <PagerStyle CssClass="GridPager" />--%>
                        <asp:GridView ID="dgvConfigMaster" runat="server" ShowHeaderWhenEmpty="true" AllowPaging="true" AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" CssClass="Grid" PageSize="10" Style="margin-left: 12px; margin-top: 15px" DataKeyField="Setting_Id" ViewStateMode="Enabled">

                            <SelectedRowStyle CssClass="GridItemSelect" />
                            <RowStyle CssClass="GridItem" />
                            <HeaderStyle CssClass="GridHeader" />
                            <FooterStyle CssClass="GridFooter" />
                            <PagerStyle CssClass="GridPager" />
                            <PagerSettings FirstPageText="First" LastPageText="Last" Mode="NumericFirstLast" Position="Bottom" />
                            <EmptyDataTemplate>
                                <asp:Label ID="lblqueuedatagrid" runat="server" CssClass="lbl" Text="No data found."></asp:Label>
                            </EmptyDataTemplate>
                            <Columns>

                                <asp:TemplateField>

                                    <EditItemTemplate>
                                        <asp:LinkButton ID="btnUpdate" runat="server" CommandName="Update" Text="Update" Width="50px" />
                                        <asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel" Width="50px" />
                                    </EditItemTemplate>
                                    <ItemStyle HorizontalAlign="Center" />
                                    <FooterStyle HorizontalAlign="Center" />
                                    <ItemTemplate>

                                        <asp:LinkButton ID="btnEdit" runat="server" CommandName="Edit" Text="Edit" Width="100px" />
                                    </ItemTemplate>

                                    <FooterTemplate>
                                        <asp:LinkButton ID="btnInsert" runat="server" CommandName="Add" Text="Add" Width="100px" ValidationGroup="Insert" />
                                    </FooterTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField>
                                    <ItemStyle HorizontalAlign="Center" />
                                    <%--<EditItemTemplate>
                                            <asp:LinkButton ID="btnUpdate" runat="server" CommandName="Update" Text="Update" Width="50px" />
                                            <asp:LinkButton ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel" Width="50px" />
                                        </EditItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" />
                                        <FooterStyle HorizontalAlign="Center" />--%>
                                    <ItemTemplate>

                                        <asp:LinkButton ID="btndelete" runat="server" CommandName="Delete" Text="Delete" Width="80px" />
                                    </ItemTemplate>

                                    <%--    <FooterTemplate>
                                            <asp:LinkButton ID="btnInsert" runat="server" CommandName="Add" Text="Add" Width="100px" ValidationGroup="Insert" />
                                        </FooterTemplate>--%>

                                </asp:TemplateField>

                                <asp:BoundField HeaderText="Sr.No." ReadOnly="True" DataField="SrNo" SortExpression="SrNo" Visible="true" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Wrap="false" ItemStyle-Width="80px" />

                                <asp:TemplateField HeaderText="Setting Name" ItemStyle-Width="350px" SortExpression="Setting_Name" ItemStyle-Wrap="true"><%--JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP , Wrap = true--%>
                                    <ItemTemplate>
                                        <%--JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP ,Style="overflow-wrap: break-word"--%>
                                        <asp:Label ID="lblSettingName" Style="overflow-wrap: break-word" runat="server" Width="350px" Text='<%# Eval("Setting_Name")%>' Visible="true" ToolTip='<%# Eval("Setting_Name")%>'></asp:Label>
                                    </ItemTemplate>

                                    <EditItemTemplate>

                                        <asp:TextBox ID="txt_SettingName" Text='<%# Eval("Setting_Name")%>' MaxLength="50" runat="server" Visible="true" Style="width: 440px !important"></asp:TextBox>

                                    </EditItemTemplate>

                                    <FooterTemplate>
                                        <asp:TextBox ID="txtftrSettingName" runat="server" Style="width: 350px !important" MaxLength="50" />
                                    </FooterTemplate>

                                </asp:TemplateField>


                                <asp:TemplateField HeaderText="Setting Level" SortExpression="Setting_Level" ItemStyle-Wrap="false">

                                    <ItemTemplate>
                                        <asp:Label ID="lblSettingLevel" runat="server" Width="100px" Text='<%# Eval("Setting_Level")%>' Visible="true" ToolTip='<%# Eval("Setting_Level")%>'></asp:Label>
                                    </ItemTemplate>

                                    <EditItemTemplate>
                                        <asp:Label ID="lblSettLevelEdit" runat="server" Width="100px" Text='<%# Eval("Setting_Level")%>' Visible="false"></asp:Label>

                                        <asp:DropDownList ID="ddlEditSettingLevel" SelectedValue='<%# Eval("Setting_Level")%>' runat="server" Width="100px" CssClass="ddl">
                                            <asp:ListItem> </asp:ListItem>
                                            <asp:ListItem Value="ENTITY">ENTITY</asp:ListItem>
                                            <asp:ListItem Value="SYSTEM">SYSTEM</asp:ListItem>
                                        </asp:DropDownList>

                                    </EditItemTemplate>

                                    <FooterTemplate>

                                        <asp:DropDownList ID="ddlftrSettingLevel" runat="server" Width="70px" CssClass="ddl">
                                            <asp:ListItem> </asp:ListItem>
                                            <asp:ListItem Value="ENTITY">ENTITY</asp:ListItem>
                                            <asp:ListItem Value="SYSTEM">SYSTEM</asp:ListItem>
                                        </asp:DropDownList>

                                    </FooterTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Default Value" SortExpression="Default_Value" ItemStyle-Wrap="true"><%-- updated wrap as true on 8-1-2021--%>

                                    <ItemTemplate>
                                        <asp:Label ID="lblDefaultValue" runat="server" Width="400px" Text='<%# Eval("Default_Value")%>' Visible="true" Style="overflow-wrap: break-word" ToolTip='<%# Eval("Default_Value")%>'></asp:Label>
                                        <%--added break-word for wrapping of long text on 8-1-2021--%>
                                    </ItemTemplate>

                                    <EditItemTemplate>

                                        <asp:TextBox ID="txt_DefaultValue" Text='<%# Eval("Default_Value")%>' MaxLength="100" runat="server" Visible="true" Style="width: 440px !important"></asp:TextBox>

                                    </EditItemTemplate>

                                    <FooterTemplate>
                                        <asp:TextBox ID="txtftrDefaultValue" runat="server" Style="width: 400px !important" MaxLength="100" />
                                    </FooterTemplate>

                                </asp:TemplateField>


                                <asp:TemplateField HeaderText="Setting Section" SortExpression="Setting_Section" ItemStyle-Wrap="false">

                                    <ItemTemplate>
                                        <asp:Label ID="lblSettingSection" runat="server" Width="80px" Text='<%# Eval("Setting_Section")%>' Visible="true" ToolTip='<%# Eval("Setting_Section")%>' Style="overflow: hidden;"></asp:Label>
                                    </ItemTemplate>

                                    <EditItemTemplate>

                                        <asp:TextBox ID="txt_SettingSection" Text='<%# Eval("Setting_Section")%>' MaxLength="50" runat="server" Visible="true" Style="width: 80px !important"></asp:TextBox>

                                    </EditItemTemplate>

                                    <FooterTemplate>
                                        <asp:TextBox ID="txtftrSettingSection" runat="server" Width="80px" MaxLength="50" />
                                    </FooterTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Created At" SortExpression="Created_At" ItemStyle-Wrap="false">
                                    <ItemStyle Width="120" HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblCreated_At" runat="server" Text='<%# Eval("Created_At")%>' Visible="true" ToolTip='<%# Eval("Created_At")%>'></asp:Label>
                                    </ItemTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Created By" SortExpression="Created_By" ItemStyle-Wrap="true"><%--JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP , Wrap = true--%>
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <%--JIra:-UBPINT-202 Added by shubham k on 22-Feb-21 for UBP ,Style="overflow-wrap: break-word"--%>
                                        <asp:Label ID="lblCreated_By" Style="overflow-wrap: break-word" runat="server" Width="60px" Text='<%# Eval("Created_By")%>' Visible="true" ToolTip='<%# Eval("Created_By")%>'></asp:Label>
                                    </ItemTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Setting Id" SortExpression="Setting_id" ItemStyle-Wrap="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lblSetting_id" runat="server" Width="60px" Text='<%# Eval("Setting_id")%>' Visible="true" ToolTip='<%# Eval("Setting_id")%>'></asp:Label>
                                    </ItemTemplate>

                                </asp:TemplateField>


                                <%--  <asp:BoundField HeaderText="Created At" ReadOnly="True" DataField="Created_At" SortExpression="Created_At" Visible="true" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="false" ItemStyle-Width="120px" />
                                                                 
                                 <asp:BoundField HeaderText="Created By" ReadOnly="True" DataField="Created_By" SortExpression="Created_By" Visible="true" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" ItemStyle-Wrap="false" ItemStyle-Width="120px" />

                                <asp:BoundField HeaderText="Setting Id" ReadOnly="True" DataField="Setting_id" SortExpression="Setting_id" Visible="true" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" ItemStyle-Wrap="false" ItemStyle-Width="120px" />--%>
                            </Columns>

                        </asp:GridView>
                    </td>
                    <asp:TextBox ID="txtTag" Style="display: none" runat="server"></asp:TextBox>
                </tr>
                <asp:HiddenField ID="hdnDeleteRowIndex" runat="server" />
                <%-- Added By RuchiraM on 6-june-2018--%>
                <asp:Button ID="btnConfirmation" runat="server" Width="0" Style="width: 0px; height: 0px; font-size: 0; border: none; display: none;" />
                <%-- Added By RuchiraM on 6-june-2018--%>
            </table>
            <asp:HiddenField ID="hdnSettingName" runat="server" />
            <asp:HiddenField ID="hdnSettingLevel" runat="server" />


            <script type="text/javascript">

                var prm1 = Sys.WebForms.PageRequestManager.getInstance();
                prm1.add_initializeRequest(InitializeRequest1);
                prm1.add_endRequest(EndRequest1);


                function InitializeRequest1(sender, args) {
                }

                function EndRequest1(sender, args) {
                    $("#<%=TxRowsPerPage.ClientID%>").keydown(function (e) {
                        var code = e.keyCode || e.which;

                        if (code == 13 || code == 9) {
                            document.getElementById('<%=btnSetPageSize.ClientID%>').click();
                        }
                    });
                }

                $("#<%=TxRowsPerPage.ClientID%>").keydown(function (e) {
                    var code = e.keyCode || e.which;

                    if (code == 13 || code == 9) {
                        document.getElementById('<%=btnSetPageSize.ClientID%>').click();
                    }
                });

                function AllowNumericOnly(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 <= 57)) { return true; }
                    else { return false; } return true;
                }
            </script>

        </ContentTemplate>

        <Triggers>
            <asp:PostBackTrigger ControlID="btnExcel" />
            <asp:PostBackTrigger ControlID="dgvConfigMaster" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
