<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
   CodeFile="SearchBatch.aspx.cs" Inherits="SearchBatch" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
   <style type="text/css">
      .style5
      {
         width: 143px;
      }
      .style10
      {
         width: 219px;
      }
      .style14
      {
         width: 250px;
      }
      .style15
      {
         width: 66%;
      }
      .style54
      {
         width: 101px;
      }
      .style68
      {
         width: 251px;
      }
      .style70
      {
         width: 100%;
         height: 172px;
      }
      .style72
      {
         width: 320px;
         height: 272px;
      }
      .style77
      {
         width: 99px;
         height: 66px;
      }
      .style78
      {
         height: 66px;
         width: 337px;
      }
      .style80
      {
         height: 17px;
         width: 337px;
      }
      .style82
      {
         font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;
      }
      .style86
      {
         width: 337px;
      }
      .style89
      {
         width: 251px;
         height: 272px;
      }
      .style90
      {
         height: 17px;
      }
      .style96
      {
         width: 251px;
         height: 10px;
      }
      .style98
      {
         width: 320px;
      }
      .style99
      {
         height: 10px;
         width: 320px;
      }
      .style101
      {
         width: 424px;
         height: 10px;
      }
      .style102
      {
         width: 424px;
         height: 272px;
      }
      .style105
      {
         width: 424px;
      }
      .style106
      {
         width: 99px;
         height: 32px;
      }
      .style107
      {
         height: 32px;
         width: 337px;
      }
      .style110
      {
         width: 99px;
         height: 17px;
      }
      .style111
      {
         width: 99px;
      }
      </style>
   <script type="text/javascript">
      function ValidateSearchFields(source, args) {
         var varAccountID = document.getElementById('<%= txtBoxAccountID.ClientID %>');
         var varLastName = document.getElementById('<%= txtBoxLastName.ClientID %>');
         var varFirstName = document.getElementById('<%= txtBoxFirstName.ClientID %>');

         if ((varLastName.value != '') || (varFirstName.value != '')) {
            args.IsValid = true;
         }
         else if (varAccountID.value != '') {
            args.IsValid = true;
         }
         else {
            args.IsValid = false;
         }
      }

      function ValidateChequeNumber(source2, args2) {
         var varChequeAmount = document.getElementById('<%= txtBoxAmountPaidByCheque.ClientID %>');
         var varChequeNumber = document.getElementById('<%= txtBoxChequeNumber.ClientID %>');

         if ((varChequeAmount.value != 0) && (varChequeNumber.value == '')) {
            args2.IsValid = false;
         }
         else {
            args2.IsValid = true;
         }
      }
      function ValidateBatchAdjustmentAmount(source3, args3) {
         var varCashAmount = document.getElementById('<%= txtBoxAmountPaidByCash.ClientID %>');
         var varChequeAmount = document.getElementById('<%= txtBoxAmountPaidByCheque.ClientID %>');
         var temp = document.getElementById('<%= lblBatchAmount.ClientID %>');
         var varBatchAmount = temp.innerHTML.toString();

         if ((Number(varChequeAmount.value) + Number(varCashAmount.value)) == 0) {
            args3.IsValid = false;
         }
         else if (Number(varChequeAmount.value) < 0) {
            args3.IsValid = false;
         }
         else if (Number(varCashAmount.value) < 0) {
            args3.IsValid = false;
         }
         else if ((Number(varChequeAmount.value) + Number(varCashAmount.value)) > Number(varBatchAmount)) {
            args3.IsValid = false;
         }
         else {
            args3.IsValid = true;
         }
      }

   </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
   
<%--   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>--%>

   <div style="float:left; width:"50%">
   <h2>
      Batch Renewal Search</h2>
   <p>
      Please enter at least one search criteria.</p>
