<%@ Page Title="New Sale" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" 
    CodeBehind="SalesNew.aspx.cs" Inherits="SMTBETECH_V3.SalesNew" %>
<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;
    }
</script>





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


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

    <ContentTemplate>


<%-- Start Customers --%>

<h5>Customer:</h5>

<asp:Button ID="btnSelectCustomer" runat="server" CssClass="btn btn-primary btn-sm" Text="Select Customer" />

            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderSelectCustomers" runat="server"
                BackgroundCssClass="modalBackground"
                DropShadow ="true"
                TargetControlID="btnSelectCustomer"
                PopupControlID="PanelSelectCustomers"
                CancelControlID="btnCancelSelectCustomer" />

            <asp:Panel ID="PanelSelectCustomers" 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>Select Customer</h4>
                <hr />

                 <%-- Start Grid Customers--%>

              <asp:Panel ID="PanelSearchCustomer" runat="server" DefaultButton="btnSearchCustomer">
                  <div class="row" style="width:100%">
                      <div class="col-6">
                          <asp:TextBox CssClass="form-control" placeholder="Search Customer"  runat="server"
                              ID="txtSearchCustomer" AutoPostBack="false" onFocus="this.select()"/>
                      </div>
                      <div class="col-6" style="text-align:left">
                          <asp:Button CssClass="btn btn-primary btn-sm" ID="btnSearchCustomer" runat="server" 
                              Text="Search" OnClick="btnSearchCustomer_Click"/>
                          <asp:Button CssClass="btn btn-primary btn-sm" ID="btnClearSearchCustomer" runat="server"
                              Text="Clear" OnClick="btnClearSearchCustomer_Click"/>
                      </div>
                 </div>
                  <p></p>
              </asp:Panel>

                
                <div style="overflow-x:scroll">
                <asp:GridView CssClass="table table-bordered table-striped table-sm"
                    ID="GVSelectCustomers"
                    runat="server"
                    AutoGenerateColumns="False"
                    AllowPaging="True"
                    AllowSorting="False"
                    OnRowCommand="GVSelectCustomers_RowCommand" OnPageIndexChanging="GVSelectCustomers_PageIndexChanging" PageSize="5">
                <HeaderStyle CssClass="table-primary" />
                <Columns>
                    <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" InsertVisible="False" SortExpression="Id"></asp:BoundField>

                    <asp:ButtonField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" ItemStyle-Wrap="false" SortExpression="CustomerName" 
                        CommandName="SelectCustomer" DataTextField="CustomerName" HeaderText="Customer Name" />

                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" DataField="CustomerAbbrevation" HeaderText="Customer Abbrevation" SortExpression="CustomerAbbrevation"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" DataField="VendorNo" HeaderText="Vendor No" SortExpression="VendorNo"></asp:BoundField>
                    <asp:BoundField DataField="TaxId" HeaderText="Tax Id" SortExpression="TaxId"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  DataField="BillToStreet" HeaderText="Bill To Street" SortExpression="BillToStreet"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  DataField="BillToSuburb" HeaderText="Bill To Suburb" SortExpression="BillToSuburb"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillToMunicipality" HeaderText="Bill To Municipality" SortExpression="BillToMunicipality"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillToZipCode" HeaderText="Bill To ZipCode" SortExpression="BillToZipCode"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillToState" HeaderText="Bill To State" SortExpression="BillToState"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillToCountry" HeaderText="Bill To Country" SortExpression="BillToCountry"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  DataField="ShipToStreet" HeaderText="Ship To Street" SortExpression="ShipToStreet"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ShipToSuburb" HeaderText="Ship To Suburb" SortExpression="ShipToSuburb"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ShipToMunicipality" HeaderText="Ship To Municipality" SortExpression="ShipToMunicipality"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ShipToZipCode" HeaderText="Ship To ZipCode" SortExpression="ShipToZipCode"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ShipToState" HeaderText="Ship To State" SortExpression="ShipToState"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ShipToCountry" HeaderText="Ship To Country" SortExpression="ShipToCountry"></asp:BoundField>
                    <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="TermsPayment" HeaderText="Terms Payment" SortExpression="TermsPayment"></asp:BoundField>
                    <asp:BoundField DataField="Currency" HeaderText="Currency" SortExpression="Currency"></asp:BoundField>
                    <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="CreationDate" HeaderText="Creation Date" SortExpression="CreationDate"></asp:BoundField>
                    <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="ModifiedDate" HeaderText="Modified Date" SortExpression="ModifiedDate"></asp:BoundField>
                </Columns>
                        <PagerStyle CssClass="GridPager" />

                </asp:GridView>
                </div>

                    <p></p>
                    <div>
                    Total:
                    <asp:Label runat="server" ID="lblCountCustomers"></asp:Label>
                    </div>


                    <%--End Grid Customers--%>

                    <p></p>

                    <div style="text-align:right;">            
                        <asp:Button ID="btnCancelSelectCustomer" CssClass="btn btn-secondary btn-sm" runat="server" Text="Cancel" />
                    </div>

            </asp:Panel>



    <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>



