<%@ Page Title="New Material Income" Language="C#" MasterPageFile="~/Site.Master" 
    AutoEventWireup="true" CodeBehind="MaterialsIncomeNew.aspx.cs" Inherits="SMTBETECH_V3.MaterialsIncomeNew" %>
<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('<%= FormRequestNumber.ClientID %>').value = "";
            document.getElementById('<%= FormRequestNumber.ClientID %>').focus();
        } catch (e) {
            alert(e);
        }
    }

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



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

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>

    <asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true" 
        AssociatedUpdatePanelID="UpdatePanelMaterialIncomeNew"  >

        <ProgressTemplate>
            Loading...
        </ProgressTemplate>

    </asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanelMaterialIncomeNew" runat="server" >

    <ContentTemplate>


         <%--Start Materials--%>

        <h5>Materials:</h5>

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

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


                <asp:Panel ID="PanelMaterials" 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="GVMaterials"
            runat="server"
            AutoGenerateColumns="False"
            AllowPaging="True"
            AllowSorting="False"
            OnRowCommand="GVMaterials_RowCommand" OnPageIndexChanging="GVMaterials_PageIndexChanging" PageSize="5">
        <HeaderStyle CssClass="table-primary" />
            <Columns>
                <asp:BoundField HeaderStyle-Width="80px" DataField="Id" HeaderText="Id" ReadOnly="True" InsertVisible="False" SortExpression="Id"></asp:BoundField>

                <asp:ButtonField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" ItemStyle-Wrap="false" SortExpression="PartNumber" 
                    CommandName="SelectMaterial" DataTextField="PartNumber" HeaderText="Part Number" />
            
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="400px" ItemStyle-Wrap="false" DataField="Description" HeaderText="Description" SortExpression="Description"></asp:BoundField>                    
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="100px" ItemStyle-Wrap="false" DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" 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" OnClick="btnCancelSelectMaterial_Click"/>
            </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>
        <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--%>

    <hr />

        <div class="row mb-1">
            <div class="col">
                <label style="font-weight:bold" for="FormImportDocType" class="form-label">Import Doc Type:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormImportDocType"></asp:TextBox>
            </div>
            <div class="col">
                <label style="font-weight:bold" for="FormQuantity" class="form-label">Quantity (+):</label>
                <asp:TextBox AutoPostBack="true" CssClass="form-control" runat="server" ID="FormQuantity" style="text-align:right;color:blue"
                    OnFocus="this.select()" OnKeyPress="return isNumberKey(this, event);" OnTextChanged="FormQuantity_TextChanged"></asp:TextBox>
            </div>

        </div>

        <div class="row mb-1">
            <div class="col">
                <label style="font-weight:bold" for="FormConditionOfGoods" class="form-label">Condition Of Goods:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormConditionOfGoods"></asp:TextBox>
            </div>

            <div class="col">
                <label style="font-weight:bold" for="FormBrandUsed" class="form-label">Brand Used:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormBrandUsed"></asp:TextBox>
            </div>
        </div>
        <div class="row mb-1">
            <div class="col">
                <label style="font-weight:bold" for="FormSerialNumber" class="form-label">Serial Number:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormSerialNumber"></asp:TextBox>
            </div>
             <div class="col">
                <label style="font-weight:bold" for="FormDateIncomming" class="form-label">Date Incomming:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormDateIncomming" TextMode="Date"></asp:TextBox>

            </div>

        </div>

        <div class="row mb-1">
            <div class="col">
                <label style="font-weight:bold" for="FormImportNo" class="form-label">Import No:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormImportNo"></asp:TextBox>
            </div>
            <div class="col">
                <label style="font-weight:bold" for="FormLocalNo" class="form-label">Local No:</label>
                <asp:TextBox CssClass="form-control" runat="server" ID="FormLocalNo"></asp:TextBox>
            </div>
        </div>

    <hr />
           