<%--   <asp:Panel ID="Panel1" runat="server" GroupingText="Account Search Criteria" 
         Width="270px" DefaultButton="btnSearch">--%>
      <table class="style14">
         <tr>
            <td class="style5">
               Last Name:
            </td>
            <td class="style10" colspan="2">
               <asp:TextBox ID="txtBoxLastName" runat="server" AutoCompleteType="Disabled" 
                  Width="150px" Height="18px"
                  TabIndex="1" CssClass="eitField"></asp:TextBox>
               <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please enter at least one search criteria."
                  OnServerValidate="CustomValidator1_ServerValidate" ClientValidationFunction="ValidateSearchFields"
                  Display="Dynamic" ValidationGroup="SearchCriteria" Font-Bold="True" ForeColor="Red">*</asp:CustomValidator>
            </td>
         </tr>
         <tr>
            <td class="style5">
               First Name:
            </td>
            <td class="style10" colspan="2">
               <asp:TextBox ID="txtBoxFirstName" runat="server" AutoCompleteType="Disabled" 
                  Width="150px" Height="18px"
                  TabIndex="2" CssClass="eitField"></asp:TextBox>
            </td>
         </tr>
         <tr>
            <td class="style5">
               Jamatkhana:
            </td>
            <td class="style10" colspan="2">
               <asp:DropDownList ID="ddlJamatkhana" runat="server" AppendDataBoundItems="True" DataSourceID="adsJK"
                  DataTextField="JKName" DataValueField="JKID" Width="155px" Height="20px" 
                  TabIndex="3" CssClass="eitField">
                  <asp:ListItem Value="0">- Select Jamatkhana -</asp:ListItem>
               </asp:DropDownList>
            </td>
         </tr>

<%--         <tr>
            <td class="style5">
               Telephone:
            </td>
            <td class="style10" colspan="2">
               <asp:TextBox ID="txtBoxTelephone" runat="server" Width="150px" AutoCompleteType="Disabled" Height="18px"
                  TabIndex="4"></asp:TextBox>
            </td>
         </tr>--%>

         <tr>
            <td class="style5">
               Account ID:
            </td>
            <td class="style10" colspan="2">
               <asp:TextBox ID="txtBoxAccountID" runat="server" AutoCompleteType="Disabled" 
                  Width="150px" Height="18px"
                  TabIndex="5" CssClass="eitField"></asp:TextBox>
            </td>
         </tr>

         <tr>
            <td class="style5">
            </td>
            <td class="style54">
               <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search"
                  Width="65px" TabIndex="6" CssClass="eitField" />
            </td>
            <td class="style10" align="center">
               <asp:Button ID="btnClear" runat="server" Text="Clear" Width="65px" OnClick="btnClear_Click"
                  TabIndex="7" CssClass="eitField" />
            </td>
         </tr>
         <tr>
            <td colspan="3">
                <asp:ValidationSummary ID="ValidationSummary2" runat="server" CssClass="failureNotification" ValidationGroup="SearchCriteria" />
            </td>
         </tr>
      </table>