<%-- End Customers --%>


<hr />

 <%--Start Materials--%>

<h5>Materials:</h5>

<asp:Button Enabled="false" ID="btnSelectMaterial" runat="server" CssClass="btn btn-primary btn-sm" Text="Select Material" />

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderSelectMaterials" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" 
    TargetControlID="btnSelectMaterial" 
    PopupControlID="PanelSelectMaterials" 
    CancelControlID="btnCancelSelectMaterial" />


        <asp:Panel ID="PanelSelectMaterials" 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>Select Material</h4>
    <hr />

   <%-- Start Grid Materials--%>

    <asp:Panel runat="server" DefaultButton="btnSearchMaterial">
        <div class="row" style="width:100%">
            <div class="col-6">
                <asp:TextBox CssClass="form-control" placeholder="Search Part Number"  runat="server"
                    ID="txtSearchMaterial" AutoPostBack="false" onFocus="this.select()"/>
            </div>
            <div class="col-6" style="text-align:left">
                <asp:Button CssClass="btn btn-primary btn-sm" ID="btnSearchMaterial" runat="server" 
                    Text="Search" OnClick="btnSearchMaterial_Click"/>
                <asp:Button CssClass="btn btn-primary btn-sm" ID="btnClearSearchMaterial" runat="server"
                    Text="Clear" OnClick="btnClearSearchMaterial_Click"/>
            </div>
       </div>

       <p></p>
    </asp:Panel>

<div style="overflow-x:scroll">
<asp:GridView CssClass="table table-bordered table-striped table-sm"
    ID="GVSelectMaterials"
    runat="server"
    AutoGenerateColumns="False"
    AllowPaging="True"
    AllowSorting="False"
    OnRowCommand="GVSelectMaterials_RowCommand" OnPageIndexChanging="GVSelectMaterials_PageIndexChanging" PageSize="5">
<HeaderStyle CssClass="table-primary" />
    <Columns>
        <asp:BoundField HeaderStyle-Width="80px" DataField="Id" HeaderText="Id" ReadOnly="True" InsertVisible="False"></asp:BoundField>

        <asp:ButtonField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" ItemStyle-Wrap="false"  
            CommandName="SelectMaterial" DataTextField="PartNumber" HeaderText="Part Number" />
    
        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="400px" ItemStyle-Wrap="false" DataField="Description" HeaderText="Description" ></asp:BoundField>                    
        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="100px" ItemStyle-Wrap="false" DataField="Quantity" HeaderText="Quantity" ItemStyle-HorizontalAlign="Right"></asp:BoundField>                    
        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="100px" ItemStyle-Wrap="false" DataField="Price" HeaderText="Price" ItemStyle-HorizontalAlign="Right"></asp:BoundField>                    
    </Columns>
        <PagerStyle CssClass="GridPager" />
    
