<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
    CodeBehind="Voucher.aspx.cs" Inherits="HRMS.Voucher" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="scriptManager" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server" ID="upMain" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <div class="main-panel">
                <div class="row">
                    <div class="col-md-12">
                        <section class="panel">
                         <header class="panel-heading" style="padding-bottom:30px">
                           <span class="label label-primary"></span>
                            <asp:Label id="lbl_header" Text="Select Voucher Template" runat="server"></asp:Label>
                         </header>

                    <div class="panel-body">
                        <div class="span6">
                                <div id="divmessage" runat="server" visible="false" class="alert alert-info alert-dismissable">
                                    <asp:label text="" ID="lbl_msg" CssClass="msg" runat="server"></asp:label>
                                   
                                </div>
                            </div>

                            <div class="span6">
                                <div id="diverrmessage" runat="server" visible="false" class="alert alert-info alert-dismissable">
                                    <asp:label text="" id="lbl_err_msg" CssClass="msg" runat="server"></asp:label>
                                    
                                </div>
                            </div>
                            

                            <div class="row" runat="server" id="div_ddl">
                                <label class="col-md-2 control-label">Voucher Templates</label>
                                <asp:HiddenField ID="hid_temp" runat="server" />
                                <div class="col-md-5">
                                    <asp:DropDownList ID="ddl_vch" runat="server" CssClass="form-control" OnSelectedIndexChanged="ddl_vch_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                                </div>
                            </div>
                           


                            <div id="dv" runat="server" visible="false">
                            <div class="row">
                            <label class="col-md-1 control-label">Voucher.No</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form-control" Enabled= "false" ID="txt_control_total" runat="server"></asp:TextBox>
                                </div>

                            <asp:HiddenField ID="hid_journal" runat="server" />
                            <asp:HiddenField ID="hid_lbl" runat="server" />
                            <asp:HiddenField ID="hid_post" runat="server" />
                            <asp:HiddenField ID="hid_pr_set_id" runat="server" />
                                <label class="col-md-1 control-label">Journal</label>
                                <div class="col-md-3">
                                    <asp:TextBox CssClass="form-control" ID="txt_journal" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="req_journal" controltovalidate="txt_journal" errormessage="Journal Name Required!" />
                                   
                                </div>

                                


                                  <label class="col-md-1 control-label">Ledger</label>
                                <div class="col-md-2">
                                    <asp:DropDownList ID="ddl_ledger"  runat="server" CssClass="form-control" OnSelectedIndexChanged="ddl_ledger_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                                        <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="req_ddl_ledger" controltovalidate="ddl_ledger" errormessage="Ledger Name Required!" />
                                </div>

                                
                                 
                            </div>

                        


                             <div class="row">
                             <label class="col-md-1 control-label">Period</label>
                                <div class="col-md-2">
                                 <div class="input-group">
                                 <asp:AutoCompleteExtender ServiceMethod="GetPeriods" MinimumPrefixLength="1" CompletionInterval="10"  
                                  EnableCaching="false" CompletionSetCount="10" TargetControlID="txt_period" ID="AutoCompleteExtender1"  
                                  runat="server" FirstRowSelected="true">  
                                  </asp:AutoCompleteExtender>  
                                        <asp:HiddenField ID="hid_per" runat="server" />
                                        <asp:HiddenField ID="hid_date" runat="server" />
                                        <asp:TextBox CssClass="form-control" ID="txt_period" Enabled="false" runat="server"></asp:TextBox>
                                          <span class="input-group-btn">
                                            <button id="btn_lov_per" type="button" runat="server" class="btn btn-white" onserverclick="btn_lov_per_Click"><i class="fa fa-search"></i></button>
                                            <%--<asp:Button ID="btn_lov_per" Text="Save" CssClass="btn btn-info" runat="server" onclick="btn_lov_per_Click" />--%>
                                          </span>
                                          
                                    </div>
                                    <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="RequiredFieldValidator1" controltovalidate="txt_period" errormessage="Period Name Required!" />
                                </div>

                                <label class="col-md-2 control-label">Transaction Date</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form_datetime form-control" ID="txt_effective_date" runat="server"></asp:TextBox>
                                      <asp:RegularExpressionValidator ID="regexpName" runat="server"     
                                ErrorMessage="Date format is invalid please Enter (dd-MM-yyyy)." 
                                ControlToValidate="txt_effective_date" ValidationGroup="save"   
                                ValidationExpression="(0[1-9]|[12][0-9]|3[01])[-](0[1-9]|1[012])[-]\d{4}" />

                                <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="RequiredFieldValidator2" controltovalidate="txt_effective_date" errormessage="Transaction Date Required!" />
                                </div>

                                <label id="lbl_cur" class="col-md-1 control-label" runat="server">Currency</label>
                                    <div class="col-md-2">
                                       <asp:TextBox CssClass="form-control" ID="txt_currency" runat="server" Enabled="false"></asp:TextBox>
                                    </div>
                                
                                


                                
                            </div>

                            <div class="row">

                              <label class="col-md-1 control-label">Category</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form-control" ID="txt_category" runat="server"></asp:TextBox>
                                </div>

                                <label class="col-md-2 control-label">Document Number</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form-control" ID="txt_doc_no" runat="server"></asp:TextBox>
                                </div>
                               
                             
                                 
                                   <label class="col-md-1 control-label">Balance.Type</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form-control" ID="txt_balancetype" runat="server"></asp:TextBox>
                                </div>


                                  


                            </div>
                            
                             <div class="row" runat="server">
                                <label class="col-md-1 control-label">Tax</label>
                                <div class="col-md-2">
                                   <asp:TextBox ID="txt_tax" CssClass="form-control"  runat="server"></asp:TextBox>
                                </div>

                                <label class="col-md-2 control-label">Clearing Company</label>
                                <div class="col-md-2">
                                    <asp:TextBox CssClass="form-control" ID="txt_clearing_company" runat="server"></asp:TextBox>
                                </div>

                               <label class="col-md-1 control-label">Description</label>
                                <div class="col-md-4">
                                    <asp:TextBox CssClass="form-control" ID="txt_desc" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="req_desc" controltovalidate="txt_desc" errormessage="Description Required!" />
                                </div>
                            </div>

                            <hr />
                          
                           
                             <div style="height:250px; overflow: scroll">
                                    <asp:GridView ID="GridView1" runat="server" CellPadding="0" Border="0" GridLines="Horizontal"
                                        AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound"
                                        onrowcommand="GridView1_RowCommand">
                                        <Columns>
                                            <asp:TemplateField HeaderText="Account" ControlStyle-Width="360px" ItemStyle-Width="100px">
                                               <ItemTemplate>
                                               <%--<asp:HiddenField ID="hid_ldgr" runat="server" Value='<%#Bind("LEDGER_ID") %>' />--%>
                                               <asp:HiddenField ID="hid_comb" runat="server" Value='<%#Bind("CODE_COMBINATION_ID") %>' />
                                               <asp:Label ID="lbl_id" runat="server" Visible="false"></asp:Label>
                                                    <div class="input-group">
                                                        <asp:HiddenField ID="hid_acc" runat="server" />
                                                            <asp:TextBox ID="txt_acc" Enabled="false" runat="server" CssClass="form-control" Text='<%#Bind("account_id") %>'></asp:TextBox>
                                                                <span class="input-group-btn">
                                                                    <%--<button id="btn_lov" type="button" runat="server" class="btn btn-white" onserverclick="btn_lov_Click"><i class="fa fa-search"></i></button>--%>
                                                                    <button id="btn_desc" type="button" runat="server" class="btn btn-white" onserverclick="btn_desc_Click"><i class="fa fa-info"></i></button>
                                                                </span>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:TemplateField>

                                            <asp:TemplateField ControlStyle-Width="100px" HeaderText="Debit" ItemStyle-Width="20px">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txt_debit" style="text-align:right" Width="100px"  CssClass="form-control col-md-1"  runat="server" OnTextChanged="txt_debit_TextChanged" AutoPostBack="true" onkeypress="return numbersOnly(event)"   Text='<%#Bind("ACCOUNTED_DR") %>'></asp:TextBox>
                                                </ItemTemplate>
                                            </asp:TemplateField>

                                             <asp:TemplateField ControlStyle-Width="100px" HeaderText="Credit" ItemStyle-Width="20px">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="txt_credit" style="text-align:right"  Width="100px" CssClass="form-control col-md-1" onkeypress="return numbersOnly(event)" AutoPostBack="true" OnTextChanged="txt_credit_TextChanged"  runat="server" Text='<%#Bind("ACCOUNTED_CR") %>'></asp:TextBox>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            
                                             <asp:TemplateField HeaderText="Description" ControlStyle-Width="479px" ItemStyle-Width="200px">
                                                <ItemTemplate>
                                                       <%--<asp:Label ID="lbl_a_desc" CssClass="control-label"  runat="server" Text='<%#Bind("desc")%>'></asp:Label>--%>
                                                    <asp:TextBox ID="txt_a_desc" CssClass="form-control"  runat="server" Text='<%#Bind("des") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="desc" controltovalidate="txt_a_desc" errormessage="Description is Required!" />
                                                </ItemTemplate>
                                            </asp:TemplateField>

                                         
                                            <asp:TemplateField HeaderText="Action" ItemStyle-Width="70px" Visible="false">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnk" CommandName="g_add" runat="server" ><i class="fa fa-plus" style="font-size:20px !important"></i></asp:LinkButton>
                                                    &nbsp;
                                                    <asp:LinkButton ID="lnk_dlt" OnClick="lnk_dlt_Click"  CommandName="g_dlt" runat="server"><i class="fa fa-remove" style="font-size:20px !important"></i></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                       
                                    </asp:GridView>
                                    </div>

                                    <div class="row">
                                    <div class="col-md-1" style="margin-left:425px">
                                        <%--<asp:Label ID="txt_dr"  CssClass="control-label" runat="server"></asp:Label>--%>
                                        <asp:TextBox ID="txt_dr" runat="server" style="border: none;background-color:transparent" Enabled="false"></asp:TextBox>
                                    </div>

                                    <div class="col-md-1">
                                   <%-- <asp:Label ID="txt_cr" CssClass="control-label" Text="" runat="server"></asp:Label>--%>
                                    
                                        <asp:TextBox ID="txt_cr" runat="server" style="border: none;background-color:transparent"  Enabled="false"></asp:TextBox>
                                    </div>
                                      <asp:CompareValidator ID="cmp_dr" Operator="Equal" runat="server" ValidationGroup="save"
                                        ControlToValidate="txt_cr" ControlToCompare="txt_dr" ErrorMessage="Credit Value Must be equal to Debit Value"></asp:CompareValidator>
                                    </div>
                                   
                                    <div class="row">
                                <label class="control-label col-md-2">Account Description</label>
                                <div class="col-md-8">
                                    <asp:TextBox ID="txt_acc_desc" Enabled="false" runat="server" CssClass="form-control"></asp:TextBox>
                                </div>
                            </div>
                            
                    


                    <div class="row" style="padding-top:10px;margin-left:15px">
                        <asp:Button ID="btn_save" Text="Save" CssClass="btn btn-primary" Width="300px" runat="server" ValidationGroup="save" onclick="btn_save_Click" />
                    <asp:Button ID="btn_post" Text="Post" Visible="false" CssClass="btn btn-primary" Width="300px" runat="server"  onclick="btn_post_Click" />
                            <asp:Button ID="btn_cancel" Text="Clear" CssClass="btn btn-primary"  Width="300px"
                                runat="server" OnClick="btn_cancel_Click" />
                                     <asp:Button ID="btn_prnt" Text="Print" CssClass="btn btn-primary" Width="300px" 
                                runat="server" Enabled="false" OnClick="btn_prnt_Click"/>
                                </div>

                                </div>

                   </div>
                </section>
                    </div>
                </div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btn_save" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