<%--   </asp:Panel>--%>
   </div>
   <div style="float:left; width:"100%">
   <table class="style15">
      <tr>
         <td>
            <h2>
               Batch Renewal Search Results:</h2>
         </td>
         <td>
            &nbsp;
         </td>
      </tr>
      <tr>
         <td>
            <asp:GridView ID="gvBatchSearch" runat="server" AllowPaging="True" AutoGenerateColumns="False"
               CellPadding="4" DataKeyNames="AccountID" DataSourceID="adsSearchBatch" ForeColor="#333333"
               GridLines="None" 
               EmptyDataText="No accounts matching your search criteria were found." SelectedIndex="0"
               OnPageIndexChanging="gvBatchSearch_PageIndexChanging" Width="680px" 
               onselectedindexchanged="gvBatchSearch_SelectedIndexChanged" 
               onselectedindexchanging="gvBatchSearch_SelectedIndexChanging" PageSize="6">
               <AlternatingRowStyle BackColor="#D0FFFF" ForeColor="#284775" />
               <Columns>
                  <asp:CommandField ShowSelectButton="True" />
                  <asp:BoundField DataField="AccountID" HeaderText="ID" InsertVisible="False" SortExpression="AccountID"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:BoundField DataField="MemberLastName" HeaderText="Last" SortExpression="MemberLastName"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:BoundField DataField="MemberMiddleName" HeaderText="Middle" SortExpression="MemberFirstName"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:BoundField DataField="MemberFirstName" HeaderText="First" SortExpression="MemberFirstName"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:BoundField DataField="AccountRenewalYear" HeaderText="Renewal Year" SortExpression="Renewal Year"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:BoundField DataField="JKName" HeaderText="JK" SortExpression="JKName" HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
                  <asp:CheckBoxField DataField="MemberPrimary" HeaderText="Primary" SortExpression="MemberPrimary"
                     ItemStyle-HorizontalAlign="Center">
                     <ItemStyle HorizontalAlign="Center"></ItemStyle>
                  </asp:CheckBoxField>
                  <asp:BoundField DataField="AccountStatus" HeaderText="Account Status" SortExpression="AccountStatus"
                     HeaderStyle-HorizontalAlign="Left">
                     <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                  </asp:BoundField>
               </Columns>
               <EditRowStyle BackColor="#DDDDDD" />
               <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
               <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
               <PagerSettings PageButtonCount="5" />
               <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
               <RowStyle BackColor="#EFF3FB" />
               <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
               <SortedAscendingCellStyle BackColor="#F5F7FB" />
               <SortedAscendingHeaderStyle BackColor="#6D95E1" />
               <SortedDescendingCellStyle BackColor="#E9EBEF" />
               <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
         </td>
         <td>
            &nbsp;
         </td>
      </tr>
   </table>
   </div>
   <div style="clear:both; width:"100%">
      <table style="width: 75%;">
         <tr>
            <td class="style98" valign="top">
               &nbsp;
               </td>
            <td valign="top" class="style105">
               &nbsp;
               </td>
            <td valign="top" class="style68">
               &nbsp;</td>
         </tr>
         <tr>
            <td class="style98" valign="top">
               <asp:GridView ID="gvAccountBatches" runat="server" AutoGenerateColumns="False" 
                  CellPadding="4" DataSourceID="adsAccountBatches" 
                  ForeColor="#333333" GridLines="None" DataKeyNames="BatchID" 
                  onselectedindexchanged="gvAccountBatches_SelectedIndexChanged" 
                  Caption="RECENT BATCH MATCHING THE SELECTED ACCOUNT" Width="675px" 
                  CaptionAlign="Left" AllowPaging="True" PageSize="3">
                  <AlternatingRowStyle BackColor="White" />
                  <Columns>
                     <asp:CommandField ShowSelectButton="True" >
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                     </asp:CommandField>
                     <asp:BoundField DataField="BatchID" HeaderText="Batch ID" 
                        SortExpression="BatchID" >
                     <HeaderStyle HorizontalAlign="Left" Width="25px" />
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="AccountID" HeaderText="Account ID" 
                        SortExpression="AccountID" >
                     <HeaderStyle HorizontalAlign="Left" Width="25px" />
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="JKName" HeaderText="Jamatkhana" 
                        SortExpression="JKName" >
                     <HeaderStyle HorizontalAlign="Left" Width="60px" />
                     <ItemStyle HorizontalAlign="Left" Width="60px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchCreationDate" HeaderText="Date Created" 
                        SortExpression="BatchCreationDate" DataFormatString="{0:dd MMM yyyy}">
                     <HeaderStyle HorizontalAlign="Left" Width="90px" />
                     <ItemStyle HorizontalAlign="Left" Width="90px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="UserName" HeaderText="Created By" 
                        SortExpression="UserName" >
                     <HeaderStyle HorizontalAlign="Left" Width="60px" />
                     <ItemStyle HorizontalAlign="Left" Width="60px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchTotal" HeaderText="Batch Total" 
                        SortExpression="BatchTotal" DataFormatString="{0:C}">
                     <HeaderStyle HorizontalAlign="Left" Width="60px" />
                     <ItemStyle HorizontalAlign="Left" Width="60px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchComments" HeaderText="Comments" 
                        SortExpression="BatchComments">
                     <HeaderStyle HorizontalAlign="Left" Width="200px" />
                     <ItemStyle HorizontalAlign="Left" Width="200px" />
                     </asp:BoundField>
                  </Columns>
                  <EditRowStyle BackColor="#2461BF" />
                  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                  <RowStyle BackColor="#EFF3FB" />
                  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                  <SortedAscendingCellStyle BackColor="#F5F7FB" />
                  <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                  <SortedDescendingCellStyle BackColor="#E9EBEF" />
                  <SortedDescendingHeaderStyle BackColor="#4870BE" />
               </asp:GridView>
            </td>
            <td valign="top" class="style105">
               <asp:GridView ID="gvBatchAdjustments" runat="server" 
                  AutoGenerateColumns="False" CellPadding="4" DataSourceID="adsBatchAdjustments" 
                  ForeColor="#333333" GridLines="None" Width="550px" 
                  Caption="BATCH ADJUSTMENTS" CaptionAlign="Left" PageSize="3" 
                  AllowPaging="True">
                  <AlternatingRowStyle BackColor="White" />
                  <Columns>
                     <asp:BoundField DataField="BatchAdjustmentBatchID" HeaderText="Batch ID" 
                        SortExpression="BatchAdjustmentBatchID">
                     <HeaderStyle HorizontalAlign="Left" Width="25px" />
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentAccountID" HeaderText="Account ID" 
                        SortExpression="BatchAdjustmentAccountID">
                     <HeaderStyle HorizontalAlign="Left" Width="25px" />
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentCashAmount" DataFormatString="{0:C}" 
                        HeaderText="Cash" SortExpression="BatchAdjustmentCashAmount">
                     <HeaderStyle HorizontalAlign="Left" Width="30px" />
                     <ItemStyle HorizontalAlign="Left" Width="30px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentChequeAmount" DataFormatString="{0:C}" 
                        HeaderText="Cheque" SortExpression="BatchAdjustmentChequeAmount">
                     <HeaderStyle HorizontalAlign="Left" Width="30px" />
                     <ItemStyle HorizontalAlign="Left" Width="30px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentChequeNumber" 
                        HeaderText="Cheque Number" SortExpression="BatchAdjustmentChequeNumber">
                     <HeaderStyle HorizontalAlign="Left" Width="20px" />
                     <ItemStyle HorizontalAlign="Left" Width="20px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentCreatedBy" HeaderText="Entered By" 
                        SortExpression="BatchAdjustmentCreatedBy">
                     <HeaderStyle HorizontalAlign="Left" Width="65px" />
                     <ItemStyle HorizontalAlign="Left" Width="65px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentCreatedDate" 
                        DataFormatString="{0:dd MMM yyyy}" HeaderText="Date Entered" 
                        SortExpression="BatchAdjustmentCreatedDate">
                     <HeaderStyle HorizontalAlign="Left" Width="90px" />
                     <ItemStyle HorizontalAlign="Left" Width="90px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchAdjustmentComments" HeaderText="Comments" 
                        SortExpression="BatchAdjustmentComments">
                     <HeaderStyle HorizontalAlign="Left" Width="300px" />
                     <ItemStyle HorizontalAlign="Left" Width="300px" />
                     </asp:BoundField>
                  </Columns>
                  <EditRowStyle BackColor="#2461BF" />
                  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                  <RowStyle BackColor="#EFF3FB" />
                  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                  <SortedAscendingCellStyle BackColor="#F5F7FB" />
                  <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                  <SortedDescendingCellStyle BackColor="#E9EBEF" />
                  <SortedDescendingHeaderStyle BackColor="#4870BE" />
               </asp:GridView>
            </td>
            <td valign="top" class="style68">               
               &nbsp;</td>
         </tr>
         <tr>
            <td class="style99" valign="top">
               </td>
            <td class="style101" valign="top">
            </td>
            <td class="style96" valign="top">
               </td>
         </tr>
         <tr>
            <td class="style72" valign="top">
               <asp:GridView ID="gvBatchDetails" runat="server" AllowPaging="True" 
                  AutoGenerateColumns="False" CellPadding="4" DataKeyNames="BatchID,AccountID" 
                  DataSourceID="adsBatchDetails" ForeColor="#333333" GridLines="None" 
                  onselectedindexchanged="gvBatchDetails_SelectedIndexChanged" Width="675px" 
                  Caption="BATCH DETAILS" CaptionAlign="Left" 
                  onrowdatabound="gvBatchDetails_RowDataBound">
                  <AlternatingRowStyle BackColor="White" />
                  <Columns>
                     <asp:CommandField ShowSelectButton="True" SelectText="Adjust" >
                     <HeaderStyle Width="25px" />
                     <ItemStyle Width="25px" />
                     </asp:CommandField>
                     <asp:BoundField DataField="BatchID" HeaderText="Batch ID" 
                        SortExpression="BatchID">
                     <HeaderStyle HorizontalAlign="Left" Width="20px" />
                     <ItemStyle HorizontalAlign="Left" Width="20px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="AccountID" HeaderText="Account ID" 
                        SortExpression="AccountID">
                     <HeaderStyle HorizontalAlign="Left" Width="20px" />
                     <ItemStyle HorizontalAlign="Left" Width="20px" />
                     </asp:BoundField>