</asp:GridView>
</div>
    <p></p>
    <div>
    Total:
    <asp:Label runat="server" ID="lblCountMaterials"></asp:Label>
    </div>


    <%--End Grid Materials--%>

    <p></p>

    <div style="text-align:right;">
        <asp:Button ID="btnCancelSelectMaterial" CssClass="btn btn-secondary btn-sm" runat="server" Text="Cancel"/>
    </div>
</asp:Panel>


<div class="row mb-1">
    <div class="col" style="display:none">
        <label style="font-weight:bold" for="FormIdMaterial" class="form-label">Id Material:</label>
        <asp:TextBox CssClass="form-control" runat="server" ID="FormIdMaterial"></asp:TextBox>
    </div>
    <div class="col">
        <label style="font-weight:bold" for="FormPartNumber" class="form-label">Part Number:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormPartNumber"></asp:TextBox>
    </div>
     <div class="col">
        <label style="font-weight:bold" for="FormPartNumberCustomer" class="form-label">Part Number for Customer:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormPartNumberCustomer"></asp:TextBox>
    </div>
</div>
<div class="row mb-1">
    <div class="col">
        <label style="font-weight:bold" for="FormDescription" class="form-label">Description:</label>
        <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormDescription"></asp:TextBox>
    </div>
</div>
      
 <%--End Materials--%>
        
<p></p>

<%--Start Materials Income--%>

 <hr />

<asp:Button Enabled="false" ID="btnSelectMaterialIncome" runat="server" CssClass="btn btn-primary btn-sm" Text="Select Material Income" />

    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderSelectMaterialsIncomes" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" 
                TargetControlID="btnSelectMaterialIncome" 
                PopupControlID="PanelSelectMaterialsIncomes" 
                CancelControlID="btnCancelSelectMaterialIncome" />

    <asp:Panel ID="PanelSelectMaterialsIncomes" 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>Select Material Income</h4>

            

            <%-- Start Grid Materials Income--%>

            <%--<asp:Panel runat="server" DefaultButton="btnSearchMaterialIncome">
              <div class="row" style="width:100%">
                  <div class="col-6">
                      <asp:TextBox CssClass="form-control" placeholder="Search Part Number"  runat="server"
                          ID="txtSearchMaterialIncome" AutoPostBack="false" onFocus="this.select()"/>
                  </div>
                  <div class="col-6" style="text-align:left">
                      <asp:Button CssClass="btn btn-primary btn-sm" ID="btnSearchMaterialIncome" runat="server" 
                          Text="Search" OnClick="btnSearchMaterialIncome_Click" />
                      <asp:Button CssClass="btn btn-primary btn-sm" ID="btnClearSearchMaterialIncome" runat="server"
                          Text="Clear"  OnClick="btnClearSearchMaterialIncome_Click" />
                  </div>
             </div>

             <p></p>
          </asp:Panel>--%>

            <div style="overflow-x:scroll">
        <asp:GridView CssClass="table table-bordered table-striped table-sm"
            ID="GVSelectMaterialsIncome"
            runat="server"
            AutoGenerateColumns="False"
            AllowPaging="True"
            AllowSorting="False"
            OnRowCommand="GVSelectMaterialsIncome_RowCommand" OnPageIndexChanging="GVSelectMaterialsIncome_PageIndexChanging" PageSize="10">
        <HeaderStyle CssClass="table-primary" />
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" InsertVisible="False" ></asp:BoundField>

                <asp:BoundField Visible="false" DataField="IdMaterial" HeaderText="IdMaterial" ReadOnly="True" InsertVisible="False" ></asp:BoundField>

                <asp:ButtonField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" ItemStyle-Wrap="false" 
                    CommandName="SelectMaterialIncome" DataTextField="PartNumber" HeaderText="Part Number" />

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

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportDocType" HeaderText="Import Doc Type"></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ConditionOfGoods" HeaderText="Condition of Goods" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BrandUsed" HeaderText="Brand Used" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SerialNumber" HeaderText="Serial Number" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportNo" HeaderText="Import No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalNo" HeaderText="Local No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="DateIncomming" HeaderText="Date Incomming" ></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="IdSupplier" HeaderText="IdSupplier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SupplierName" HeaderText="Supplier Name" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="TaxID" HeaderText="TaxID" ></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportCarrier" HeaderText="Import Carrier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalCarrier" HeaderText="Local Carrier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="AWBTrackingNo" HeaderText="AWB Tracking No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillLadingNo" HeaderText="Bill Lading No" ></asp:BoundField>
                
                <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="CreationDate" HeaderText="Creation Date" ></asp:BoundField>
                <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="ModifiedDate" HeaderText="Modified Date" ></asp:BoundField>
            </Columns>
                <PagerStyle CssClass="GridPager" />
    
            </asp:GridView>
        </div>
        <p></p>
        <div>
            Total:
            <asp:Label runat="server" ID="lblCountMaterialIncomes"></asp:Label>
        </div>

       <%--End Grid Materials Income--%>

    <p></p>

    <div style="text-align:right;">
        <asp:Button ID="btnCancelSelectMaterialIncome" CssClass="btn btn-secondary btn-sm" runat="server" Text="Cancel"/>
    </div>


