<%@ Page Title="Customer Master" Language="C#" MasterPageFile="~/SunMaster.Master" AutoEventWireup="true" CodeBehind="CustomerMaster.aspx.cs" Inherits="SUNWEB.CustomerMaster" %>
<%@ Register Assembly="AjaxControlToolkit" TagPrefix="asp" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

 <script language="javascript" type="text/javascript">

     function validate() {

         if (document.getElementById("<%=txtCustNo.ClientID %>").value == "") {
             alert("Enter the CustomerNo");
             document.getElementById("<%=txtCustNo.ClientID %>").focus();
             return false;
         }

         if (document.getElementById("<%=txtCustomerName.ClientID %>").value == "") {
             alert("Enter CustomerName");
             document.getElementById("<%=txtCustomerName.ClientID %>").focus();
             return false;
         }

         if (document.getElementById("<%=txtBirthDate.ClientID %>").value == "") {
             alert("Enter BirthDate");
             document.getElementById("<%=txtBirthDate.ClientID %>").focus();
             return false;
         }

     }
    </script>

<%--   <script type="text/javascript" language="javascript">
        window.onbeforeunload = function () {
            var msg = "Are you sure you want to close windows";
            return msg;
        }
       </script>--%>

    <style type="text/css">
    @media only screen and (max-width: 600px)
     {
      div 
       {
       text-align:left;        
       }
     }
  </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div align="left">
     <asp:Button ID="btnExcel" runat="server" Text="Excel" ToolTip="To Export the Report Click Here"  CssClass="btn btn-success active"  onclick="btnExcel_Click"/>
     </div>
     
 <asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
  <ContentTemplate>
              <div class="section-block">
                    <h5 class="section-title">
                        CUSTOMER MASTER</h5>
                </div>

    

             <div class="row">
                      
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="card">
                                
                                <div class="card-body">
                                   
                       
                                       
                                              <div align="right">
                                            <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <label for="validationCustom05">Branch  <asp:Label ID="lblBranchAliasName" runat="server"></asp:Label> </label> 
                                                <asp:DropDownList ID="cmbBranches" CssClass="custom-select"  
                                                Width="250px" runat="server" AutoPostBack="true" 
                                                onselectedindexchanged="cmbBranches_SelectedIndexChanged"></asp:DropDownList>
                                              
                                            </div>
                                            
                                           
                                        </div>
                                   
                                </div>
                            </div>
                        </div>
                      
                    </div>


                        <div class="row">
                 
                          <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="card">
                              <h5 class="card-header">
                                        Customer Details
                                </h5>
                                                    
                                <div class="card-body">
                                
                                 <div class="form-row">


                                      <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                               <label for="validationCustom03">
                                                      Customer#
                                                   </label>
                                                 <asp:TextBox ID="txtCustNo"  class="form-control" runat="server"  ></asp:TextBox>
                                                     
                                                   <asp:HiddenField  ID="hidCustomerID" runat="server" />
                                            </div>
                                           <%-- <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <caption>
                                                    <label for="validationCustom03">
                                                      Id
                                                   </label>
                                                   <asp:TextBox ID="txtCustomerId"  class="form-control" runat="server"  ></asp:TextBox>
                                                
                                                     
                                                </caption>
                                                
                                            </div>--%>
                                            <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">

                                                <label for="validationCustom03"> Customer Name  
                                                 </label>
                                                 <asp:TextBox ID="txtCustomerName" class="form-control" runat="server"></asp:TextBox>
                                            </div>


                                              <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">

                                                <label for="validationCustom03">  Birth Date
                                                 </label>
                                                   <asp:TextBox ID="txtBirthDate"  class="form-control" runat="server"  ></asp:TextBox>
                                                   <asp:CalendarExtender ID="calFirstDueDate"  Format="yyyy-MM-dd" runat="server"  TargetControlID="txtBirthDate"  PopupPosition="BottomLeft" FirstDayOfWeek="Sunday"></asp:CalendarExtender>                         
                                              
                                            </div>

                                               
                        
                                        </div>
                                         <div class="form-row">
                                      

                                    <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">

                                                <label for="validationCustom03">MobileNo
                                                 </label>
                                                 <asp:TextBox ID="txtMobileNo" class="form-control" runat="server"></asp:TextBox>
                                            </div>

                                              <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">

                                                <label for="validationCustom03">  Email
                                                 </label>
                                                   <asp:TextBox ID="txtEmail"  class="form-control" runat="server"  ></asp:TextBox>
                                                 
                                              
                                           </div>




                                         </div>

                                         

                                         
                                           <div class="form-row">
                                             <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <asp:Button ID="btnSave" runat="server" Text="SAVE"  
                                                CssClass="btn btn-primary" onclick="btnSave_Click" OnClientClick="return validate()"   />

                                                 <asp:Button ID="btnUpdate" runat="server" Text="UPDATE"  
                                                CssClass="btn btn-primary" onclick="btnUpdate_Click" OnClientClick="return validate()"   />
   
   
                                             </div>
                                         </div>


                                 </div>
                                 
                                
                                                         
                                </div>
                            </div>
                        </div>

                        

                          <div class="card">
                                    <h5 class="card-header">Title  </h5>
                                       <div class="card-body border-top">
                                         <div class="form-row">
                                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <label for="validationCustom04">Search By </label>
                                                 <asp:DropDownList ID="cmbSearch" CssClass="custom-select"  runat="server" AutoPostBack="true" onselectedindexchanged="cmbSearch_SelectedIndexChanged" >
                                                
                                               
                                                 <asp:ListItem Value="0" Text="Select"></asp:ListItem>
                                                 <asp:ListItem Value="1" Text="All Customers"></asp:ListItem>
                                                 <asp:ListItem Value="2" Text="CustomerNumber"></asp:ListItem>
                                                 <asp:ListItem Value="3" Text="CustomerName"></asp:ListItem>
                                                <asp:ListItem  Value="4" Text="Id"></asp:ListItem>
                                                <asp:ListItem  Value="5" Text="Mobile"></asp:ListItem>
                                                
                                                </asp:DropDownList>
                                            

                                                </div>

                                                   <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <label for="validationCustom04"> Search Value  </label>
                                                 <asp:TextBox ID="txtSearchVal"  class="form-control" runat="server"></asp:TextBox>
                                                 
                                                </div>
                                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                </div>
                                                <div class="col-xl-4 col-lg-4 col-md-12 col-sm-12 col-12 mb-2">
                                                <asp:Button ID="btnSearchbyVal" runat="server" Text="Search"  CssClass="btn btn-primary" onclick="btnSearchbyVal_Click"  />
                                          
                                                </div>

                                          
                                      </div>
                                    </div>

                                </div>




                        <div class="row">
                       <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="card">
                        <div class="card-header">
                         <div>
               
                </div>
                <h4> <asp:Label ID="lblSearchResult" runat="server"> </asp:Label>  </h4>       
                                
                   </div>
                   <div class="card-body">
                   <div class="table-responsive">
                   <table id="example" class="table table-striped table-bordered second" style="width:100%">
                   <tbody>
                   <caption>
                   <asp:Panel ID="Panel8" runat="server" BackColor="white" Height="500px"    ScrollBars="Auto" Width="1500px">                     
                   <asp:GridView ID="grdCustomerMaster" runat="server" AutoGenerateColumns="False"  EmptyDataRowStyle-CssClass="alert-dark"
                    Font-Size="11px" HeaderStyle-BackColor="RoyalBlue" EmptyDataText="No Such Record Found ! " 
                    DataKeyNames="CustomerID" FooterStyle-BackColor="Green" FooterStyle-ForeColor="white" 
                    Width="920px"  AllowPaging="true" PageSize="15000000" OnRowCommand="grdCustomerMaster_RowCommand"
                    BackColor="White" AllowSorting="true"  
                    BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                    OnSelectedIndexChanged="grdCustomerMaster_SelectedIndexChanged">
                     
                    <Columns>
                      
                        <%--<asp:TemplateField HeaderText="SNo">
                        <ItemTemplate>
                        <%#Container.DataItemIndex+1 %>
                        </ItemTemplate>
                        </asp:TemplateField>--%>


                        <%--  <asp:TemplateField>  
                           <HeaderTemplate>   
                           <asp:CheckBox ID="chkAllSelect" runat="server" onclick="CheckAll(this);"  />  
                           </HeaderTemplate>  
                           <ItemTemplate>  
                           <asp:CheckBox ID="chkSelect" runat="server" />  
                           </ItemTemplate>  
                          </asp:TemplateField>  
                     --%>

                  <asp:TemplateField HeaderText="Cust_id"  ItemStyle-HorizontalAlign="Left" Visible="false">
                  <ItemTemplate >
                  <asp:Label ID="lblCustomerid"   runat="server" Text='<%#Eval("CustomerID") %>'></asp:Label>
                  </ItemTemplate>
                  </asp:TemplateField>
            
                  <asp:TemplateField HeaderText="Cust_No"  ItemStyle-HorizontalAlign="Left">
                  <ItemTemplate >
                  <asp:Label ID="lblCustomerNumber"   runat="server" Text='<%#Eval("CustomerNumber") %>'></asp:Label>
                  </ItemTemplate>
                  </asp:TemplateField>
            
                 <asp:TemplateField HeaderText="ID" ItemStyle-Width="80px" >
                   <ItemTemplate>
                   <asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
                   </ItemTemplate>
                           
                   </asp:TemplateField>     

                  <asp:TemplateField HeaderText="Cust_Name"  ItemStyle-HorizontalAlign="Left">
                  <ItemTemplate >
                  <asp:Label ID="lblCustomerName"   runat="server" Text='<%#Eval("CustomerName") %>'></asp:Label>
                  </ItemTemplate>
                  </asp:TemplateField>

                  <asp:TemplateField HeaderText="OpenDt" ItemStyle-Width="80px" >
                   <ItemTemplate>
                   <asp:Label ID="lblOpenDate" runat="server" Text='<%#Eval("OpenDate","{0:dd/MM/yyyy}") %>'></asp:Label>
                   </ItemTemplate>
         
                  </asp:TemplateField>    
                  
                  <asp:TemplateField HeaderText="Email"  ItemStyle-HorizontalAlign="Left">
                  <ItemTemplate >
                  <asp:Label ID="lblEmail"   runat="server" Text='<%#Eval("EmailAddress") %>'></asp:Label>
                  </ItemTemplate>
                  </asp:TemplateField>
                  
                  <asp:TemplateField HeaderText="MobileNo"  ItemStyle-HorizontalAlign="Left">
                  <ItemTemplate >
                  <asp:Label ID="lblTel1"   runat="server" Text='<%#Eval("Mobile") %>'></asp:Label>
                  </ItemTemplate>
                  </asp:TemplateField>
                  
                  <asp:TemplateField>
                  <ItemTemplate>
                  <%--<asp:ImageButton ID="imgbtn1" ImageUrl="~/IMG/edit.png" Width="30px" Height="25px"  runat="server" CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" />--%>
                  <asp:LinkButton ID="imgbtn1" ImageUrl="~/IMG/edit.png" Text="Edit" ForeColor="Green"  runat="server" CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>"></asp:LinkButton>


                  </ItemTemplate>
                  </asp:TemplateField>



                <asp:ButtonField Text="Select" CommandName="Select" ItemStyle-Width="150" Visible="false" />
                </Columns>
                <pagerstyle cssclass="gridview">
                </pagerstyle>
                <FooterStyle BackColor="#006699" ForeColor="White"></FooterStyle>
                <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black"></HeaderStyle>
                    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                    <RowStyle ForeColor="#000066" />
                    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#007DBB" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#00547E" />
                     </asp:GridView>

                    </asp:Panel>                  
                    </caption>
                                          
                    </tbody>
                   
                    </table>
                     
                    </div>
                   </div>


                            
                </div>
               </div>
              </div> 
   
     <div>
       <h4>&nbsp;<asp:Label ID="lblGreeting" runat="server"></asp:Label></h4>
           <%--<asp:Button ID="btnPdf" runat="server" Text="PDF" 
            ToolTip="To Export  the Report Click Here"  CssClass="btn btn-secondary" 
            onclick="btnPdf_Click"/>--%>   
     </div>
     </ContentTemplate>
     </asp:UpdatePanel>



</asp:Content>
