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

     <h2 id="title"><%: Title %></h2>
 
 <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>

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

<ProgressTemplate>
   Loading...
</ProgressTemplate>

 </asp:UpdateProgress>

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

     <ContentTemplate>


    <div class="row mb-1">
        <div class="col-2">
            <label style="font-weight:bold" for="FormCustomerID" class="form-label">Id:</label>
            <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormCustomerID"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormCustomerName" class="form-label">Customer Name:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormCustomerName"></asp:TextBox>
        </div>
    </div>
    
    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormCustomerAbbrevation" class="form-label">Abbrevation:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormCustomerAbbrevation"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormVendorNo" class="form-label">Vendor No:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormVendorNo"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormTaxID" class="form-label">Tax ID:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormTaxID"></asp:TextBox>
        </div>
    </div>

    <hr />

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormBillToStreet" class="form-label">Bill To Street:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToStreet"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormBillToSuburb" class="form-label">Bill To Suburb:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToSuburb"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormBillToMunicipality" class="form-label">Bill To Municipality:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToMunicipality"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormBillToZipCode" class="form-label">Bill To ZipCode:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToZipCode"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormBillToState" class="form-label">Bill To State:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToState"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormBillToCountry" class="form-label">Bill To Country:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormBillToCountry"></asp:TextBox>
        </div>
    </div>

    <hr />

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormShipToStreet" class="form-label">Ship To Street:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToStreet"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormShipToSuburb" class="form-label">Ship To Suburb:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToSuburb"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormShipToMunicipality" class="form-label">Ship To Municipality:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToMunicipality"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormShipToZipCode" class="form-label">Ship To ZipCode:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToZipCode"></asp:TextBox>
        </div>
    </div>

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormShipToState" class="form-label">Ship To State:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToState"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormShipToCountry" class="form-label">Ship To Country:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormShipToCountry"></asp:TextBox>
        </div>
    </div>

    <hr />

         <%--Start BUYERS --%>
    <h4>Buyers:</h4>
         
         <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderBuyers" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" TargetControlID="btnNewBuyer" PopupControlID="panModalPopup" CancelControlID="btnCancelButton" />
            <asp:Panel 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 Buyer</h4>
                 <hr />
                <div class="row mb-1">
                    <div class="col">
                        <label style="font-weight:bold" for="FormBuyerName" class="form-label">Buyer Name:</label>
                        <asp:TextBox CssClass="form-control" runat="server" ID="FormBuyerName"></asp:TextBox>
                    </div>
                </div>
                <div class="row mb-1">
                    <div class="col">
                        <label style="font-weight:bold" for="FormBuyerEmail" class="form-label">Buyer Email:</label>
                        <asp:TextBox CssClass="form-control" runat="server" ID="FormBuyerEmail"></asp:TextBox>
                    </div>
                </div>
                <div class="row mb-1">
                    <div class="col">
                        <label style="font-weight:bold" for="FormBuyerPhone" class="form-label">Buyer Phone:</label>
                        <asp:TextBox CssClass="form-control" runat="server" ID="FormBuyerPhone"></asp:TextBox>
                    </div>
                </div>

                <p></p>

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

         <asp:Button ID="btnNewBuyer" runat="server" CssClass="btn btn-primary btn-sm" Text="New Buyer" />
         <p></p>

        <div style="overflow-x:scroll">
        <asp:GridView CssClass="table table-bordered table-striped table-sm"
            ID="GVCustomersBuyers" runat="server" AutoGenerateColumns="false" OnRowCommand="GVCustomersBuyers_RowCommand">
            <HeaderStyle CssClass="table-primary" />
            <Columns>
                <asp:BoundField Visible="false" DataField="IdBuyer" HeaderText="Id" SortExpression="IdBuyer" InsertVisible="False" ReadOnly="True">
                <ItemStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField DataField="BuyerName" HeaderText="Buyer Name" SortExpression="BuyerName">
                <ItemStyle Width="400px" />
                </asp:BoundField>
                <asp:BoundField DataField="BuyerEmail" HeaderText="Buyer Email" SortExpression="BuyerEmail">
                <ItemStyle Width="200px" />
                </asp:BoundField>
                <asp:BoundField DataField="BuyerPhone" HeaderText="Buyer Phone" SortExpression="BuyerPhone">
                <ItemStyle Width="200px" />
                </asp:BoundField>

                <asp:TemplateField HeaderStyle-CssClass="col-1" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>                        
                        <asp:Button runat="server" ID="btnDeleteBuyer" CssClass="btn btn-close" CommandName="DeleteBuyer" CommandArgument= '<%# Eval("IdBuyer") %>' />
                    </ItemTemplate>
                </asp:TemplateField>

            </Columns>

            <EmptyDataTemplate>No Buyers</EmptyDataTemplate>
        </asp:GridView>
      </div>
         <%--End BUYERS --%>

    <hr />

   

    <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormTermsPayment" class="form-label">Terms of Payment:</label>
            <asp:TextBox CssClass="form-control" runat="server" ID="FormTermsPayment"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormDropDownCurrency" class="form-label">Currency:</label>
            <asp:DropDownList CssClass="form-select" runat="server" ID="FormDropDownCurrency">
                <asp:ListItem></asp:ListItem>
                <asp:ListItem>MXN</asp:ListItem>
                <asp:ListItem>USD</asp:ListItem>
            </asp:DropDownList>
            <%--<asp:TextBox CssClass="form-control" runat="server" ID="FormCurrency"></asp:TextBox>--%>
        </div>
    </div>




    <hr />

         <%-- START Certificate of Tax Status --%>

         <h6 style="font-weight:bold">Certificate of Tax Status</h6>

         <script type="text/javascript">

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

         </script>

      
         <ajaxToolkit:AsyncFileUpload ID="AsyncFileUploadTaxStatus" runat="server" OnClientUploadComplete="uploadComplete" OnUploadedComplete="AsyncFileUploadTaxStatus_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="GVFilesTaxStatus" runat="server" AutoGenerateColumns="false" OnRowCommand="GVFilesTaxStatus_RowCommand">
                <%--<HeaderStyle CssClass="table-primary" />--%>
                <Columns>
                    <asp:TemplateField HeaderText="Files">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbTaxStatus" runat="server" Text='<%# Eval("file") %>' 
                                CommandName="OpenTaxStatus" CommandArgument= '<%# Eval("file") %>' ></asp:LinkButton>
                            <asp:Button runat="server" ID="btnDeleteTaxStatus" CssClass="btn btn-close" 
                                CommandName="DeleteTaxStatus" CommandArgument= '<%# Eval("file") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <h6 style="font-weight:bold">No Files</h6>
                </EmptyDataTemplate>
            </asp:GridView>
         <%-- END Certificate of Tax Status --%>

    <hr />

          <%-- START Contract Documents --%>
        <h6 style="font-weight:bold">Contract Documents</h6>

        <script type="text/javascript">
            function uploadCompleteCD(sender, args) {
                __doPostBack('<%= btnRefreshCD.UniqueID %>', '');
                }
        </script>

        <ajaxToolkit:AsyncFileUpload ID="AsyncFileUploadContractDocuments" runat="server" 
            OnClientUploadComplete="uploadCompleteCD" OnUploadedComplete="AsyncFileUploadContractDocuments_UploadedComplete" />

        <asp:Button style="display:none" ID="btnRefreshCD" Text="refresh" runat="server" onclick="btnRefreshCD_Click" />
         
                 <asp:GridView CssClass="table table-bordered table-striped table-sm"
                ID="GVFilesContractDocuments" runat="server" AutoGenerateColumns="false" OnRowCommand="GVFilesContractDocuments_RowCommand" >
                <%--<HeaderStyle CssClass="table-primary" />--%>
                <Columns>
                    <asp:TemplateField HeaderText="Files">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbContractDocuments" runat="server" Text='<%# Eval("file") %>'
                                CommandName="OpenContractDocuments" CommandArgument='<%# Eval("file") %>' ></asp:LinkButton>
                            <asp:Button runat="server" ID="btnDeleteContractDocuments" CssClass="btn btn-close"
                                CommandName="DeleteContractDocuments" CommandArgument='<%# Eval("file") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <h6 style="font-weight:bold">No Files</h6>
                </EmptyDataTemplate>
                </asp:GridView>
    
          <%-- END Contract Documents --%>

    <hr />



               <%-- START Logo --%>
    <h6 style="font-weight:bold">Logos</h6>

    <script type="text/javascript">
        function uploadCompleteLogo(sender, args) {
            __doPostBack('<%= btnRefreshLogo.UniqueID %>', '');
        }
    </script>

    <ajaxToolkit:AsyncFileUpload ID="AsyncFileUploadLogo" runat="server" 
        OnClientUploadComplete="uploadCompleteLogo" OnUploadedComplete="AsyncFileUploadLogo_UploadedComplete" />

    <asp:Button style="display:none" ID="btnRefreshLogo" Text="refresh" runat="server" onclick="btnRefreshLogo_Click" />
     
             <asp:GridView CssClass="table table-bordered table-striped table-sm"
            ID="GVFilesLogo" runat="server" AutoGenerateColumns="false" OnRowCommand="GVFilesLogo_RowCommand" >
            <Columns>
                <asp:TemplateField HeaderText="Files">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbLogo" runat="server" Text='<%# Eval("file") %>'
                            CommandName="OpenLogo" CommandArgument='<%# Eval("file") %>' ></asp:LinkButton>
                        <asp:Button runat="server" ID="btnDeleteLogo" CssClass="btn btn-close"
                            CommandName="DeleteLogo" CommandArgument='<%# Eval("file") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <h6 style="font-weight:bold">No Files</h6>
            </EmptyDataTemplate>
            </asp:GridView>

      <%-- END Logo --%>

<hr />






   <div class="row mb-1">
        <div class="col">
            <label style="font-weight:bold" for="FormCreationDate" class="form-label">Creation Date:</label>
            <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormCreationDate"></asp:TextBox>
        </div>
        <div class="col">
            <label style="font-weight:bold" for="FormModifiedDate" class="form-label">Last Modified Date:</label>
            <asp:TextBox disabled="true" CssClass="form-control" runat="server" ID="FormModifiedDate"></asp:TextBox>
        </div>
        
   
    </div>

         <asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary" Text="Update" OnClick="btnSave_Click" OnClientClick="return confirm('Update Customer ? ');" />
         <asp:Button ID="btnBack" runat="server" CssClass="btn btn-secondary" Text="Back to Customers" OnClick="btnBack_Click" />
         
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
