<%@ Page Title="New Sales Payment" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" 
    CodeBehind="SalesPayment.aspx.cs" Inherits="SMTBETECH_V3.SalesPayment" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<style type="text/css">
   
    .GridPager a, .GridPager span {
        display: block;
        height: 28px;
        width: 24px;
        font-weight: bold;
        text-align: center;
        text-decoration: none;
    }

    .GridPager a {
        background-color: #f5f5f5;
        color: #969696;
        border: 1px solid #969696;
    }

    .GridPager span {
        /*background-color: #A1DCF2;*/
        background-color: steelblue;
        color: whitesmoke;
        border: 1px solid #3AC0F2;
    }
</style>

<script>
    function isNumberKey(sender, evt) {
        var txt = sender.value;
        var dotcontainer = txt.split('.');
        var charCode = (evt.which) ? evt.which : event.keyCode;
        if (!(dotcontainer.length == 1 && charCode == 46) && charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

        return true;
    }
    function setFocus() {
        try {
            document.getElementById('<%= FormAmount.ClientID %>').value = "";
            document.getElementById('<%= FormAmount.ClientID %>').focus();
        } catch (e) {
            alert(e);
        }
    }

    function SetRequestFocus() {
        try {
            setTimeout("setFocus();", 1);
        }
        catch (e) {
            alert(e);
        }
    }
</script>


<h2 id="title"><%: Title %></h2>


    
<asp:ScriptManagerProxy ID="ScriptManagerProxySalesNew" runat="server"></asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanelSalesNew" runat="server">

    <ContentTemplate>


<div class="row mb-1">
     <div class="col-2">
        <label style="font-weight:bold" for="FormCreation" class="form-label">Creation:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormCreation"></asp:TextBox>
    </div>
     <div class="col-2">
        <label style="font-weight:bold" for="FormInternalFolioNo" class="form-label">Folio:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormInternalFolioNo"></asp:TextBox>
    </div>
     <div class="col-2">
        <label style="font-weight:bold" for="FormTotal" class="form-label">Total:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormTotal" style="text-align:right;color:blue"></asp:TextBox>
    </div>
</div>

 <div class="row mb-1">
     <div class="col" style="display:none">
         <label style="font-weight:bold" for="FormIdCustomer" class="form-label">Id Customer:</label>
         <asp:TextBox CssClass="form-control" runat="server" ID="FormIdCustomer"></asp:TextBox>
     </div>
     <div class="col">
        <label style="font-weight:bold" for="FormCustomerName" class="form-label">Customer Name:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormCustomerName"></asp:TextBox>
    </div>
</div>


<hr />

<asp:Button ID="btnNewPayment" runat="server" CssClass="btn btn-primary btn-sm" Text="New Payment" OnClientClick="return SetRequestFocus()" />

        <p></p>


    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderPayments" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" 
    TargetControlID="btnNewPayment" 
    PopupControlID="PanelPayments" 
    CancelControlID="btnCancelButton" />

    <asp:Panel ID="PanelPayments" runat="server" style="display:none; text-align:left; width:350px; background-color:White; border-width:2px; border-color:steelblue; border-style:solid; padding:10px;">
    <h4>New Payment</h4>
     <hr />
    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormAmount" class="form-label">Amount:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormAmount"
                style="text-align:right;color:blue" OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);" />
        </div>
    </div>
    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormComments" class="form-label">Comments:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormComments"></asp:TextBox>
        </div>
    </div>

    <p></p>

    <div style="text-align:right;">
        <asp:Button ID="btnSavePayment" CssClass="btn btn-primary btn-sm" runat="server" Text="Save Payment" OnClick="btnSavePayment_Click" />
        <asp:Button ID="btnCancelButton" CssClass="btn btn-secondary btn-sm" runat="server" Text="Cancel" OnClick="btnCancelButton_Click"/>
    </div>
</asp:Panel>







        <asp:GridView CssClass="table table-bordered table-striped table-sm table-hover" DataKeyNames="Id"
        ID="GVPayments"
        runat="server"
        AutoGenerateColumns="False"
        AllowPaging="True"
        AllowSorting="False">
    <HeaderStyle CssClass="table-primary" />
        <Columns>

            <asp:BoundField Visible="false" HeaderStyle-Width="40px" DataField="Id" HeaderText="Id" ></asp:BoundField>

            <asp:BoundField Visible="false" HeaderStyle-Wrap="false" HeaderStyle-Width="100px" ItemStyle-Wrap="false" 
               DataField="IdSalesHeader" HeaderText="IdSalesHeader" ></asp:BoundField>
            
            <asp:BoundField DataFormatString="{0:yyyy-MM-dd}" ItemStyle-Wrap="false" ItemStyle-Width="150px" DataField="Date" HeaderText="Date"></asp:BoundField>

             <asp:BoundField HeaderStyle-Wrap="false" ItemStyle-Wrap="false" 
                    DataField="Comments" HeaderText="Comments" ></asp:BoundField>

            <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  HeaderStyle-HorizontalAlign="Right"
                   DataField="Amount" HeaderText="Amount" ItemStyle-ForeColor="Blue" ItemStyle-HorizontalAlign="Right"></asp:BoundField>


            <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  HeaderStyle-HorizontalAlign="Right"
                   DataField="NewAmount" HeaderText="Pending Amount" ItemStyle-ForeColor="Blue" ItemStyle-HorizontalAlign="Right"></asp:BoundField>

        </Columns>
            <EmptyDataTemplate>No Payments</EmptyDataTemplate>
            
</asp:GridView>


<hr />

<asp:Button ID="btnBack" runat="server" CssClass="btn btn-secondary" Text="Back to Sales" OnClick="btnBack_Click" />




    </ContentTemplate>

</asp:UpdatePanel>

</asp:Content>