<%--                     <asp:BoundField DataField="MemberLastName" HeaderText="Last Name" 
                        SortExpression="MemberLastName">
                     <HeaderStyle HorizontalAlign="Left" Width="60px" />
                     <ItemStyle HorizontalAlign="Left" Width="60px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="MemberMiddleName" HeaderText="Middle" 
                        SortExpression="MemberMiddleName" Visible="False" />
                     <asp:BoundField DataField="MemberFirstName" HeaderText="First Name" 
                        SortExpression="MemberFirstName">
                     <HeaderStyle HorizontalAlign="Left" Width="60px" />
                     <ItemStyle HorizontalAlign="Left" Width="60px" />
                     </asp:BoundField>--%>
                     <asp:BoundField DataField="MemberFullName" HeaderText="Last, First Name" 
                        SortExpression="MemberFullName">
                     <HeaderStyle HorizontalAlign="Left" Width="90px" />
                     <ItemStyle HorizontalAlign="Left" Width="90px" />
                     </asp:BoundField>
<%--                     <asp:TemplateField HeaderText="Last, First Name">
                        <ItemTemplate>
                           <asp:Label ID="Label5" runat="server" Text='<%# String.Format("{0}, {1}", FormatLastNameToUpper( Eval("MemberLastName")), Eval("MemberFirstName")) %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Width="100px" HorizontalAlign="Left" />
                        <ItemStyle HorizontalAlign="Left" Width="100px" />
                     </asp:TemplateField>--%>
                     <asp:BoundField DataField="AmountDue" DataFormatString="{0:C}" 
                        HeaderText="Amount Due" SortExpression="AmountDue">
                     <HeaderStyle HorizontalAlign="Left" Width="40px" />
                     <ItemStyle HorizontalAlign="Left" Width="40px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="AmountPaid" DataFormatString="{0:C}" 
                        HeaderText="Amount Paid" SortExpression="AmountPaid">
                     <HeaderStyle HorizontalAlign="Left" Width="40px" />
                     <ItemStyle HorizontalAlign="Left" Width="40px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchPaymentType" HeaderText="Paid by" 
                        SortExpression="BatchPaymentType">
                     <HeaderStyle HorizontalAlign="Left" Width="40px" />
                     <ItemStyle HorizontalAlign="Left" Width="40px" />
                     </asp:BoundField>
                     <asp:BoundField DataField="BatchDetailsChequeNumber" HeaderText="Cheque Number" 
                        SortExpression="BatchDetailsChequeNumber">
                     <HeaderStyle HorizontalAlign="Left" Width="40px" />
                     <ItemStyle HorizontalAlign="Left" Width="40px" />
                     </asp:BoundField>
                     <asp:CheckBoxField DataField="MemberPrimary" HeaderText="Primary" 
                        SortExpression="MemberPrimary" Visible="False" />
                     <asp:BoundField DataField="BatchDetailsComments" HeaderText="Comments" 
                        SortExpression="BatchDetailsComments">
                     <HeaderStyle HorizontalAlign="Left" Width="200px" />
                     <ItemStyle HorizontalAlign="Left" Width="200px" />
                     </asp:BoundField>
                        
                  </Columns>
                  <EditRowStyle BackColor="#2461BF" />
                  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                  <RowStyle BackColor="#EFF3FB" />
                  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                  <SortedAscendingCellStyle BackColor="#F5F7FB" />
                  <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                  <SortedDescendingCellStyle BackColor="#E9EBEF" />
                  <SortedDescendingHeaderStyle BackColor="#4870BE" />
               </asp:GridView>
               <br />
               <asp:Label ID="lblError" runat="server" CssClass="failureNotification"></asp:Label>
            </td>
            <td class="style102" valign="top">
               &nbsp;
               <asp:Panel ID="pnlAdjustments" runat="server" BackColor="#FFFFD5" 
                  Height="399px" Width="440px">
                  <table class="style70" border="1">
                     <tr>
                        <td align="center" class="style90" colspan="2">
                           <asp:Label ID="lblHeader" runat="server" Font-Bold="True" 
                              Text="ADD BATCH ADJUSTMENT"></asp:Label>
                        </td>
                     </tr>
                     <tr>
                        <td class="style110">
                           <asp:Label ID="lblHeaderBatchID" runat="server" Font-Bold="True" 
                              Text="BATCH ID:"></asp:Label>
                        </td>
                        <td class="style80">
                           <asp:Label ID="lblBatchID" runat="server" Text="2081"></asp:Label>
                        </td>
                     </tr>
                     <tr>
                        <td class="style110">
                           <asp:Label ID="lblHeaderAccountID" runat="server" Font-Bold="True" 
                              Text="ACCOUNT ID:"></asp:Label>
                        </td>
                        <td class="style80">
                           <asp:Label ID="lblAccountID" runat="server" Text="2405"></asp:Label>
                        </td>
                     </tr>
                     <tr>
                        <td class="style110">
                           <asp:Label ID="lblHeaderFullName" runat="server" Font-Bold="True" 
                              Text="FULL NAME:"></asp:Label>
                        </td>
                        <td class="style80">
                           <asp:Label ID="lblFullName" runat="server" Text="Full name"></asp:Label>
                        </td>
                     </tr>
                     <tr>
                        <td class="style110">
                           <asp:Label ID="lblHeaderBatchAmount" runat="server" Font-Bold="True" 
                              Text="BATCH AMOUNT:"></asp:Label>
                        </td>
                        <td class="style80">
                           <asp:Label ID="lblBatchAmount" runat="server" Text="230"></asp:Label>
                        </td>
                     </tr>
                     <tr>
                        <td colspan="2">
                           <span class="bold">PAYMENT:</span>
                        </td>
                     </tr>
                     <tr>
                        <td class="style111">
                           Cash amount:</td>
                        <td class="style68">
                           <asp:TextBox ID="txtBoxAmountPaidByCash" runat="server" Width="50px" 
                              AutoCompleteType="Disabled" TabIndex="14" CssClass="eitField"></asp:TextBox>
                              &nbsp;
                           <asp:RequiredFieldValidator ID="RequiredFieldValidatorPaidByCash" runat="server" ControlToValidate="txtBoxAmountPaidByCash"
                              CssClass="failureNotification" Display="Dynamic" ErrorMessage="Adjustment Amount is required. Enter 0 for full payment by cheque."
                              ValidationGroup="ValidationGroupAdjustment" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                        </td>
                     </tr>
                     <tr>
                        <td class="style111">
                           Cheque amount:</td>
                        <td class="style68">
                           <asp:TextBox ID="txtBoxAmountPaidByCheque" runat="server" Width="50px" 
                              AutoCompleteType="Disabled" TabIndex="15" CssClass="eitField"></asp:TextBox>
                              &nbsp;
                           <asp:RequiredFieldValidator ID="RequiredFieldValidatorPaidByCheque" runat="server" ControlToValidate="txtBoxAmountPaidByCheque"
                              CssClass="failureNotification" Display="Dynamic" ErrorMessage="Adjustment Amount is required. Enter 0 for full payment by cash."
                              ValidationGroup="ValidationGroupAdjustment" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                        </td>
                     </tr>
                     <tr>
                        <td class="style111">
                           Cheque number:</td>
                        <td class="style68">
                           <asp:TextBox ID="txtBoxChequeNumber" runat="server" Width="50px" 
                              AutoCompleteType="Disabled" TabIndex="16" CssClass="eitField"></asp:TextBox>
                              &nbsp;
                           <asp:CustomValidator ID="CustomChequeNumberValidator" runat="server" CssClass="failureNotification"
                              ErrorMessage="Cheque number is required if adjustment by cheque." OnServerValidate="ChequeNumberCustomValidator_ServerValidate"
                              ValidationGroup="ValidationGroupAdjustment" ClientValidationFunction="ValidateChequeNumber"
                              Display="Dynamic">*</asp:CustomValidator>
                        </td>
                     </tr>
