<%@ Page Title="OnetimePromocode" Language="C#" MasterPageFile="~/SunMaster.Master" AutoEventWireup="true" CodeBehind="OneTimePromocode.aspx.cs" Inherits="SUNWEB.OneTimePromocode" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
        .modalCss {
            display: none; /* Hidden by default */
            position: fixed; /* Stay in place */
            z-index: 1; /* Sit on top */
            padding-top: 80px; /* Location of the box */
            left: 0;
            top: 0;
            width: 100%; /* Full width */
            height: 100%; /* Full height */
            overflow: auto; /* Enable scroll if needed */
            background-color: rgb(0,0,0); /* Fallback color */
            background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
        }
        .modal-dialogCss 
        {
        }

        /* Modal Content */
        .modal-contentCss {
            background-color: #fefefe;
            margin: auto;
            width: 1150px;
            height: 400px;
            border-radius: 3px;
        }


        /* Create two equal columns that floats next to each other */
        .column {
            float: left;
            width: 40%;
            padding: 16px;
            height: auto; /* Should be removed. Only for demonstration */
        }

        /* Clear floats after the columns */
        .row:after {
            content: "";
            display: table;
            clear: both;
        }

        .ButtonSearch {
            background: #ffc108;
            margin: 0;
            font-family: Circular Std Book;
            font-size: 14px;
            line-height: inherit;
            border-width: thin;
            border-color: #212529;
            border-radius: 2px;
            color: #212529;
        }

        .progress-barCondimentImagePath {
            background-color: #5969ff;
            justify-content: center;
            color: #fff;
            text-align: center;
        }
    </style>
     <script language="javascript" type="text/javascript">

         function isNumberKey(evt, obj) {

             var charCode = (evt.which) ? evt.which : event.keyCode
             var value = obj.value;
             var dotcontains = value.indexOf(".") != -1;
             if (dotcontains)
                 if (charCode == 46) return false;
             if (charCode == 46) return true;
             if (charCode > 31 && (charCode < 48 || charCode > 57))
                 return false;
             return true;
         }



         function checkNumber(evt) {
             evt = (evt) ? evt : window.event
             var charCode = (evt.which) ? evt.which : evt.keyCode
             if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                 status = "This field accepts numbers only."
                 return false
             }
             status = ""
             return true
         }

         function validate() {

             if (document.getElementById("<%=txtPromocodeName.ClientID %>").value == "") {
                 alert("Enter Promo Code Name ");
                 document.getElementById("<%=txtPromocodeName.ClientID %>").focus();
                 return false;



             }


             if (document.getElementById("<%=txtPromoCode.ClientID %>").value == "") {
                 alert("Enter PromoCode");
                 document.getElementById("<%=txtPromoCode.ClientID %>").focus();
                 return false;
             }
             if (document.getElementById("<%=txtPromoValue.ClientID %>").value == "")
            {
                alert("Enter PromoCode  Value");
                document.getElementById("<%=txtPromoValue.ClientID %>").focus();
                return false;
             }

        

         }


         function ShowModalPromotionList() {
             var modal = document.getElementById("ModalPromotionList");
             modal.style.display = "block";
         }

         function CloseModalPromotionList() {
             var modal = document.getElementById("ModalPromotionList");
             modal.style.display = "none";
         }
         function ClearFields() {
             location.href = 'OnetimePromoCode.aspx';
         }


         function blockSpecialChar(e) {
             var k = e.keyCode;
             return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
         }


     </script>


    <style type="text/css">
 
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) 
{
    .DiveButtonSection 
     {
     margin-left:0px;
     }

}


@media only screen and (min-width : 321px) 
{
  .DiveButtonSection 
    {
    margin-left:0px;
    }

}

@media only screen  and (min-width : 1224px)
{
     .DiveButtonSection 
      {
       margin-left:405px;
      }


}