<%--Start CUSTOMS ENTRY DOCUMENT --%>
<h5>Customs Entry Documents:</h5>

     <asp:Button ID="btnNewRequest" runat="server" CssClass="btn btn-primary btn-sm" Text="New Document Number" OnClientClick="return SetRequestNumberFocus()" />
     
     <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderRequests" runat="server" 
         BackgroundCssClass="modalBackground" 
         DropShadow="True" 
         TargetControlID="btnNewRequest" 
         PopupControlID="panModalPopup" 
         CancelControlID="btnCancelButton" />

        <asp:Panel DefaultButton="btnSaveRequest" ID="panModalPopup" 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 Document Number</h4>
             <hr />
            <div class="row mb-1">
                <div class="col">
                    <label style="font-weight:bold" for="FormRequestNumber" class="form-label">Document Number:</label>
                    <asp:TextBox CssClass="form-control" runat="server" ID="FormRequestNumber"></asp:TextBox>
                </div>
            </div>
            
            <p></p>

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

     
     <p></p>

    <asp:GridView CssClass="table table-bordered table-striped table-sm" ShowHeaderWhenEmpty="true"
        ID="GVMaterialsRequests" runat="server" AutoGenerateColumns="false" OnRowCommand="GVMaterialsRequests_RowCommand">
        <Columns>
                        
           
            <asp:BoundField DataField="RequestNumber" HeaderText="Document Number" SortExpression="RequestNumber">
                <ItemStyle Width="400px" />
            </asp:BoundField>
            
            <asp:TemplateField HeaderStyle-CssClass="col-1" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>                        
                    <asp:Button runat="server" ID="btnDeleteRequest" CssClass="btn btn-close" 
                        CommandName="DeleteRequest" CommandArgument='<%# Container.DataItemIndex %>'/>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>No Document Numbers</EmptyDataTemplate>
    </asp:GridView>

<%--End CUSTOMS ENTRY DOCUMENT --%>

<%-- START ATTACH CUSTOMS ENTRY DOCUMENT --%>

     <h6>Files:</h6>

     <script type="text/javascript">

         function uploadComplete(sender, args) {
             __doPostBack('<%= btnRefresh.UniqueID %>', '');
         }

     </script>

     <ajaxToolkit:AsyncFileUpload ID="AsyncFileUploadCustomsEntryDocument" runat="server" OnClientUploadComplete="uploadComplete" OnUploadedComplete="AsyncFileUploadCustomsEntryDocument_UploadedComplete" />

        <asp:Button style="display:none" ID="btnRefresh" Text="refresh" runat="server" onclick="btnRefresh_Click" />
     
        <asp:GridView CssClass="table table-bordered table-striped table-sm"
            ID="GVFilesCustomsEntryDocument" runat="server" AutoGenerateColumns="false" OnRowCommand="GVFilesCustomsEntryDocument_RowCommand">
            <Columns>
                <asp:TemplateField HeaderText="Files">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbCustomsEntryDocument" runat="server" Text='<%# Eval("file") %>' 
                            CommandName="OpenCustomsEntryDocument" CommandArgument= '<%# Eval("file") %>' ></asp:LinkButton>
                        <asp:Button runat="server" ID="btnDeleteCustomsEntryDocument" CssClass="btn btn-close" 
                            CommandName="DeleteCustomsEntryDocument" CommandArgument= '<%# Eval("file") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <h6 style="font-weight:bold">No Files</h6>
            </EmptyDataTemplate>
        </asp:GridView>
<%-- END ATTACH CUSTOMS ENTRY DOCUMENT --%>