<%--                     <tr>
                        <td class="style79">
                           <asp:Label ID="lblHeaderAdjustmentAmount" runat="server" Font-Bold="True" 
                              Text="ADJUSTMENT AMOUNT:"></asp:Label>
                        </td>
                        <td class="style80">
                           <asp:TextBox ID="txtboxAmount" runat="server" AutoCompleteType="Disabled" 
                              CssClass="eitField" Width="75px"></asp:TextBox>
                           &nbsp;
                           <asp:RequiredFieldValidator ID="rfvAdjustmentAmount" runat="server" 
                              ControlToValidate="txtboxAmount" CssClass="failureNotification" 
                              Display="Dynamic" ErrorMessage="Adjustment amount is required." Text="*" 
                              ValidationGroup="ValidationGroupAdjustment"></asp:RequiredFieldValidator>

                           <asp:CustomValidator ID="CustomValidatorAdjustmentAmount" runat="server" 
                              ClientValidationFunction="ValidateBatchAdjustmentAmount" 
                              CssClass="failureNotification" Display="Dynamic" 
                              ErrorMessage="Adjustment amount must be greater than 0 and less than the batch amount." 
                              onservervalidate="CustomValidatorAdjustmentAmount_ServerValidate" Text="*" 
                              ValidationGroup="ValidationGroupAdjustment"></asp:CustomValidator>
                        </td>
                     </tr>--%>
                     <tr>
                        <td class="style77">
                           <span class="bold">TYPE OF ADJUSTMENT:</span></td>
                        <td class="style78">
                           <asp:RadioButtonList ID="rblAdjustmentType" runat="server">
                              <asp:ListItem Selected="True" Value="1">Refunds, Stop payments, etc. (Batch reduction)</asp:ListItem>
                              <asp:ListItem Value="2">Payment received (Batch increased)</asp:ListItem>
                           </asp:RadioButtonList>
                        </td>
                     </tr>
                     <tr>
                        <td class="style106">
                           <asp:Label ID="lblReason" runat="server" Font-Bold="True" 
                              Text="REASON FOR ADJUSTMENT:"></asp:Label>
                        </td>
                        <td class="style107">
                           <asp:TextBox ID="txtboxReason" runat="server" AutoCompleteType="Disabled" 
                              CssClass="style82" Height="40px" TextMode="MultiLine" Width="289px"></asp:TextBox>
                           <asp:TextBoxWatermarkExtender ID="txtboxReason_TextBoxWatermarkExtender" 
                              runat="server" Enabled="True" TargetControlID="txtboxReason" 
                              WatermarkCssClass="watermarked" 
                              WatermarkText="Please enter detailed comments for the batch adjustment.">
                           </asp:TextBoxWatermarkExtender>
                           &nbsp;
                           <asp:RequiredFieldValidator ID="rfvAdjustmentReason" runat="server" 
                              ControlToValidate="txtboxReason" CssClass="failureNotification" 
                              Display="Dynamic" 
                              ErrorMessage="Detailed comments for the adjustment are required." Text="*" 
                              ValidationGroup="ValidationGroupAdjustment"></asp:RequiredFieldValidator>
                        </td>
                     </tr>
                     <tr>
                        <td class="style111">
                           &nbsp;</td>
                        <td class="style86">
                           <asp:Button ID="btnAddAdjustment" runat="server" CssClass="eitField" 
                              onclick="btnAddAdjustment_Click" Text="Adjust Batch" 
                              ValidationGroup="ValidationGroupAdjustment" Width="89px" />
                           &nbsp;
                           <asp:CustomValidator ID="CustomValidatorAdjustmentAmount" runat="server" 
                              ClientValidationFunction="ValidateBatchAdjustmentAmount" 
                              CssClass="failureNotification" Display="Dynamic" 
                              ErrorMessage="Adjustment amount must be greater than 0 and less than the batch amount." 
                              onservervalidate="CustomValidatorAdjustmentAmount_ServerValidate" Text="*" 
                              ValidationGroup="ValidationGroupAdjustment"></asp:CustomValidator>
                        </td>
                     </tr>
                  </table>
               </asp:Panel>
            </td>
            <td class="style89" valign="top">
            </td>
         </tr>
         <tr>
            <td class="style98" valign="top">
               &nbsp;</td>
            <td class="style105" valign="top">
               <asp:ValidationSummary ID="ValidationSummaryBatchAdjustment" runat="server" 
                  CssClass="failureNotification" HeaderText="Batch Adjustment Validation Errors:" 
                  ValidationGroup="ValidationGroupAdjustment" />
            </td>
            <td class="style68" valign="top">
               &nbsp;</td>
         </tr>
         <tr>
            <td class="style98" valign="top">
               &nbsp;</td>
            <td valign="top" class="style105"> 
               &nbsp;</td>
            <td valign="top" class="style68"> 
               &nbsp;</td>
         </tr>
         </table>

      <br />

   </div>

   <div>
      <br />
   </div>
   <asp:AccessDataSource ID="adsJK" runat="server" DataFile="~/App_Data/Burial.mdb"
      SelectCommand="SELECT [JKID], [JKName] FROM [Jamatkhana]"></asp:AccessDataSource>

   <asp:AccessDataSource ID="adsSearchBatch" runat="server" DataFile="~/App_Data/Burial.mdb"
      SelectCommand="SELECT Accounts.AccountID, Members.MemberLastName, Members.MemberMiddleName, Members.MemberFirstName, Accounts.AccountRenewalYear, AccountStatus.AccountStatus, Members.MemberPrimary, Jamatkhana.JKName FROM ((((Accounts INNER JOIN AccountStatus ON Accounts.AccountStatusID = AccountStatus.AccountStatusID) INNER JOIN Members ON Accounts.AccountID = Members.AccountID) INNER JOIN MemberStatus ON Members.MemberStatusID = MemberStatus.MemberStatusID) INNER JOIN Jamatkhana ON Accounts.AccountJamatkhanaID = Jamatkhana.JKID) WHERE (@TempLastName IS NULL OR Members.MemberLastName LIKE '%' + @TempLastName + '%') AND (@TempFirstName IS NULL OR Members.MemberFirstName LIKE '%' + @TempFirstName + '%') AND (@TempJamatkhanaID = 0 OR Accounts.AccountJamatkhanaID = @TempJamatkhanaID) AND (@TempAccountID IS NULL OR Accounts.AccountID LIKE '%' + @TempAccountID + '%') AND (Members.MemberPrimary = TRUE) AND (Accounts.AccountStatusID = 1) ORDER BY Accounts.AccountID"
      CancelSelectOnNullParameter="False" OnSelecting="adsSearchBatch_Selecting">
      <SelectParameters>
         <asp:ControlParameter ControlID="txtBoxLastName" Name="MemberLastName" Type="String" />
         <asp:ControlParameter ControlID="txtBoxFirstName" Name="MemberFirstName" Type="String" />
         <asp:ControlParameter ControlID="ddlJamatkhana" Name="AccountJamatkhanaID" Type="Int32" />
         <asp:ControlParameter ControlID="txtBoxAccountID" Name="AccountID" Type="String" />
      </SelectParameters>
   </asp:AccessDataSource>

   <asp:AccessDataSource ID="adsAccountBatches" runat="server" DataFile="~/App_Data/Burial.mdb"                        
      
      SelectCommand="SELECT TOP 1 Batch.BatchID, Batch.BatchCreationDate, Batch.UserName, Batch.BatchTotal, Batch.BatchComments, BatchDetails.AccountID, Jamatkhana.JKName FROM ((Batch INNER JOIN BatchDetails ON Batch.BatchID = BatchDetails.BatchID) INNER JOIN Jamatkhana ON Batch.JamatkhanaID = Jamatkhana.JKID) WHERE (BatchDetails.AccountID = ?) ORDER BY Batch.BatchID DESC">
      <SelectParameters>
         <asp:ControlParameter ControlID="gvBatchSearch" Name="?" PropertyName="SelectedValue"
            Type="Int32" />
      </SelectParameters>
   </asp:AccessDataSource>

   <asp:AccessDataSource ID="adsBatchDetails" runat="server" 
      DataFile="~/App_Data/Burial.mdb" 
            
      
      SelectCommand="SELECT BatchDetails.BatchID, BatchDetails.AccountID, BatchDetails.AmountDue, BatchDetails.AmountPaid, BatchDetails.BatchDetailsChequeNumber, BatchDetails.BatchDetailsComments, BatchPaymentType.BatchPaymentType, Members.MemberLastName, Members.MemberMiddleName, Members.MemberFirstName, Members.MemberLastName+', '+Members.MemberFirstName AS MemberFullName, Members.MemberPrimary FROM ((BatchDetails INNER JOIN BatchPaymentType ON BatchDetails.BatchPaymentTypeID = BatchPaymentType.BatchPaymentTypeID) INNER JOIN Members ON BatchDetails.AccountID = Members.AccountID) WHERE (Members.MemberPrimary = TRUE) AND (BatchDetails.BatchID = ?) ORDER BY BatchDetails.AccountID">
      <SelectParameters>
         <asp:ControlParameter ControlID="gvAccountBatches" Name="?" 
            PropertyName="SelectedValue" />
      </SelectParameters>
   </asp:AccessDataSource>