</style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel runat="server" ID="updatepanel1" UpdateMode="Conditional">
  <ContentTemplate>
      
     <%--  <table style="width:100%">
       <tr>
       <td>
          <h7> VOUCHER  PAGE </h7>
       </td>
       <td align="right" style="padding-bottom:7px;">
         
         <label for="validationCustom05">Branch  <asp:Label ID="lblBranchAliasName" runat="server"></asp:Label> </label> 
         <asp:DropDownList ID="cmbBranches" CssClass="form-select" Width="200px"
         runat="server" AutoPostBack="true" 
         onselectedindexchanged="cmbBranches_SelectedIndexChanged"></asp:DropDownList>

       </td>
       </tr>
       
      </table>--%>


    <div class="container-fluid">
    <div class="row mb-3 align-items-center">
        <!-- Left side: Heading -->
        <div class="col-md-6 col-12">
            <h6 class="mb-0">VOUCHER PAGE</h6>
        </div>

        <!-- Right side: Branch Dropdown aligned to right -->
        <div class="col-md-6 col-12">
            <div class="d-flex justify-content-md-end justify-content-start align-items-center mt-2 mt-md-0">
                <label for="cmbBranches" class="form-label me-2 mb-0">
                    Branch <asp:Label ID="lblBranchAliasName" runat="server"></asp:Label>
                </label>
                <asp:DropDownList ID="cmbBranches"
                    runat="server"
                    CssClass="form-select"
                    Style="width: 200px;"
                    AutoPostBack="true"
                    OnSelectedIndexChanged="cmbBranches_SelectedIndexChanged">
                </asp:DropDownList>
            </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" style="background-color: #4c4c4c; font-size: 14px; color: #F8F9FA"> &nbsp;&nbsp;
                   <button type="button" class="btn btn-warning" onclick="ShowModalPromotionList()">
                                Search
                               </button>
                               <button type="button" class="btn btn-success" onclick="ClearFields()">
                                Add New
                               </button>
                               
                                </h5>

                                
                                <div class="card-body">
                                    <form id="validationform" data-parsley-validate="" novalidate="">
                                        <div class="form-group row">
                                            <label class="col-12 col-sm-3 col-form-label text-sm-right">Promo Code Name </label>
                                            <div class="col-12 col-sm-8 col-lg-6">
                                               <asp:HiddenField ID="hidvaluePromoid" runat="server" Visible="false" />
                                                   
                                              <asp:TextBox ID="txtPromocodeName"  onkeypress="return blockSpecialChar(event)"   onpaste="return false"  autocomplete="off" class="form-control" Height="30px" runat="server"></asp:TextBox>
                                                                                          
                                            </div>
                                            


                                        </div>
                                        <div class="form-group row">
                                            <label class="col-12 col-sm-3 col-form-label text-sm-right">Promo Code</label>
                                            <div class="col-12 col-sm-8 col-lg-6">
                                                <asp:TextBox ID="txtPromoCode" onpaste="return false" onkeypress="return blockSpecialChar(event)" AutoPostBack="true" autocomplete="off" class="form-control" Height="30px" runat="server" OnTextChanged="txtPromoCode_TextChanged"></asp:TextBox>

                                                <div class="input-group-append">

                                                    <asp:RegularExpressionValidator ID="Regex2" runat="server" ControlToValidate="txtPromoCode"
                                                        ValidationExpression="[a-zA-Z0-9]*[^!@%~?:#$%^&*()0']" ErrorMessage="Special Characters Not Allowed (Including space)"
                                                        ForeColor="Red" />
                                                </div>

                                            </div>
                                        </div>
                                        

                                        <div class="form-group row">
                                            <label class="col-12 col-sm-3 col-form-label text-sm-right">Percentage</label>
                                            <div class="col-sm-4 col-lg-3">

                                                <asp:TextBox ID="txtPromoValue" onkeypress="return isNumberKey(event,this)" class="form-control" placeholder="Promo Value" autocomplete="off" runat="server"></asp:TextBox>
                                                <asp:Label ID="lblperSynmbol" runat="server" Text="%"></asp:Label>

                                                <div class="input-group-append">
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="txtPromoValue"
                                                        ErrorMessage="You Must Enter Promo Value!" ForeColor="Red" ValidationGroup="SubmitPromo"
                                                        Display="Dynamic" />

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


                                        <div class="form-group row" style="display:none">
                                            <label class="col-12 col-sm-3 col-form-label text-sm-right">Promotion Period </label>
                                            <div class="col-sm-4 col-lg-3 mb-3 mb-sm-0">
                                            <asp:TextBox ID="txtPromoStartDt"  class="form-control" runat="server" no-cache="true"></asp:TextBox>
                                            <asp:CalendarExtender ID="calFirstDueDate"  Format="yyyy-MM-dd" runat="server"  TargetControlID="txtPromoStartDt"  PopupPosition="BottomLeft" FirstDayOfWeek="Sunday"></asp:CalendarExtender>                                                                             
                                                 <div class="input-group-append">
                                                  <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="txtPromoStartDt"
                                                  ErrorMessage="You Must Enter Promo StartDate!" ForeColor="Red" ValidationGroup="SubmitPromo"
                                                  Display="Dynamic" />
                                                   
                                                 </div>

                                            </div>
                                            <div class="col-sm-4 col-lg-3">
                                                <asp:TextBox ID="txtPromoEnddt"  class="form-control" runat="server" no-cache="true"></asp:TextBox>
                                                <asp:CalendarExtender ID="CalendarExtender1"  Format="yyyy-MM-dd" runat="server"  TargetControlID="txtPromoEnddt"  PopupPosition="BottomLeft" FirstDayOfWeek="Sunday"></asp:CalendarExtender>                                                                             

                                                <div class="input-group-append">
                                                  <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="txtPromoEnddt"
                                                  ErrorMessage="You Must Enter Promo EndDate!" ForeColor="Red" ValidationGroup="SubmitPromo"
                                                  Display="Dynamic" />
                                                   
                                                 </div>
                                            </div>
                                        </div>

                                        <div class="DiveButtonSection">
                                            
                                            <asp:Button ID="btnAdd" runat="server" ValidationGroup="SubmitPromo"  OnClientClick="return  validate();" class="btn btn-primary" Text="Save"   OnClick="btnAdd_Click"/>
                                            <asp:Button ID="btnUpdate" runat="server"  ValidationGroup="SubmitPromo"  class="btn btn-primary" Text="Update" OnClientClick="return  validate();" OnClick="btnUpdate_Click"/>
                                            
                                        </div>

                                     </form>

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

            </div>


      
 
   
   <div>
       <h4>&nbsp;<asp:Label ID="lblGreeting" runat="server"></asp:Label></h4>
        
     </div>
      <div class="modalCss" id="ModalPromotionList">
                <div class="modal-dialogCss">
                    <div class="modal-contentCss" style="width:90%">
                        <div class="modal-body" style="padding: 0px;">
                            <div class="card">
                                <h7 class="card-header" style="background-color: #4c4c4c; color: White;">
                                    SEARCH PROMOCODE
                                    <button type="button" id="Button2" class="close" style="color: White; opacity: 1;"
                                        onclick="CloseModalPromotionList()">
                                        &times;</button></h7>
                                <div class="card-body">
                                    <table style="margin-bottom:5px">
                                        <tr>
                                            <td style="padding:3px;">
                                              &nbsp;&nbsp;Promo Name <asp:TextBox ID="txtInputPromocodeName" runat="server" class="form-control"  Width="300px"> </asp:TextBox>
                                            </td>
                                        
                                           
                                                
                                        </tr>
                                        <tr>
                                           <td style="padding:3px;">
                                            <asp:Button ID="btnSearchPromocode" runat="server" class="btn btn-primary" Text="Apply" OnClick="btnSearchPromocode_Click" />
                                               <asp:Button ID="btnClear" runat="server" class="btn btn-primary" Text="Clear" OnClick="btnClear_Click"  />
                                           </td>

                                            <td style="padding:3px;">
                                            
                                           </td>
                                        </tr>

                                    </table>
                                    <br />
                                    <div class="table-responsive" style="height: 550px">
                                        <label for="validationCustom03">
                                            Search Result:
                                        </label>
                                        <table id="Table2" class="table table-striped table-bordered second" style="width: 100%">
                                            <tbody>
                                                <caption>
                                                    <asp:Panel ID="Panel9"  runat="server" BackColor="white" Height="900px" ScrollBars="Auto" Width="1050px">
                                         
                                                        <asp:GridView ID="GrdPromoCode" runat="server" ShowFooter="false" BorderColor="Transparent"
                                                            DataKeyNames="Promoid" AutoGenerateColumns="false" EmptyDataText=" No Record Found ! "
                                                            Height="50px" Width="380px" OnRowCommand="GrdPromoCode_RowCommand" OnSelectedIndexChanged="OnSelectedIndexChanged" >
                                                            
                                                            <AlternatingRowStyle CssClass="dataTableAlt" />
                                                            <RowStyle CssClass="dataTable" />
                                                            <Columns>

                                                                 <asp:TemplateField HeaderText="SNo">
                                                                 <ItemTemplate>
                                                                 <%#Container.DataItemIndex + 1%>
                                                                 </ItemTemplate>
                                                                 </asp:TemplateField>
                                                                 <asp:TemplateField HeaderText="Promoid" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="left"
                                                                    ItemStyle-Width="150%" Visible="false" >
                                                                    <ItemTemplate>
                                                                   <asp:Label ID="lblPromoid" Width="200px" runat="server" Text='<%#Eval("Promoid")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>

                                                                <asp:TemplateField HeaderText="Promocode Name" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="left"
                                                                    ItemStyle-Width="150%" >
                                                                    <ItemTemplate>
                                                                   <asp:Label ID="lblPromocodeName" Width="200px" runat="server" Text='<%#Eval("PromoName")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="PromoCode" ItemStyle-Width="120%"  HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left"
                                                                    ItemStyle-HorizontalAlign="Left">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblPromoCode" Width="120px" runat="server" Text='<%#Eval("Promocode")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>
                                                               
                                                                <asp:TemplateField HeaderText="Promo Value" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-right"
                                                                    ItemStyle-Width="120%">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblPromoValue" runat="server" Width="100px" Text='<%#Eval("FlatPercentage")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>
                                                              

                                                                <asp:TemplateField HeaderText="CreatedDate" ItemStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-right"
                                                                    ItemStyle-Width="20%">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblcreatedDate" runat="server" Width="90px" DataFormatString = "{0:dd/MM/yyyy}"  Text='<%#Eval("createdDate")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>

                                                                  <asp:TemplateField HeaderText="Status" ItemStyle-Width="10%"  HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="text-left"
                                                                    ItemStyle-HorizontalAlign="Left">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblStatus" Width="20px" runat="server" Text='<%#Eval("Status")%>'></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>

                                                                <%--<asp:CommandField ShowDeleteButton="True" DeleteText="Remove"  ControlStyle-ForeColor="Red"   />--%>
                                                                
                                                                <asp:TemplateField HeaderText="Delete" ShowHeader="False">
                                                                    <ItemTemplate>
                                                                        <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" ForeColor="Red"
                                                                            ToolTip="Click Here to Remove" CommandName="Delete" OnClientClick="javascript: return confirm('Do you want to delete this record?')"
                                                                            CommandArgument='<%#bind("Promoid") %>' Text="Delete"></asp:LinkButton>
                                                                    </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"   ForeColor="Green" runat="server" Font-Underline="true"
                                                                    CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" CausesValidation="false">Edit</asp:LinkButton>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                            </Columns>
                                                        </asp:GridView>
                                                    </asp:Panel>
                                                </caption>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>




     </ContentTemplate>

  <Triggers>
     <asp:PostBackTrigger ControlID="btnAdd" />

     </Triggers>
     
    </asp:UpdatePanel>


  <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css?v=1.1" rel="stylesheet" />
 <!-- Bootstrap 5 -->
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
 <!-- Optional Bootstrap Icons -->
 <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
</asp:Content>
