<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/FiniqAppMasterPage.Master"
    CodeBehind="HolidayCalenderSetup.aspx.vb" Inherits="FinIQWebApp.HolidayCalenderSetup"
    Title="Holiday Cal Setup" %>

<%@ Register Src="../FinIQ_User_Controls/DateControl.ascx" TagName="DateControl"
    TagPrefix="uc1" %>

<asp:Content ID="cont" ContentPlaceHolderID="MainContent" runat="server">
<script src="../FinIQJS/SortFilter_Grid.js"></script>
    <asp:ScriptManagerProxy ID="ScriptManagerProxy11" runat="server">
    </asp:ScriptManagerProxy>
    <%--Start Added by shubham k on 11-Feb-21 for UBP UI Standard--%>
        <link href="../FinIQJS/FreezeGrid.css" type="text/css" rel="stylesheet">
 <script src="../FinIQJS/FreezeGrid.js" type="text/javascript"></script> 
    <%--End Added by shubham k on 11-Feb-21 for UBP UI Standard--%>
    <style type="text/css">
        .ddlWidth
        {
            width: 180px;
        }
        .width70
        {
            width: 70px !important;
        }
     
        #ctl00_MainContent_dtpFrom_txtDate, #ctl00_MainContent_dtpTo_txtDate
        {
            margin-left:-1px !important;
        }
      
        /*Added by shubham k on 11-Feb-21 for the holiday calendar pop up*/
        .EventClass {
            background-image: url(../App_Resources/calendarIcon.png);
            width: 30px !important;
            height: 30px !important;
            border: none 0px #FFF !important;
            background-color: #FFFFFF;
            background-repeat: no-repeat;
            display: block;
            background-size: contain;
            /*margin-left: 5px;*/
        }
        .EventClass:hover {
                cursor: pointer;
        }
        /*End by shubham k on 11-Feb-21 for the holiday calendar pop up*/

        .auto-style1 {
            height: 21px;
        }

        .btn_padding {
            padding-top: 5px;
            padding-right: 10px;
        }
    </style>
    <asp:UpdatePanel ID="UpdatePanelCP" runat="server">
        <ContentTemplate>

         <script type="text/javascript">
                function Export() {
                    CreateExcelSheetAutoFitEUD(dgholidaycalender);
                }

                function CreateExcelSheetAutoFit(dgholidaycalender) {
                    try {
                        var tbl = dgholidaycalender
                        var x = tbl.rows;

                        try {
                            var xls = new ActiveXObject("Excel.Application")
                            var handle = xls.Workbooks.Add


                        }
                        catch (e) {
                            document.getElementById('ctl00_MainContent_' + 'lblError').innerText = "Please Check Browser setting Tools-->Internet Option-->Security-->Custom Level-->Initialize and script ActiveX controls not marked and safe  Make it enable."
                        }


                        for (i = 0; i < x.length - 1; i++) {

                            var y = x[i].cells
                            for (j = 2; j < y.length - 1; j++) {
                                xls.Cells(i + 1, j - 1).Value = "'" + y[j].innerText;
                            }
                        }
                        xls.visible = true
                        if (y.length - 1 <= 26) {
                            var rng = xls.Columns(String.fromCharCode(65, 58, 65 + y.length - 1))
                            rng.AutoFit
                        }
                    }
                    catch (e) {
                        document.getElementById('ctl00_MainContent_' + 'lblError').innerText = "Please Check Browser setting Tools-->Internet Option-->Security-->Custom Level-->Initialize and script ActiveX controls not marked and safe  Make it enable."
                    }

                }





               


                function checkFileExtension(elem) {
                    var filePath = elem.value;

                    if (filePath.indexOf('.') == -1)
                        return false;

                    var validExtensions = new Array();
                    var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();

                    validExtensions[0] = 'xls';
                    validExtensions[1] = 'xlsx';

                    for (var i = 0; i < validExtensions.length; i++) {
                        if (ext == validExtensions[i]) {
                            document.getElementById("ctl00_MainContent_btnImportExcel").disabled = false;
                            return true;
                        }
                    }
                    var uploadControl = document.getElementById('<%=fileupload1.ClientID%>');
                    //<Mohit / Chitra on 11-Nov-2016 >
                    uploadControl.value = null;
                    //</Mohit / Chitra on 11-Nov-2016 >
                    document.getElementById("ctl00_MainContent_btnImportExcel").disabled = true;

                    alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
                    return false;


                }

                //Added by Chitralekha on 30-Sep-16
                function onlyAlphabet(e, t) {

                    try {

                        if (window.event) {

                            var charCode = window.event.keyCode;

                        }

                        else if (e) {

                            var charCode = e.which;

                        }

                        else { return true; }

                        if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 32 || charCode == 45 || charCode == 46 || charCode == 38)    //<Nikhil M. on 15-Oct-2016: Added 45,46,38 for - . & |dilkhush>

                            return true;

                        else

                            return false;

                    }

                    catch (err) {

                        alert(err.Description);

                    }

                }
             //Start Added by shubham k on 11-Feb-2021 for UBP
        document.onkeyup = function (e) {
            if (e.ctrlKey && e.key == "r") {
                document.getElementById('<%= btnLoad.ClientID %>').click();
            } else if (e.ctrlKey && e.shiftKey && e.key == "E") {
                document.getElementById('<%= btnexcel.ClientID %>').click();
            }
        }
        //End Added by shubham k on 11-Feb-2021 for UBP

             //Added to prompt message to update day count after saving and deleting holiday on 04-May-2021 by Palak A. || Start
             function alertMessage() {
                    alert('Please update day count after saving record(s)');
             }

              function DeletealertMessage() {
                    alert('Please update day count after deleting record(s)');
             }
             //Added to prompt message to update day count after saving and deleting holiday on 04-May-2021 by Palak A. || End

            </script>

            <asp:HiddenField ID="hdnShowupdatedaycountbtn" runat="server" />  <%--Added on 19-Apr-2021 by Palak A. for for INT1FINFXC-134 Jira to update rate swap point table based on config--%>
            <table>
                <tr>
                    <td class="Label" valign="top" align="left">
                        <asp:Label ID="lblError" runat="server" CssClass="lblError"></asp:Label>
                        <asp:Label ID="lblInfo" runat="server" CssClass="lblInfo"></asp:Label>
                         <asp:Label ID="lblsuccess" runat="server" Text="" CssClass="lblsuccess"></asp:Label>
                    </td>

                </tr>
            </table>

            <table>
                <tr>
                    <td colspan="9">
                        <asp:Label ID="Label5" runat="server" CssClass="lbl" Style="padding: 5px;">Search By Holiday</asp:Label>
                    </td>

                </tr>

                <tr>
                    <td class="lblBlotterPaddingRight">
                        <%--Header changed from Currency to Calendar by ApurvaK for BBVAORINT-126 UI changes suggested by DJ| 04 APR 2022--%>
                        <asp:CheckBox ID="chkbCCY" runat="server" AutoPostBack="True" CssClass="lbl" Text="Calendar"
                     TabIndex="1" />
               </td>
                    <td ></td>
               <td class="lblBlotterPaddingRight">
                  <asp:DropDownList ID="ddlholccy" runat="server" CssClass="ddl" Width="170px" AutoPostBack="true" TabIndex="2">
                        </asp:DropDownList>
               </td>
                <td class="lblBlotterPaddingRight"></td>
               <td class="lblBlotterPaddingRight">
                        <asp:Label ID="Label3" runat="server" CssClass="lbl" MaxLength="50">Holiday Name</asp:Label>
                    </td>
                    <td class="lblBlotterPaddingRight">
                  <asp:TextBox ID="txtHolname" runat="server" CssClass="txt" Width="170px" Visible="true" TabIndex="3"
                            MaxLength="50" onkeypress="Javascript:onlyAlphabet();"></asp:TextBox>

                    </td>
                     <td class="lblBlotterPaddingRight" style="white-space:nowrap;">
                     <%--Added by shubham k on 11-Feb-21 for UBP UI Standard--%>
                  <asp:Label ID="Label7" runat="server" Style="margin-left: 5px !important;" CssClass="lbl">Record(s) Per Page: </asp:Label>
                  <asp:TextBox ID="txtPageSize" runat="server" MaxLength="3" Width="35px" TabIndex="10" Style="text-align: center;" AutoPostBack="true" OnKeyPress="return AllowNumericOnly(this);"></asp:TextBox>
                    </td>


                </tr>

                <tr>
               <td class="lblBlotterPaddingRight">
                        <asp:CheckBox ID="chkbType" runat="server" AutoPostBack="True" CssClass="lbl" Text="Type"
                     TabIndex="4" />

                    </td>
                    <td></td>
               <td class="lblBlotterPaddingRight">
                  <asp:DropDownList ID="ddlholtype" runat="server" CssClass="ddl" Width="170px" AutoPostBack="True" TabIndex="5">
                        </asp:DropDownList>

                    </td>
                <td class="lblBlotterPaddingRight"></td>
               <td class="lblBlotterPaddingRight">
                        <asp:Label ID="Label4" runat="server" CssClass="lbl">Event</asp:Label>
                    </td>
                    <td class="lblBlotterPaddingRight">
                        <asp:TextBox ID="txtmisc" runat="server" CssClass="txt ddlWidth" Visible="true"
                     TabIndex="6" MaxLength="50" onkeypress="Javascript:onlyAlphabet();" Width="170px"></asp:TextBox>


                    </td>
                     <td class="lblBlotterPaddingRight">
                   <%--Added by shubham k on 11-Feb-21 for UBP UI Standard--%>
                        <asp:Label ID="Label6" runat="server" Style="margin-left: 5px !important;" CssClass="lbl">Total Record(s): </asp:Label>
                        <asp:Label ID="txtCount" runat="server" Style="margin-left:2px;" CssClass="lbl"></asp:Label>

                    </td>
                </tr>

                <tr>
               <td class="lblBlotterPaddingRight">
                  <asp:CheckBox ID="chkbDateRange" runat="server" AutoPostBack="True" CssClass="lbl" Text="Date" TabIndex="7" />

                    </td>
               <td class="lblBlotterPaddingRight">
                        <asp:Label Visible="false" ID="lblHolidayDate" runat="server" CssClass="lbl">From</asp:Label>

                    </td>
               <td id="dptfromdate" class="lblBlotterPaddingRight">
                  <uc1:DateControl ID="dtpFrom" runat="server" TabIndex="8" CalenderCss="btn1" TextBoxCss="txt" TextBoxSize="170" />
                    </td>
                <td class="lblBlotterPaddingRight"></td>
                <td class="lblBlotterPaddingRight">
                  <asp:Label ID="lblToDate" runat="server" CssClass="lbl">To</asp:Label>
               </td>
               
                 
                     <td >
                  <uc1:DateControl ID="dtpTo" runat="server" TabIndex="9" CalenderCss="btn1" TextBoxCss="txt" TextBoxSize="170" />
               </td>
                </tr>

                <tr>
                
                <td></td>

                <td class="lblBlotterPaddingRight"></td>
               <td colspan="2">
                  <asp:FileUpload ID="fileupload1" runat="server" Height="28px" TabIndex="11" />
                    </td>

                  
                 
                   
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblWeekEnd" runat="server" CssClass="lbl">WeekEnd Days</asp:Label>
                       
                                       </td>
                    <td class="lblBlotterPaddingRight">
                  <asp:CheckBoxList ID="chkblWeekEnd" runat="server" RepeatDirection="Horizontal" TabIndex="12">
                            <asp:ListItem Value="Saturday">Saturday</asp:ListItem>
                            <asp:ListItem Value="Sunday">Sunday</asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                   
                </tr>

                <%--Added by ApurvaK for BBVAORINT-126 UI changes as discussed with DJ| 04 APR 2022| Start--%> 
                <%-- <tr>
                     <td class="lblBlotterPaddingRight">
                        <asp:CheckBox ID="chkCustomCal" runat="server" AutoPostBack="True" CssClass="lbl" Text="Holiday Calendar Dropdown"
                     TabIndex="1" />
                     </td>
                     <td ></td>
                       <td class="lblBlotterPaddingRight">
                       <asp:DropDownList ID="ddCustomCal" runat="server" CssClass="ddl" Width="170px" AutoPostBack="true" TabIndex="2">
                       </asp:DropDownList>
                       </td>
                </tr>--%>
                 <%--Added by ApurvaK for BBVAORINT-126 UI changes as discussed with DJ| 04 APR 2022| End--%> 
         </table>
          <table>
                <tr>
                 <td class="btn_padding">
                  <input class="btn" id="btnAddNew" type="button" value="Add New" runat="server" style="width: 100px;" tabindex="13">
               </td>
                 <td class="btn_padding">
                  <input class="btn" id="btnAdd" type="button" value="Save" runat="server" style="width: 100px;" tabindex="14">
               </td>
                  <td class="btn_padding">
                  <input class="btn" id="btnCancel" type="button" value="Cancel" runat="server" style="width: 100px;" tabindex="15">
                    </td>
                   <td class="btn_padding">
                  <input class="btn" id="btnload" type="button" value="Load" title="Load (ctrl + r)" runat="server" style="width: 100px;" tabindex="16">
               </td>
                   <td class="btn_padding">
                  <asp:Button ID="btnImportExcel" runat="server" CssClass="btn" Text="Import Excel" TabIndex="17" Style="width: 100px;"></asp:Button>
                    </td>
               <td class="lblBlotterPaddingRight">
                    <%--Added by shubham k on 11-Feb-21 for UBP added export excel class--%>
                  <asp:Button ID="btnExcel" runat="server" CssClass="Export2Excel" ToolTip="Export Excel (ctrl + shift + e)" Text="" Style="width: 100px;" TabIndex="18"></asp:Button>
                  <asp:Button ID="btnSetPageSize" runat="server" Style="display: none"></asp:Button>
               </td>
                     <%--Start Added by Palak A. on 19-Apr-2021 for update day count button--%>
                    <td  class="btn_padding">
                        <asp:Button ID="btnDaycount" type="button" value="Day Count" CssClass="btn" Text="DayCount" Style="width: 100px;" runat="server" Visible="false" />
                    </td>
                    <%--End Added by Palak A. on 19-Apr-2021 for update day count button--%>
                    <%--Start Added by shubham k on 11-Feb-21 for holiday calendar pop up--%>
                    <td class="btn_padding">
                        <asp:Button ID="btnOpenCalendar" ToolTip="Holiday Calendar" CssClass="EventClass" Text="" runat="server" />
                    </td>
                    <%--End Added by shubham k on 11-Feb-21 for holiday calendar pop up--%>
                    
                </tr>

            </table>
            <table style="margin-top: 20px;">








                <tr>
                    <td style="height: 10px"></td>
                </tr>

										<tr>

                    <td class="tblMain" valign="top" align="left">
                       <%--Added by shubham k on 11-Feb-21 for UBP UI Standard--%>
                        <asp:DataGrid ID="dgholidaycalender" runat="server" CssClass="Grid frozenGrid"
                            AllowPaging="True" AutoGenerateColumns="False"   AllowSorting="True" DataKeyField="ID"  >
                            <SelectedItemStyle CssClass="GridItemSelect" />
                            <ItemStyle CssClass="GridItem" />
                            <HeaderStyle CssClass="GridHeader" />
                            <FooterStyle CssClass="GridFooter" />
                            <Columns>
                                 <asp:TemplateColumn>
                                                    <HeaderStyle HorizontalAlign="Right" />
                                                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                                   
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="chkSelection"  runat="server" OnCheckedChanged="chkAccept_Changed" AutoPostBack="true"  ></asp:CheckBox>
                                                    </ItemTemplate>
                                                </asp:TemplateColumn>
                                
                                <asp:BoundColumn HeaderText="SR. NO." Visible="false"></asp:BoundColumn>
                                <asp:BoundColumn Visible="false" DataField="ID" SortExpression="ID" HeaderText="ID">
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle>
                                </asp:BoundColumn>
                                <%--Header changed from Currency to Calendar by ApurvaK for BBVAORINT-126 UI changes suggested by DJ| 04 APR 2022--%>
                                <%--DataField and SortExpression changed from Currency to Calendar for import not working functionality| 06 May 2022--%>
                                <asp:BoundColumn DataField="Calendar" SortExpression="Calendar" HeaderText="Calendar"> 
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle" Width="90px"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="HolidayDate" SortExpression="HolidayDate" HeaderText="Holiday Date">
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle" Width="125px"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="HolidayName" SortExpression="HolidayName" HeaderText="Holiday Name">
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Middle" Width="125px"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:BoundColumn DataField="Misc" SortExpression="Misc" HeaderText="Event">
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="128px"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle>
                                </asp:BoundColumn>

                                <asp:BoundColumn DataField="HolidayType" SortExpression="HolidayType" HeaderText="Holiday Type">
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                    <ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle" Width="130px"></ItemStyle>
                                </asp:BoundColumn>
                                <asp:TemplateColumn>
                                    <ItemTemplate>
                                        <itemstyle horizontalalign="center" />
                                        <div style="text-align: center !important">
                                            <asp:LinkButton ID="lnkdelete" CommandName="Delete" runat="server">Delete</asp:LinkButton>
                                        </div>

                                    </ItemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                            <PagerStyle CssClass="GridPager" Mode="NumericPages" />
                        </asp:DataGrid>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input id="saveScrollPos" type="hidden" name="saveScrollPos" runat="server">
                  <asp:TextBox ID="txtFlag" runat="server" CssClass="txt" Visible="False"></asp:TextBox>
                  <asp:TextBox
                     ID="hdn" runat="server" Width="24px" Visible="False"></asp:TextBox>
                  <input id="hdnButtonValue"
                                style="width: 56px; height: 22px" type="hidden" size="4" runat="server"><input id="hdnHolidayID"
                                    style="width: 48px; height: 22px" type="hidden" size="2" runat="server">
                    </td>
                </tr>
            </table>


            <asp:TextBox ID="txt_sortorder" runat="server" Visible="false">desc</asp:TextBox>

            <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) {
                    $("#<%=txtPageSize.ClientID%>").keydown(function (e) {
                        var code = e.keyCode || e.which;

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

                $("#<%=txtPageSize.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>
            <asp:HiddenField ID="hdnpageindex" runat="server" Value="0"/>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="btnExcel" />
            <asp:PostBackTrigger ControlID="btnImportExcel" />
        </Triggers>

    </asp:UpdatePanel>
</asp:Content>