</asp:Panel>


 <%--End Materials Income--%>



<p></p>

<%--Start Materials Income Selected--%>

<asp:Panel runat="server" DefaultButton="btnAddMaterial">

    <div style="overflow-x:scroll">
    <asp:GridView CssClass="table table-bordered table-striped table-sm"
        ID="GVMaterialsIncomeSelected"
        runat="server"
        AutoGenerateColumns="False">
        <HeaderStyle CssClass="table-primary" />
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" InsertVisible="False" SortExpression="Id"></asp:BoundField>

                <asp:BoundField Visible="false" DataField="IdMaterial" HeaderText="IdMaterial" ReadOnly="True" InsertVisible="False"></asp:BoundField>
        
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" ItemStyle-Wrap="false" DataField="PartNumber" HeaderText="PartNumber" ></asp:BoundField>

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

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportDocType" HeaderText="Import Doc Type" ></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ConditionOfGoods" HeaderText="Condition of Goods" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BrandUsed" HeaderText="Brand Used" > </asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SerialNumber" HeaderText="Serial Number" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportNo" HeaderText="Import No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalNo" HeaderText="Local No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="DateIncomming" HeaderText="Date Incomming" ></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="IdSupplier" HeaderText="IdSupplier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SupplierName" HeaderText="Supplier Name" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="TaxID" HeaderText="TaxID" ></asp:BoundField>

                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportCarrier" HeaderText="Import Carrier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalCarrier" HeaderText="Local Carrier" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="AWBTrackingNo" HeaderText="AWB Tracking No" ></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillLadingNo" HeaderText="Bill Lading No" ></asp:BoundField>
                
                <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="CreationDate" HeaderText="Creation Date" ></asp:BoundField>
                <asp:BoundField ItemStyle-Wrap="false" ItemStyle-Width="200px" DataField="ModifiedDate" HeaderText="Modified Date" ></asp:BoundField>
            </Columns>
                   <EmptyDataTemplate>No Material Income Selected</EmptyDataTemplate>
        </asp:GridView>
        </div>

<%--End Materials Income Selected--%>


<p></p>

    <div class="row mb-1">
        <div class="col-6">
            <label style="font-weight:bold" for="FormQuantity" class="form-label">Quantity (-):</label>
            <asp:TextBox Enabled="false" CssClass="form-control" runat="server" ID="FormQuantity" 
                style="text-align:right;color:blue" OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);" ></asp:TextBox>
        </div>
        <div class="col-6">
            <label style="font-weight:bold" for="FormPrice" class="form-label">Price:</label>
            <asp:TextBox Enabled="false" CssClass="form-control" runat="server" ID="FormPrice" style="text-align:right;color:blue" 
                OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col-6">
            <label style="font-weight:bold" for="FormQuotationNo" class="form-label">Quotation No:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormQuotationNo" ></asp:TextBox>
        </div>
        <div class="col-6">
            <label style="font-weight:bold" for="FormAdditionalComments" class="form-label">Additional Comments:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormAdditionalComments"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col-6">
            <label style="font-weight:bold" for="FormAmountOfCommissionsToPay" class="form-label">Amount Of Commissions To Pay:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormAmountOfCommissionsToPay"  AutoPostBack="true"
                style="text-align:right;color:blue" OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);"></asp:TextBox>
        </div>
        <div class="col-6">
            <label style="font-weight:bold" for="FormSalesmanSalesCommission" class="form-label">Salesman:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormSalesmanSalesCommission"></asp:TextBox>
        </div>
    </div>



    <p></p>

    <div class="row mb-3">
        <div style="text-align:right">
            <asp:Button Enabled="false" ID="btnAddMaterial" runat="server" CssClass="btn btn-primary btn-sm" Text="Add Material" OnClick="btnAddMaterial_Click" />
        </div>
   </div>


        
