<%@ page language="C#" autoeventwireup="true" inherits="Pages_FeeManagement_FeeSetup, App_Web_01ryypri" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" uiculture="auto" meta:resourcekey="PageResource1" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/DatePicker/DatePickerControl.ascx" TagName="DatePickerControl" TagPrefix="Date" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/AutoComplete/AutoCompleteControl.ascx" TagName="AutoCompleteControl" TagPrefix="acc" %>
<%@ Register Src="~/UserControls/Common/CommonSearch/CommonSearch.ascx" TagName="CommonSearchUserControl" TagPrefix="Common" %>
<%@ Register Src="~/UserControls/Common/EmployeeSearch/EmployeeSearch.ascx" TagName="EmployeeSearchControl" TagPrefix="hims" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <asp:UpdatePanel ID="OTQueueListingUpdatePanel" runat="server">
        <ContentTemplate>
            <hims:EmployeeSearchControl ID="EmployeeSearch" Visible="false" runat="server" />
            <Common:CommonSearchUserControl ID="CommonSearchControl" runat="server" Visible="false" />




            <div id="divContentPage" class="divcontentpagemargin">
                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <table>
                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="104"
                                Visible="true" runat="server" />
                        </table>
                    </div>
                </div>
                <div class="whiteboxpaddingleft row">
                    <div class="himssuHeader1WireBox card card-box">
                        <div class="himsBoxHeader  card-head">
                            <div class="leftdiv">
                            </div>
                            <div class="himsBoxTitle">
                                <div class="headerText">
                                    <header>
                                        <i class="fas fa-credit-card"></i>
                                        <asp:Label ID="ReasonMasterDetailLabel" runat="server" Text="Fee Setup"></asp:Label>
                                    </header>
                                </div>
                            </div>

                        </div>

                        <div class="himsBoxContent  card-body">
                            <div class="contentHolder">

                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="OrganizationLabel" Text="Organization" runat="server" SkinID="MandatoryLabel"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList ID="OrganizationDropDownList" runat="server" onmouseleave="showHideTooltip()"
                                            onmouseenter="showHideTooltip()" AutoPostBack="true" SkinID="CustomWidthDropDownList"
                                            CssClass="form-control" OnSelectedIndexChanged="OrganizationDropDownList_OnSelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>
                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="BatchLable" Text="Batch" runat="server" SkinID="MandatoryLabel"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList ID="BatchDropDownList" runat="server" onmouseleave="showHideTooltip()"
                                            onmouseenter="showHideTooltip()" SkinID="CustomWidthDropDownList" CssClass="form-control"
                                            AutoPostBack="true" OnSelectedIndexChanged="BatchDropDownList_OnSelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>

                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="AdmissionCategoryLabel" runat="server" Text="Fees Category" SkinID="MandatoryLabel">
                                        </asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList runat="server" ID="AdmissionCategoryDropDownList" SkinID="CustomWidthDropDownList"
                                            onmouseleave="showHideTooltip()" CssClass="form-control" onmouseenter="showHideTooltip()"
                                            AutoPostBack="true" OnSelectedIndexChanged="AdmissionCategoryDropDownList_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>
                                </div>
                                <div class="outerBox pTop5 col-md-3">
                                    <div class="controlLabelWidth">
                                        <asp:Label ID="ClassLabel" runat="server" SkinID="MandatoryLabel" Text="Class"></asp:Label>
                                    </div>
                                    <div class="fLeft pRight5">
                                        <asp:DropDownList runat="server" ID="ClassDropDownList" SkinID="CustomWidthDropDownList"
                                            AutoPostBack="true" onmouseleave="showHideTooltip()" CssClass="form-control" onmouseenter="showHideTooltip()"
                                            OnSelectedIndexChanged="ClassDropDownList_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </div>

                                </div>

                                <div class="outerBox pTop5 col-md-3">
                                    <div class="fLeft pTop5">
                                        <asp:CheckBox ID="ApplyToOtherClassCheckBox" runat="server" Onclick="ApplyToOtherClass(this);" />
                                        <asp:Label ID="ApplyToOtherClassLabel" runat="server" AssociatedControlID="ApplyToOtherClassCheckBox" Text="Apply To Other Class"
                                            class="pLeft5"></asp:Label>
                                    </div>
                                </div>
                                <div class="outerBox pTop5 col-md-2">
                                </div>
                                <div class="outerBox pTop5 col-md-3">
                                    <asp:Button ID="ReportPrintButton" runat="server" OnClick="ReportPrintButton_Click" SkinID="0" Text="&#xf15b; Print" class="form-control" CssClass="btn btn-report fas" Visible="True" />
                                </div>

                                <div id="DivClassCheckBoxList" class="outerBox11 pTop5 col-md-6" runat="server" style="display: none">
                                    <div class="col-md-6">
                                        <div class="select">
                                            <asp:CheckBox ID="ClassCheckBox" runat="server" onclick="ClassCheckBox(this);" />
                                            <asp:Label ID="ApplyForAllClassLabel" AssociatedControlID="ClassCheckBox" runat="server" Text="Select All" class="pLeft5"></asp:Label>
                                        </div>

                                        <div id="ClassDivisionDiv" runat="server" class="fLeft pRight5 chck-dropdown-onclick bg-lghtgrey outerBox11 col-md-12 overflow-x-hidden padd-0">
                                            <asp:CheckBoxList ID="ClassDivisionCheckBoxList" runat="server">
                                            </asp:CheckBoxList>
                                        </div>
                                    </div>
                                    <div class="col-md-6 ">
                                        <br />
                                        <br />
                                        <%--<asp:Button ID="ApplyForSelectClassButton" runat="server" SkinID="0" OnClientClick="ApplyForSelectClass(this);"
                                            Text="Apply For Select Class" CssClass="btn btn-apply" />--%>
                                        <input type="Button" name="ApplyForSelectClassButton" value="Apply For Select Class" onclick="ValidateForSelectClass(this);" id="ApplyForSelectClassButton" tabindex="9" class="btn btn-apply">
                                    </div>
                                </div>

                                <div id="FeeSetupDetailDiv" runat="server" visible="false">
                                    <div class="col-md-12">
                                        <div class="alert alert-info">
                                            <i class="material-icons">info</i>
                                            <asp:Label ID="NoteLabel" runat="server" Text="| Record are sorted by start date,Fee Head Order and Fee Order."></asp:Label><br />
                                        </div>
                                    </div>

                                    <div class="himssuHeader6WireBox col-md-12 pTop5">
                                        <div class="himsBoxHeader card-head inner" style="height: 55px;" id="GridViewPagerDiv" runat="server" visible="false">
                                            <div runat="server" id="LateFeeRuleDiv" class="leftdiv">
                                                <div class="outerBox pTop5 col-md-3">
                                                    <div class="controlLabelWidth">
                                                        <asp:Label ID="LateFeeRuleLabel" runat="server" Text="Late Fee Rule"></asp:Label>
                                                    </div>
                                                    <div class="fLeft pRight5">
                                                        <asp:DropDownList runat="server" ID="LateFeeRuleDropDownList" SkinID="CustomWidthDropDownList" Enabled="True"
                                                            AutoPostBack="true" onmouseleave="showHideTooltip()" CssClass="form-control" onmouseenter="showHideTooltip()">
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="himsBoxTitle pTop5">
                                                <%--<div class="gridHeaderText">
                                                    <header>
                                                        <asp:Label ID="GridViewLabel" Text="List" runat="server" />
                                                    </header>
                                                      </div>--%>

                                                <div class="pull-right col-md-6 display-flex pTop10">
                                                    <asp:DropDownList ID="FeeHeadDropDownList" runat="server" SkinID="CustomWidthDropDownList" CssClass="form-control mt-10" />
                                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                                    <asp:DropDownList ID="ApplyDropDownList" runat="server" SkinID="CustomWidthDropDownList" CssClass="form-control mt-10">
                                                        <asp:ListItem Text="- Select -" Value="-1" Selected="True"></asp:ListItem>
                                                        <asp:ListItem Text="Amount" Value="1"></asp:ListItem>
                                                        <asp:ListItem Text="Start Date" Value="2"></asp:ListItem>
                                                        <asp:ListItem Text="End Date" Value="3"></asp:ListItem>
                                                        <asp:ListItem Text="Receipt Book" Value="4"></asp:ListItem>
                                                        <%--<asp:ListItem Text="Collection Group" Value="5"></asp:ListItem>--%>
                                                        <asp:ListItem Text="Fee Duration" Value="6"></asp:ListItem>
                                                        <asp:ListItem Text="Level Amount" Value="7"></asp:ListItem>
                                                    </asp:DropDownList>
                                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                                            <asp:TextBox ID="ApplyAllTextBox" runat="server" ClientIDMode="Static" MaxLength="15"
                                                                SkinID="CustomWidthTextBox" CssClass="pTop5"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;
                                                              <input type="button" name="ApplyAllButton" value="Apply All" id="ApplyAllButton" class="btn btn-apply mt-10" onclick="ValueGet()" />
                                                    <%--<button type="button" name="ApplyAllButton" value="Apply All" id="ApplyAllButton" onclick="ValueGet()" class="btn btn-apply mt-10">Apply All</button>--%>
                                                </div>
                                            </div>


                                        </div>
                                        <div class="himsBoxContent pTop5">
                                            <div id="Div5" runat="server" visible="true" class="table-responsive">
                                                <asp:GridView ID="FeeSetupGridView" runat="server" AutoGenerateColumns="False"
                                                    EmptyDataText="No Records Found !!" AllowPaging="False" OnRowDataBound="FeeSetupGridView_RowDataBound"
                                                    DataKeyNames="Id,FeeId,IsReceiptBookChange,FeeHeadNumber" ShowHeader="True" ShowFooter="true"
                                                    CssClass="table table-striped table-bordered table-hover">
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="Select" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="3%"
                                                            ItemStyle-Wrap="true">
                                                            <HeaderTemplate>
                                                                <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                                    <asp:CheckBox ID="HeaderSelectCheckBox" runat="server" Enabled="true"
                                                                        Visible="true" onClick="HeaderCheckBoxCheck(this);" />
                                                                    <span></span>
                                                                </label>
                                                            </HeaderTemplate>
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                                    <asp:CheckBox ID="SelectCheckBox" Visible="true" Enabled="true"
                                                                        runat="server" onclick="SelectCheckBoxClick(this);" />
                                                                    <asp:HiddenField ID="hdID" Value='<%#Eval("Id") %>' runat="server" />
                                                                    <asp:HiddenField ID="HeadNumber" Value='<%#Eval("FeeHeadNumber") %>' runat="server" />
                                                                    <asp:HiddenField ID="ReceiptBookChange" Value='<%#Eval("IsReceiptBookChange") %>' runat="server" />
                                                                    <span></span>
                                                                </label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="FeeTitle" HeaderText="Fee" ItemStyle-Width="8%" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                        <asp:BoundField DataField="FeeHeadName" HeaderText="Fee Head" ItemStyle-Width="8%"
                                                            HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                                                        <asp:TemplateField HeaderText="Optional" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="3%"
                                                            ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                                    <asp:CheckBox ID="IsOptionalCheckBox" Checked='<%#Eval("IsOptional")%>' Enabled="false"
                                                                        runat="server" />
                                                                    <span></span>
                                                                </label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Variable" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="3%"
                                                            ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                                    <asp:CheckBox ID="IsVariableCheckBox" Checked='<%#Eval("IsVariable")%>' Enabled="false"
                                                                        runat="server" onClick="VariableCheckBoxClick(this);" />
                                                                    <span></span>
                                                                </label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Amount" ItemStyle-Width="10%" ItemStyle-Wrap="true">
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="AmountTextBox" runat="server" MaxLength="15" onKeypress="javascript:return MaskDecimal(event,12,2)" Enabled="false"></asp:TextBox>
                                                            </ItemTemplate>
                                                            <FooterTemplate>
                                                                <asp:Label ID="TotalAmountLabel" runat="server"></asp:Label>
                                                            </FooterTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Start Date" ItemStyle-Width="9%" ItemStyle-Wrap="true">
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="StartDateTextBox" onkeyup="FormatIt(this);" runat="server" Width="100px" Enabled="false" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="End Date" ItemStyle-Width="9%" ItemStyle-Wrap="true">
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="EndDateTextBox" runat="server" onkeyup="FormatIt(this);" DisplayDatePicker="false" Enabled="false"
                                                                    Width="100px" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Receipt Book" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="10%"
                                                            ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Left" />
                                                            <ItemTemplate>
                                                                <asp:DropDownList runat="server" ID="ReceiptBookDropDownList" onmouseleave="showHideTooltip()" Enabled="false"
                                                                    onmouseenter="showHideTooltip()" CssClass="form-control" Onchange="FillCollectionGroupDropDownList(this);">
                                                                </asp:DropDownList>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Collection Group" HeaderStyle-HorizontalAlign="Left"
                                                            ItemStyle-Width="10%" ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Left" />
                                                            <ItemTemplate>
                                                                <asp:DropDownList runat="server" ID="CollectionGroupDropDownList" onmouseleave="showHideTooltip()"
                                                                    onmouseenter="showHideTooltip()" CssClass="form-control" Width="100%" Enabled="false" Onchange="CollectionGroupChange(this);">
                                                                </asp:DropDownList>
                                                                <asp:HiddenField runat="server" ID="CollectionGroupValue" />
                                                                <asp:HiddenField runat="server" ID="OldCollectionGroupValue" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Service Tax" HeaderStyle-HorizontalAlign="Center"
                                                            ItemStyle-Width="3%" ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <label class="rt-chkbox rt-chkbox-single rt-chkbox-outline">
                                                                    <asp:CheckBox ID="IsServiceTaxCheckBox" Checked='<%#Eval("IsServiceTax")%>' runat="server" Enabled="false" />
                                                                    <span></span>
                                                                </label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Fee Duration" HeaderStyle-HorizontalAlign="Center"
                                                            ItemStyle-Width="7%" ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Center" />
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="FeeDurationTextBox" runat="server" Enabled="false" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Level Amount" ItemStyle-Width="7%" ItemStyle-Wrap="true">
                                                            <ItemTemplate>
                                                                <asp:TextBox ID="LevelAmountTextBox" runat="server" MaxLength="15" onKeypress="javascript:return MaskDecimal(event,12,2)" Enabled="false"></asp:TextBox>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Late Fee Rule" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="10%" ItemStyle-Wrap="true">
                                                            <ItemStyle HorizontalAlign="Left" />
                                                            <ItemTemplate>
                                                                <asp:DropDownList runat="server" ID="LateFeeRuleFeeWiseDropDownList" onmouseleave="showHideTooltip()"
                                                                    onmouseenter="showHideTooltip()" CssClass="form-control" Width="100%">
                                                                </asp:DropDownList>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                    <PagerSettings Visible="False" />
                                                </asp:GridView>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </ContentTemplate>
    </asp:UpdatePanel>

    <%--    <script data-main="../../JavaScript/rjs/encrypt/fee-setup-encrypt" src="../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/fee-setup")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script>
        var validated = 0;
        function SelectCheckBoxClick(obj) {

            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;
            row = obj.parentNode.parentNode.parentNode.rowIndex + 1;
            rowindex = row - 1;
            feesetupId = obj.nextElementSibling.value;
            ClassId = $('#ctl00_CP_ClassDropDownList').val();
            batchid = $('#ctl00_CP_BatchDropDownList').val();
            AdmissionCategoryId = $('#ctl00_CP_AdmissionCategoryDropDownList').val();
            if (chkselect == true) {
                if (row < 10) {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsOptionalCheckBox').removeAttr('disabled');
                    //IO.prop("disabled", false);
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('class');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('readonly');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_StartDateTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_EndDateTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_FeeDurationTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsServiceTaxCheckBox').removeAttr('disabled');
                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {

                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').removeAttr('disabled');
                    }
                    feesetupId = table.rows[rowindex].cells[0].childNodes[1].childNodes[3].value;
                    if (feesetupId != 0) {
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                        ReceiptChange = table.rows[rowindex].cells[0].childNodes[1].childNodes[7].value;
                        if (ReceiptChange == "True") {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');

                        }
                        else if (ReceiptChange == "False") {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                            if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_OldCollectionGroupValue').val()) > -1) {
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                            } else {
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                            }
                        }

                        if ($('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').prop("checked") == true) {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').attr('disabled', 'disabled');
                        }
                    }

                }
                else if (row > 9) {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').removeAttr('disabled');
                    //IO.prop("disabled", false);
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('class');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('readonly');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_StartDateTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_EndDateTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_FeeDurationTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsServiceTaxCheckBox').removeAttr('disabled');
                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {

                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').removeAttr('disabled');
                    }
                    feesetupId = table.rows[rowindex].cells[0].childNodes[1].childNodes[3].value;
                    if (feesetupId != 0) {
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                        ReceiptChange = table.rows[rowindex].cells[0].childNodes[1].childNodes[7].value;
                        if (ReceiptChange == "True") {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');

                        }
                        else if (ReceiptChange == "False") {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                            if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl' + row + '_OldCollectionGroupValue').val()) > -1) {
                                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                            }
                            else {
                                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                            }
                        }

                        if ($('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').prop("checked") == true) {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').attr('disabled', 'disabled');
                        }
                    }
                }
                $.ajax({
                    type: "POST",
                    url: "FeeSetup.aspx/SelectCheckBoxChecked",
                    data: JSON.stringify({ "RowIndex": row, "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d.returnCode == "1") {
                            enableControls(row);
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.Message);
                    }
                });
            }
            else if (chkselect == false) {
                if (row < 10) {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                    //IO.prop("disabled", false);
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_StartDateTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_EndDateTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_FeeDurationTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');

                    feesetupId = table.rows[rowindex].cells[0].childNodes[1].childNodes[3].value;
                    if (feesetupId == 0) {
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').value = '';
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_StartDateTextBox').value = '';
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_EndDateTextBox').value = '';
                    }
                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                    }
                }
                else if (row > 9) {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                    //IO.prop("disabled", false);
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_StartDateTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_EndDateTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_FeeDurationTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');
                    feesetupId = table.rows[rowindex].cells[0].childNodes[1].childNodes[3].value;
                    if (feesetupId == 0) {
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').removeAttr('checked');
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').removeAttr('checked');
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').value = '';
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_StartDateTextBox').value = '';
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_EndDateTextBox').value = '';
                    }

                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                    }
                }
                $.ajax({
                    type: "POST",
                    url: "FeeSetup.aspx/SelectCheckBoxChecked",
                    data: JSON.stringify({ "RowIndex": row, "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d.returnCode == "-50") {
                            alert('Referred in Fee Allocation can not be deleted');
                            $(obj).attr('checked', 'checked');
                            $(obj).prop("checked", true);
                            disableControls(row);
                        }
                        else if (data.d.returnCode == "-51") {
                            alert('Referred in Fee Receipt can not be deleted');
                            $(obj).attr('checked', 'checked');
                            $(obj).prop('checked', true);
                            disableControls(row);
                        }
                        else if (data.d.returnCode == "-52") {
                            alert('Referred in Optional Fee can not be deleted');
                            $(obj).attr('checked', 'checked');
                            $(obj).prop('checked', true);
                            disableControls(row);
                        }
                        else if (data.d.returnCode == "-53") {
                            alert('Referred in Online Fee can not be deleted');
                            $(obj).attr('checked', 'checked');
                            $(obj).prop('checked', true);
                            disableControls(row);
                        }
                        else if (data.d.returnCode == "-54") {
                            alert('Referred in Post Dated Payment can not be deleted');
                            $(obj).attr('checked', 'checked');
                            $(obj).prop('checked', true);
                            disableControls(row);
                        }
                        else if (data.d.returnCode == "1") {
                            $(obj).attr('checked', 'checked');
                            $(obj).prop('checked', false);
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.Message);
                    }
                });
            }
        }
        function enableControls(row) {
            rowindex = row - 1;
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            if (row < 10) {
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsOptionalCheckBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('readonly');
            }
            else if (row > 9) {
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('readonly');
            }

        }
        function disableControls(row) {
            rowindex = row - 1;
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            if (row < 10) {
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('class');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('readonly');
                if ($('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').prop("checked") == true) {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').attr('disabled', 'disabled');
                }
                ReceiptChange = table.rows[rowindex].cells[0].childNodes[1].childNodes[7].value;
                if (ReceiptChange == "True") {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');

                }
                else if (ReceiptChange == "False") {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_OldCollectionGroupValue').val()) > -1) {
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                    }
                    else {
                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                    }
                }
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_StartDateTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_EndDateTextBox').removeAttr('disabled');

                //$('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_FeeDurationTextBox').removeAttr('disabled');
            }
            else if (row > 9) {
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('class');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('readonly');
                if ($('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').prop("checked") == true) {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').attr('disabled', 'disabled');
                }
                ReceiptChange = table.rows[rowindex].cells[0].childNodes[1].childNodes[7].value;
                if (ReceiptChange == "True") {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');

                }
                else if (ReceiptChange == "False") {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl' + row + '_OldCollectionGroupValue').val()) > -1) {
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                    }
                    else {
                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                    }
                }
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_StartDateTextBox').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_EndDateTextBox').removeAttr('disabled');

                //$('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_FeeDurationTextBox').removeAttr('disabled');
            }
        }
        function VariableCheckBoxClick(obj) {
            var table = document.getElementById('ctl00_CP_FeeSetupGridView');
            row = obj.parentNode.parentNode.parentNode.rowIndex + 1;
            rowindex = row - 1;
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;
            if (chkselect == true) {
                if (row < 10) {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').value = '';
                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {

                        $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').removeAttr('disabled');
                    }
                }
                else if (row > 9) {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').value = '';
                    var FeeHeadNumber = table.rows[rowindex].cells[0].childNodes[1].childNodes[5].value;
                    if (FeeHeadNumber == 1003) {

                        $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').removeAttr('disabled');
                    }
                }
            }
            else {
                if (row < 10) {
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('class');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').removeAttr('readonly');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').value = '';
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').value = '';
                }
                else if (row > 9) {
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('class');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').removeAttr('readonly');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').value = '';
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').value = '';
                }

            }
            //$.ajax({
            //    type: "POST",
            //    url: "FeeSetup.aspx/SelectCheckBoxChecked",
            //    data: JSON.stringify({ "RowIndex": parseInt(row), "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
            //    contentType: "application/json; charset=utf-8",
            //    dataType: "json",
            //});
        }
        function HeaderCheckBoxCheck(obj) {
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;
            feesetupId = obj.nextElementSibling.value;
            ClassId = $('#ctl00_CP_ClassDropDownList').val();
            batchid = $('#ctl00_CP_BatchDropDownList').val();
            AdmissionCategoryId = $('#ctl00_CP_AdmissionCategoryDropDownList').val();
            if (chkselect == true) {
                for (var i = 2; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[1].innerText != "") {
                        if (i < 10) {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').prop('checked', true);
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsOptionalCheckBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsVariableCheckBox').removeAttr('disabled');

                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('class');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('readonly');

                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_StartDateTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_EndDateTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_FeeDurationTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsServiceTaxCheckBox').removeAttr('disabled');
                            if (i < table.rows.length + 1) {
                                var FeeHeadNumber = table.rows[i - 1].cells[0].childNodes[1].childNodes[5].value;
                                if (FeeHeadNumber == 1003) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_LevelAmountTextBox').removeAttr('disabled');
                                }
                            }
                            feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
                            if (feesetupId != 0) {
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsVariableCheckBox').attr('disabled', 'disabled');
                                ReceiptChange = table.rows[i - 1].cells[0].childNodes[1].childNodes[7].value;
                                if (ReceiptChange == "True") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                }
                                else if (ReceiptChange == "False") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_OldCollectionGroupValue').val()) > -1) {
                                        $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                                    }
                                    else {
                                        $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                    }
                                }
                                if ($('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsVariableCheckBox').prop("checked") == true) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').attr('disabled', 'disabled');
                                }
                            }
                        }
                        else if (i > 9) {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').attr('checked', 'checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').prop('checked', true);
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsOptionalCheckBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsVariableCheckBox').removeAttr('disabled');

                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('class');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('readonly');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_StartDateTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_EndDateTextBox').removeAttr('disabled');

                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_FeeDurationTextBox').removeAttr('disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsServiceTaxCheckBox').removeAttr('disabled');
                            if (i < table.rows.length + 1) {
                                var FeeHeadNumber = table.rows[i - 1].cells[0].childNodes[1].childNodes[5].value;
                                if (FeeHeadNumber == 1003) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_LevelAmountTextBox').removeAttr('disabled');
                                }
                            }
                            feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
                            if (feesetupId != 0) {
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsVariableCheckBox').attr('disabled', 'disabled');
                                ReceiptChange = table.rows[i - 1].cells[0].childNodes[1].childNodes[7].value;
                                if (ReceiptChange == "True") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').removeAttr('disabled');
                                }
                                else if (ReceiptChange == "False") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl' + i + '_OldCollectionGroupValue').val()) > -1) {
                                        $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                                    }
                                    else {
                                        $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                    }
                                }

                                if ($('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsVariableCheckBox').prop("checked") == true) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').attr('disabled', 'disabled');
                                }
                            }
                        }
                        $.ajax({
                            type: "POST",
                            url: "FeeSetup.aspx/SelectCheckBoxChecked",
                            data: JSON.stringify({ "RowIndex": i, "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {

                                if (data.d.returnCode == "1") {
                                    row = data.d.row;
                                    enableControls(row);
                                }
                            }
                        });
                    }
                }
            }
            else if (chkselect == false) {
                for (var i = 2; i < table.rows.length ; i++) {
                    if (table.rows[i].cells[1].innerText != "") {
                        if (i < 10) {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').removeAttr('checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').prop('checked', false);

                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                            //IO.prop("disabled", false);
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsVariableCheckBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_StartDateTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_EndDateTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_FeeDurationTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');

                            var FeeHeadNumber = table.rows[i - 1].cells[0].childNodes[1].childNodes[5].value;
                            if (FeeHeadNumber == 1003) {

                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_LevelAmountTextBox').attr('disabled', 'disabled');
                            }
                            feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
                            if (feesetupId != 0) {
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').attr('checked');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').prop('checked', true);
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('class');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').removeAttr('readonly');
                                if ($('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_IsVariableCheckBox').prop("checked") == true) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_AmountTextBox').attr('disabled', 'disabled');
                                }
                                ReceiptChange = table.rows[i - 1].cells[0].childNodes[1].childNodes[7].value;
                                if (ReceiptChange == "True") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').removeAttr('disabled');

                                }
                                else if (ReceiptChange == "False") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_OldCollectionGroupValue').val()) > -1) {
                                        $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                                    } else {
                                        $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                    }

                                }
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_StartDateTextBox').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_EndDateTextBox').removeAttr('disabled');

                                //$('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_FeeDurationTextBox').removeAttr('disabled');
                                ValidateHeader(i);
                            }
                        }
                        else if (i > 9) {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').removeAttr('checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').prop('checked', false);

                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                            //IO.prop("disabled", false);
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsVariableCheckBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_StartDateTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_EndDateTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_FeeDurationTextBox').attr('disabled', 'disabled');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');

                            var FeeHeadNumber = table.rows[i - 1].cells[0].childNodes[1].childNodes[5].value;
                            if (FeeHeadNumber == 1003) {

                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_LevelAmountTextBox').attr('disabled', 'disabled');
                            }
                            feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
                            if (feesetupId != 0) {
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').attr('checked');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').prop('checked', true);
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('class');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').removeAttr('readonly');
                                if ($('#ctl00_CP_FeeSetupGridView_ctl' + i + '_IsVariableCheckBox').prop("checked") == true) {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_AmountTextBox').attr('disabled', 'disabled');
                                }
                                ReceiptChange = table.rows[i - 1].cells[0].childNodes[1].childNodes[7].value;
                                if (ReceiptChange == "True") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').removeAttr('disabled');
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').removeAttr('disabled');

                                }
                                else if (ReceiptChange == "False") {
                                    $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                                    if (parseInt($('#ctl00_CP_FeeSetupGridView_ctl' + i + '_OldCollectionGroupValue').val()) > -1) {
                                        $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                                    } else {
                                        $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                    }
                                }
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_StartDateTextBox').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_EndDateTextBox').removeAttr('disabled');

                                //$('#ctl00_CP_FeeSetupGridView_ctl' + i + '_CollectionGroupDropDownList').removeAttr('disabled');
                                $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_FeeDurationTextBox').removeAttr('disabled');
                                ValidateHeader(i);
                            }
                        }
                        $.ajax({
                            type: "POST",
                            url: "FeeSetup.aspx/SelectCheckBoxChecked",
                            data: JSON.stringify({ "RowIndex": i, "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {

                                if (data.d.returnCode == "1") {
                                    row = data.d.row;
                                    $(obj).attr('checked', 'checked');
                                    $(obj).prop('checked', false);
                                    disableRows(row);
                                }
                            }
                        });
                    }
                }
            }
        }
        function disableRows(row) {
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            if (row < 10) {
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                //IO.prop("disabled", false);
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_AmountTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_StartDateTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_EndDateTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_FeeDurationTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');

                var FeeHeadNumber = table.rows[row - 1].cells[0].childNodes[1].childNodes[5].value;
                if (FeeHeadNumber == 1003) {

                    $('#ctl00_CP_FeeSetupGridView_ctl0' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                }
            }
            if (row > 9) {
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsOptionalCheckBox').attr('disabled', 'disabled');
                //IO.prop("disabled", false);
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsVariableCheckBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_AmountTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_StartDateTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_EndDateTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_ReceiptBookDropDownList').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_CollectionGroupDropDownList').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_FeeDurationTextBox').attr('disabled', 'disabled');
                $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_IsServiceTaxCheckBox').attr('disabled', 'disabled');

                var FeeHeadNumber = table.rows[row - 1].cells[0].childNodes[1].childNodes[5].value;
                if (FeeHeadNumber == 1003) {

                    $('#ctl00_CP_FeeSetupGridView_ctl' + row + '_LevelAmountTextBox').attr('disabled', 'disabled');
                }
            }
        }
        function ValidateHeader(i) {
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
            ClassId = $('#ctl00_CP_ClassDropDownList').val();
            batchid = $('#ctl00_CP_BatchDropDownList').val();
            AdmissionCategoryId = $('#ctl00_CP_AdmissionCategoryDropDownList').val();
            chkselect = true;
            $.ajax({
                type: "POST",
                url: "FeeSetup.aspx/SelectCheckBoxChecked",
                data: JSON.stringify({ "RowIndex": i, "chkselect": chkselect, "ClassId": parseInt(ClassId), "BatchId": parseInt(batchid), "AdmissionCategoryId": parseInt(AdmissionCategoryId), "FeeSetupId": parseInt(feesetupId) }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {

                    if (data.d.returnCode == "1") {
                        if (i < 10) {
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').attr('checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').prop('checked', false);
                        } else if (i > 9) {
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').attr('checked');
                            $('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').prop('checked', false);
                        }
                    }
                },
                error: function (xhr, status, error) {
                    var err = eval("(" + xhr.responseText + ")");
                    console.log(err.Message);
                }
            });
        }
        function ValueGet() {
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            SelectValue = $('#ctl00_CP_ApplyDropDownList').val();
            SelectedHead = $('#ctl00_CP_FeeHeadDropDownList').val();
            EnteredValue = ApplyAllTextBox.value;
            if (SelectValue == -1) {
                alert('Select Value');
            }
            else if (EnteredValue == "") {
                alert('Enter Value');
            }
            for (var i = 2; i < table.rows.length; i++) {
                if (table.rows[i - 1].cells[1].innerText != "") {
                    if (i < 10) {
                        feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;
                        SelectedFeeHead = $("#ctl00_CP_FeeHeadDropDownList option:selected").text();
                        if ($('#ctl00_CP_FeeSetupGridView_ctl0' + i + '_SelectCheckBox').is(':checked') || feesetupId != 0) {
                            if (table.rows[i - 1].cells[2].innerText == $("#ctl00_CP_FeeHeadDropDownList option:selected").text() || $("#ctl00_CP_FeeHeadDropDownList option:selected").text() == "- ALL -") {
                                if (SelectValue == 1) {
                                    table.rows[i - 1].cells[5].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 2) {
                                    table.rows[i - 1].cells[6].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 3) {
                                    table.rows[i - 1].cells[7].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 4 && table.rows[i - 1].cells[8].childNodes[1].disabled == false) {
                                    $("#ctl00_CP_FeeSetupGridView_ctl0" + i + "_ReceiptBookDropDownList").find("option:contains(" + EnteredValue + ")").attr('selected', 'selected');
                                    AutoFillCollectionGroupDropDownList(i);
                                }
                                else if (SelectValue == 6) {
                                    table.rows[i - 1].cells[10].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 7 && table.rows[i - 1].cells[8].childNodes[1].disabled == false) {
                                    table.rows[i - 1].cells[11].childNodes[1].value = EnteredValue;
                                }
                            }

                        }
                    }
                    else if (i > 9) {
                        feesetupId = table.rows[i - 1].cells[0].childNodes[1].childNodes[3].value;

                        if ($('#ctl00_CP_FeeSetupGridView_ctl' + i + '_SelectCheckBox').is(':checked') || feesetupId != 0) {
                            if (table.rows[i - 1].cells[2].innerText == $("#ctl00_CP_FeeHeadDropDownList option:selected").text() || $("#ctl00_CP_FeeHeadDropDownList option:selected").text() == "- ALL -") {
                                if (SelectValue == 1) {
                                    table.rows[i - 1].cells[5].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 2) {
                                    table.rows[i - 1].cells[6].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 3) {
                                    table.rows[i - 1].cells[7].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 4 && table.rows[i - 1].cells[8].childNodes[1].disabled == false) {
                                    $("#ctl00_CP_FeeSetupGridView_ctl" + i + "_ReceiptBookDropDownList").find("option:contains(" + EnteredValue + ")").attr('selected', 'selected');
                                    AutoFillCollectionGroupDropDownList(i);
                                }
                                else if (SelectValue == 6) {
                                    table.rows[i - 1].cells[10].childNodes[1].value = EnteredValue;
                                }
                                else if (SelectValue == 7 && table.rows[i - 1].cells[8].childNodes[1].disabled == false) {
                                    table.rows[i - 1].cells[11].childNodes[1].value = EnteredValue;
                                }
                            }
                        }
                    }
                }
            }
        }
        function AutoFillCollectionGroupDropDownList(obj) {
            var table = document.getElementById('<%=FeeSetupGridView.ClientID %>');
            var row = obj;
            var Id = table.rows[row - 1].cells[8].childNodes[1].value;
            var state = table.rows[row - 1].cells[9].getElementsByTagName("select")[0];
            $.ajax({
                type: "POST",
                url: "/Pages/FeeManagement/FeeSetup.aspx/FillCollectionGroupDropDownList",
                data: '{"Id":"' + Id + '"}',
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var datas = $.parseJSON(data.d);
                    $(state).html("");
                    $(state).append($("<option></option>").val("-1").html("- Select -"));
                    $.each(datas, function (index, itemData) {
                        $(state).append($("<option></option>").val(itemData['Id']).html(itemData['Title']));
                    });
                }
            });
        }
        function ApplyToOtherClass(obj) {
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;

            if (chkselect == true) {
                ctl00_CP_DivClassCheckBoxList.style.display = "Block";
            }
            else if (chkselect == false) {
                ctl00_CP_DivClassCheckBoxList.style.display = "none";
            }
        }

        function ClassCheckBox(obj) {
            var chkselect = false;
            if ($(obj).is(':checked'))
                chkselect = true;
            else
                chkselect = false;
            if (ctl00_CP_ClassDropDownList.selectedIndex <= 0) {
                alert('Select Class');
            }
            else if (ctl00_CP_ClassDivisionCheckBoxList.rows.length == 0) {
                alert('No Records Found');
            }
            else if (chkselect == true) {
                for (var i = 0; i < ctl00_CP_ClassDivisionCheckBoxList.rows.length; i++) {

                    $("#ctl00_CP_ClassDivisionCheckBoxList_" + i).prop('checked', true);
                }
            }
            else if (chkselect == false) {
                for (var i = 0; i < ctl00_CP_ClassDivisionCheckBoxList.rows.length; i++) {

                    $("#ctl00_CP_ClassDivisionCheckBoxList_" + i).prop('checked', false);
                }
            }
        }
        function ValidateForSelectClass(obj) {
            if (ctl00_CP_OrganizationDropDownList.selectedIndex <= 0) {
                alert('Select Organization');
            }
            else if (ctl00_CP_BatchDropDownList.selectedIndex <= 0) {
                alert('Select Batch');
            }
            else if (ctl00_CP_AdmissionCategoryDropDownList.selectedIndex <= 0) {
                alert('Select Fee Category');
            }
            Batch = ctl00_CP_BatchDropDownList.value;
            Admissioncategory = ctl00_CP_AdmissionCategoryDropDownList.value;
            Organization = ctl00_CP_OrganizationDropDownList.value;
            var checkBoxList = document.getElementById("<%=ClassDivisionCheckBoxList.ClientID%>");
            var checkBoxes = checkBoxList.getElementsByTagName("INPUT");
            Count = 0;
            for (var i = 0; i < checkBoxes.length; i++) {
                if (checkBoxes[i].checked) {
                    Count++;
                    var value = checkBoxes[i].value;
                    var text = checkBoxes[i].parentNode.getElementsByTagName("LABEL")[0].innerHTML;
                    Class = text;
                    $.ajax({
                        type: "POST",
                        url: "/Pages/FeeManagement/FeeSetup.aspx/ValidateApplyClass",
                        data: JSON.stringify({ "Class": Class, "Row": i, "BatchId": parseInt(Batch), "AdmissionCategoryId": parseInt(Admissioncategory), "Organization": parseInt(Organization) }),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            debugger;
                            returnCode = data.d.returnCode;
                            // alert(validated);
                            if (returnCode == "-1") {
                                alert('Fee Setup already created can not applicable to class :' + data.d.Class);

                            }
                            else if (returnCode == "1") {
                                Row = data.d.row;
                                ApplyForSelectClass(Row);
                            }
                        }
                    });
                }
            }
            if (Count == 0) {
                alert('Select Class To Apply');
            }
        }
        function ApplyForSelectClass(Row) {

            var checkBoxList = document.getElementById("<%=ClassDivisionCheckBoxList.ClientID%>");
            var checkBoxes = checkBoxList.getElementsByTagName("INPUT");

            organization = ctl00_CP_OrganizationDropDownList.value;
            FromclassId = ctl00_CP_ClassDropDownList.value;
            FromAdmissionCategoryId = ctl00_CP_AdmissionCategoryDropDownList.value;
            FromBatchId = ctl00_CP_BatchDropDownList.value;

            ToAdmissionCategoryId = ctl00_CP_AdmissionCategoryDropDownList.value;
            ToBatchId = ctl00_CP_BatchDropDownList.value;

            var text = checkBoxes[Row].parentNode.getElementsByTagName("LABEL")[0].innerHTML;
            Class = text;
            ToClass = Class;

            $.ajax({
                type: "POST",
                url: "/Pages/FeeManagement/FeeSetup.aspx/ApplyForSelectedClass",
                data: JSON.stringify({ "FromClass": FromclassId, "FromBatch": parseInt(FromBatchId), "FromAdmissionCategoryId": parseInt(FromAdmissionCategoryId), "Organization": parseInt(Organization), "Toclass": ToClass }),
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (data) {

                    if (data.d.returnCode == "1") {
                        alert('Apply to Class ' + data.d.Class + ' Successfully');
                        return;
                    }
                }
            });
        }

        function CollectionGroupChange(obj) {
            var row = obj.parentNode.parentNode;
            var rowIndex = row.rowIndex - 1;
            var state = row.cells[9].getElementsByTagName("input")[0];
            state.value = obj.value;
        }
    </script>
</asp:Content>