<%--   <asp:AccessDataSource ID="adsBatchSummary" runat="server" DataFile="~/App_Data/Burial.mdb"
      SelectCommand="SELECT Batch.BatchID, Jamatkhana.JKName, Batch.BatchCreationDate, Batch.UserName, Batch.BatchComments, Batch.BatchTotal FROM (Batch INNER JOIN Jamatkhana ON Batch.JamatkhanaID = Jamatkhana.JKID) WHERE (Batch.BatchID = ?)">
      <SelectParameters>
         <asp:ControlParameter ControlID="gvAccountBatches" Name="?" PropertyName="SelectedValue" />
      </SelectParameters>
   </asp:AccessDataSource>--%>

      <asp:AccessDataSource ID="adsBatchAdjustments" runat="server" 
         DataFile="~/App_Data/Burial.mdb" 
         SelectCommand="SELECT BatchAdjustments.BatchAdjustmentBatchID, BatchAdjustments.BatchAdjustmentAccountID, BatchAdjustments.BatchAdjustmentCashAmount, BatchAdjustments.BatchAdjustmentChequeAmount, BatchAdjustments.BatchAdjustmentChequeNumber, BatchAdjustments.BatchAdjustmentCreatedBy, BatchAdjustments.BatchAdjustmentCreatedDate, BatchAdjustments.BatchAdjustmentComments FROM BatchAdjustments WHERE (BatchAdjustments.BatchAdjustmentBatchID = ?) ORDER BY BatchAdjustments.BatchAdjustmentAccountID">
         <SelectParameters>
         <asp:ControlParameter ControlID="gvAccountBatches" Name="?" 
            PropertyName="SelectedValue" />
      </SelectParameters>
      </asp:AccessDataSource>

<%--      </ContentTemplate>
   </asp:UpdatePanel>

   <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="200" AssociatedUpdatePanelID="UpdatePanel1">
      <ProgressTemplate>
         <div class="PleaseWait">
            Please wait ...
         </div>
      </ProgressTemplate>
   </asp:UpdateProgress>--%>

</asp:Content>