</asp:Panel>


<hr />


    <h5 style="font-weight:bold">Added Materials:</h5>


    <%--Start Quantity, Price--%>

    <div style="overflow-x:scroll">
        
        <asp:ListView runat="server" ID="ListSaleItems" DataKeyNames="IdMaterialIncome, IdMaterial" >
            <ItemTemplate>
                <tr style="">
                    <td>
                        <asp:ImageButton ID="imgPlus" runat="server" ImageUrl="Images/plus.png" 
                            CommandArgument='<%# Container.DataItemIndex %>' OnCommand="imgPlus_Command" />
                        <asp:ImageButton ID="imgMinus" Visible="False" runat="server" ImageUrl="Images/minus.png" 
                            CommandArgument='<%# Container.DataItemIndex %>' OnCommand="imgMinus_Command" />
                        <br />
                    </td>
                    <td>
                        <asp:Label ID="ListlblPartNumber" runat="server" Text='<%# Eval("PartNumber") %>' />
                    </td>
                    <td>
                        <asp:Label ID="ListlblPartNumberCustomer" runat="server" Text='<%# Eval("PartNumberCustomer") %>' />
                    </td>
                    <td>
                        <asp:Label ID="ListlblDescription" runat="server" Text='<%# Eval("Description") %>' />
                    </td>
                    <td style="text-align:right">
                        <asp:Label ID="ListlblQuantity" runat="server" Text='<%# Eval("Quantity") %>' />
                    </td>
                    <td style="text-align:right">
                        <asp:Label ID="ListlblPrice" runat="server" Text='<%# Eval("Price") %>' />
                    </td>
                    <td style="text-align:right">
                        <asp:Label ID="ListlblSubtotal" runat="server" Text='<%# Eval("Subtotal") %>' />
                    </td>
                    <td style="text-align:center" >
                        <asp:Button runat="server" ID="btnDeleteSalesItem" CssClass="btn btn-close" 
                            CommandArgument='<%# Container.DataItemIndex %>' OnCommand="btnDeleteSalesItem_Command"/>
                    </td>

                </tr>
                <tr>
                    <td colspan="4">
                        <asp:Panel ID="panelGVSaleItemsMaterialsIncome" runat="server" style="display:none">
                            <div style="overflow-x:scroll;max-width:850px">
                                <asp:GridView ID="GVSaleItemsMaterialsIncome" runat="server" AutoGenerateColumns="false" 
                                    CssClass="table table-bordered table-striped table-sm" >
                                    <HeaderStyle CssClass="table-primary" />
                                    <Columns>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="150px" DataField="PartNumber" HeaderText="Part Number" />
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" DataField="Description" HeaderText="Description" />
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="150px" ItemStyle-Wrap="false" DataField="Quantity" HeaderText="Quantity" ItemStyle-ForeColor="Blue" ItemStyle-HorizontalAlign="Right"></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="150px" ItemStyle-Wrap="false" DataField="ImportDocType" HeaderText="Import Doc Type" ></asp:BoundField>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ConditionOfGoods" HeaderText="Condition of Goods" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BrandUsed" HeaderText="Brand Used" > </asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SerialNumber" HeaderText="Serial Number" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportNo" HeaderText="Import No" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalNo" HeaderText="Local No" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="DateIncomming" HeaderText="Date Incomming" ></asp:BoundField>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="IdSupplier" HeaderText="IdSupplier" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SupplierName" HeaderText="Supplier Name" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="TaxID" HeaderText="TaxID" ></asp:BoundField>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ImportCarrier" HeaderText="Import Carrier" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="LocalCarrier" HeaderText="Local Carrier" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="AWBTrackingNo" HeaderText="AWB Tracking No" ></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="BillLadingNo" HeaderText="Bill Lading No" ></asp:BoundField>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="QuotationNo" HeaderText="Quotation No"></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="AdditionalComments" HeaderText="Additional Comments"></asp:BoundField>

                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="AmountOfCommissionsToPay" HeaderText="Amount Of Commissions To Pay" ItemStyle-ForeColor="Blue" ItemStyle-HorizontalAlign="Right"></asp:BoundField>
                                        <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="SalesmanSalesCommission" HeaderText="Salesman"></asp:BoundField>

                                    </Columns>
                                </asp:GridView>
                           </div>
                       </asp:Panel>
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate >
                <table id="itemPlaceHolderContainer" runat="server" Class="table table-bordered table-striped table-sm table-hover">
                    <tr runat="server" style="" class="table-primary">
                        <th runat="server" style="width:80px" >Details</th>
                        <th runat="server" style="width:200px">Part Number</th>
                        <th runat="server" style="width:200px">PN Customer</th>
                        <th runat="server" >Description</th>
                        <th runat="server" style="width:100px;text-align:right">Quantity</th>
                        <th runat="server" style="width:100px;text-align:right">Price</th>
                        <th runat="server" style="width:100px;text-align:right">Subtotal</th>
                        <th runat="server" style="width:40px"></th>
                    </tr>
                    <tr id="itemPlaceholder" runat="server">
                    </tr>
                </table>
            </LayoutTemplate>

        </asp:ListView>

    </div>
   