<hr />

        <%--Start Suppliers--%>

        <h5>Supplier:</h5>



    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderSuppliers" runat="server" BackgroundCssClass="modalBackground" 
        DropShadow="True" TargetControlID="btnSelectSupplier" PopupControlID="PanelSuppliers" CancelControlID="btnCancelButton" />

        <asp:Panel ID="PanelSuppliers" 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 Supplier</h4>
            <hr />

           <%-- Start Grid Suppliers--%>

            <asp:Panel runat="server" DefaultButton="btnSearch">
                <div class="row" style="width:100%">
                    <div class="col-6">
                        <asp:TextBox CssClass="form-control" placeholder="Search Supplier"  runat="server"
                            ID="txtSearchSupplier" AutoPostBack="false" onFocus="this.select()"/>
                    </div>
                    <div class="col-6" style="text-align:left">
                        <asp:Button CssClass="btn btn-primary btn-sm" ID="btnSearch" runat="server" 
                            Text="Search" OnClick="btnSearch_Click"/>
                        <asp:Button CssClass="btn btn-primary btn-sm" ID="btnClearSearch" runat="server"
                            Text="Clear" OnClick="btnClearSearch_Click"/>
                    </div>
               </div>
                <p></p>
            </asp:Panel>

        <div style="overflow-x:scroll">
        <asp:GridView CssClass="table table-bordered table-striped table-sm"
            ID="GVSuppliers"
            runat="server"
            AutoGenerateColumns="False"
            AllowPaging="True"
            AllowSorting="False"
            OnRowCommand="GVSuppliers_RowCommand" OnPageIndexChanging="GVSuppliers_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="SupplierName" 
                    CommandName="SelectSupplier" DataTextField="SupplierName" HeaderText="Supplier Name" />
        
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" DataField="SupplierAbbrevation" HeaderText="Customer Abbrevation" SortExpression="SupplierAbbrevation"></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="Street" HeaderText="Street" SortExpression="Street"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false"  DataField="Suburb" HeaderText="Suburb" SortExpression="Suburb"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="Municipality" HeaderText="Municipality" SortExpression="Municipality"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="ZipCode" HeaderText="Zip Code" SortExpression="ZipCode"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="State" HeaderText="State" SortExpression="State"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="Country" HeaderText="Country" SortExpression="Country"></asp:BoundField>
                <asp:BoundField HeaderStyle-Wrap="false" HeaderStyle-Width="200px" ItemStyle-Wrap="false" DataField="TermsPayment" HeaderText="Terms of 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="lblCount"></asp:Label>
            </div>


            <%--End Grid Suppliers--%>
        
            <p></p>

            <div style="text-align:right;">
                <%--<asp:Button ID="btnSelectSupplierModal" CssClass="btn btn-primary btn-sm" runat="server" Text="Select Supplier" OnClick="btnSelectSupplierModal_Click" />--%>
                <asp:Button ID="btnCancelSelectSupplier" CssClass="btn btn-secondary btn-sm" runat="server" Text="Cancel" OnClick="btnCancelSelectSupplier_Click"/>
            </div>
        </asp:Panel>

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

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

        <%--End Suppliers--%>

        <hr />

    <div class="row mb-1">
         <div class="col">
            <label style="font-weight:bold" for="FormImportCarrier" class="form-label">Import Carrier:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormImportCarrier"></asp:TextBox>
        </div>
         <div class="col">
            <label style="font-weight:bold" for="FormLocalCarrier" class="form-label">Local Carrier:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormLocalCarrier"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
         <div class="col">
            <label style="font-weight:bold" for="FormAWBTrackingNo" class="form-label">AWB Tracking No:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormAWBTrackingNo"></asp:TextBox>
        </div>
         <div class="col">
            <label style="font-weight:bold" for="FormBillLadingNo" class="form-label">Bill Lading No:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillLadingNo"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col-6">
            <label style="font-weight:bold" for="FormRackLocation" class="form-label">Rack Location:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormRackLocation"></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 Material Income ? ');" />
      <asp:Button ID="btnBack" runat="server" CssClass="btn btn-secondary" Text="Back to Materials Income" OnClick="btnBack_Click" />


    </ContentTemplate>

</asp:UpdatePanel>




</asp:Content>