<%--End Quantity, Price--%>

<table width="100%">
    <tr>
      <td style="width: 50%">Total Items: <asp:Label Font-Size="Large" runat="server" ID="lblCountSaleItems" ForeColor="Blue"></asp:Label></td>
      <td style="width: 50%; text-align: right;">Total $: <asp:Label Font-Size="Large" runat="server" ID="lblTotalSaleItems" Font-Bold="true" ForeColor="Blue"></asp:Label></td>
    </tr>
</table>


        <hr />


        <div class="row mb-1">
           <div class="col-6">
               <label style="font-weight:bold" for="FormNetDaysCredit" class="form-label">Net Days Credit:</label>
               <asp:TextBox CssClass="form-control" runat="server" ID="FormNetDaysCredit" style="text-align:right;color:blue"
                   OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);"></asp:TextBox>
           </div>
           <div class="col-6">
               <label style="font-weight:bold" for="FormDateOfDelivery" class="form-label">Date Of Delivery:</label>
               <asp:TextBox CssClass="form-control" runat="server" ID="FormDateOfDelivery" TextMode="Date" ></asp:TextBox>
           </div>
       </div>

         <div class="row mb-1">
           <div class="col-6">
               <label style="font-weight:bold" for="FormDateBilling" class="form-label">Date Billing:</label>
               <asp:TextBox CssClass="form-control" runat="server" ID="FormDateBilling" TextMode="Date" ></asp:TextBox>
           </div>
           <div class="col-6">
               <label style="font-weight:bold" for="FormTaxIdInvoiced" class="form-label">Tax Id Invoiced:</label>
               <asp:TextBox CssClass="form-control" runat="server" ID="FormTaxIdInvoiced" ></asp:TextBox>
           </div>
       </div>

       
        <hr />

<asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary" Text="Save" OnClick="btnSave_Click" OnClientClick="return confirm('Create New Sale ? ');" />
<asp:Button ID="btnBack" runat="server" CssClass="btn btn-secondary" Text="Back to Sales" OnClick="btnBack_Click" />




         
    </ContentTemplate>

</asp:UpdatePanel>

</asp:Content>
