Anyone added a Search in the Admin Manage Discounts

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
dbo.Nop_Discount.[CouponCode]

Has anyone added a search button and search text to <list> Coupon Codes in the Admin / Manage Discounts section.  

So far added a search box / where you can add text in - but not the back end in searching the Coupon Codes...

Any advice would be great - or where to get code from another page so can customise it for trail and error.

Cheers
Simon

Some info below..... Might need help on C# end....

Admin / Discounts.ascx


<%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Administration.Modules.DiscountsControl"
    CodeBehind="Discounts.ascx.cs" %>

<%@ Register TagPrefix="nopCommerce" TagName="ToolTipLabel" Src="ToolTipLabelControl.ascx" %>

<div class="section-header">
    <div class="title">
        <img src="Common/ico-promotions.png" alt="<%=GetLocaleResourceString("Admin.Discounts.Title")%>" />
        <%=GetLocaleResourceString("Admin.Discounts.Title")%>
    </div>
    <div class="options">

<%--New code--%>
<%--            <asp:Button ID="SearchButton" runat="server" Text="<% $NopResources:Admin. ???????????? .SearchButton.Text %>" CssClass="adminButtonBlue" OnClick="SearchButton_Click" />--%>
<%--End of NEW code--%>


        <input type="button" onclick="location.href='DiscountAdd.aspx'" value="<%=GetLocaleResourceString("Admin.Discounts.AddNewButton.Text")%>"
            id="btnAddNew" class="adminButtonBlue" title="<%=GetLocaleResourceString("Admin.Discounts.AddNewButton.Tooltip")%>" />
    </div>
</div>


<%--New Code--%>
<table width="100%">
    <tr>
        <td class="adminTitle">

<%--<nopCommerce:ToolTipLabel runat="server" ID="      " Text="<% $NopResources:Admin.     %>"
                ToolTip="<% $NopResources:Admin.    .Tooltip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />--%>
        </td>
        <td class="adminData">
            <asp:TextBox ID="txtEmail" CssClass="adminInput" runat="server"></asp:TextBox>
        </td>
    </tr>
</table>
<p>
</p>
<script type="text/javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".cbHeader input");
        var cbRowItem = $(".cbRowItem input");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });
</script>
12 years ago
Hello ....

How can i show product list which has been already searched in search box  on home page???

Plz Help Me.....

Thank u...
12 years ago
I am also working on the Coupon search bar...

Gone for INPUT buttons as ASP:Button just crashes the system... I still have to program the backend in C# any help would be great - will post below my code if anyone interested...


I have added a Coupon Code in data area... So you can search by (Find) ctrl F in web browser...
        <asp:BoundField DataField="CouponCode" HeaderText="<% $NopResources:Admin.Discounts.Coupon %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>


code...Ascx
        <td class="adminTitle">
            <nopCommerce:ToolTipLabel runat="server" ID="lblGoDirectlyToCouponNumber" Text="<% $NopResources:Admin.Discounts.CouponCodes %>"
                ToolTip="<% $NopResources:Admin.Discounts.SearchText.Tooltip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
        </td>
        <td class="adminData">
            <nopCommerce:SimpleTextBox runat="server" CssClass="adminInput" ID="txtCoupon" Width="150px"
                ValidationGroup="GoDirectly" ErrorMessage="<% $NopResources:Admin.Orders.GoDirectly.ErrorMessage %>">
            </nopCommerce:SimpleTextBox>

            <input type="button" onclick="btnGoDirectlyToCouponNumber_Click" class="adminButtonBlue" value="<%=GetLocaleResourceString("Admin.Discounts.SearchButton.Text")%>"
            id="btnGoDirectlyToCouponNumber" title="<%=GetLocaleResourceString("Admin.Discounts.SearchButton.Tooltip")%>" />



On the C# trying to get the Search button to open up the Coupon Discount...
btnGoDirectlyToCouponNumber_Click

        protected void btnGoDirectlyToCouponNumber_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    int CouponCode = 0;
                    if (int.TryParse(txtCoupon.Text.Trim(), out CouponCode))
                    {
                        string url = string.Format("{0}DiscountDetails.aspx?DiscountID={1}", CommonHelper.GetStoreAdminLocation(), CouponCode);
                        Response.Redirect(url);
                    }
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }
12 years ago
Discounts.ascx


<%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Administration.Modules.DiscountsControl"
    CodeBehind="Discounts.ascx.cs" %>

<%@ Register TagPrefix="nopCommerce" TagName="ToolTipLabel" Src="ToolTipLabelControl.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="SimpleTextBox" Src="SimpleTextBox.ascx" %>

<div class="section-header">
    <div class="title">
        <img src="Common/ico-promotions.png" alt="<%=GetLocaleResourceString("Admin.Discounts.Title")%>" />
        <%=GetLocaleResourceString("Admin.Discounts.Title")%>
    </div>
    <div class="options">
        <input type="button" onclick="location.href='DiscountAdd.aspx'" value="<%=GetLocaleResourceString("Admin.Discounts.AddNewButton.Text")%>"
            id="btnAddNew" class="adminButtonBlue" title="<%=GetLocaleResourceString("Admin.Discounts.AddNewButton.Tooltip")%>" />
    </div>
</div>
<table width="100%">
    <tr>
        <td class="adminTitle">
            <nopCommerce:ToolTipLabel runat="server" ID="lblGoDirectlyToCouponNumber" Text="<% $NopResources:Admin.Discounts.CouponCodes %>"
                ToolTip="<% $NopResources:Admin.Discounts.SearchText.Tooltip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
        </td>
        <td class="adminData">
            <nopCommerce:SimpleTextBox runat="server" CssClass="adminInput" ID="txtCoupon" Width="150px"
                ValidationGroup="GoDirectly" ErrorMessage="<% $NopResources:Admin.Orders.GoDirectly.ErrorMessage %>">
            </nopCommerce:SimpleTextBox>

            <input type="button" onclick="btnGoDirectlyToCouponNumber_Click" class="adminButtonBlue" value="<%=GetLocaleResourceString("Admin.Discounts.SearchButton.Text")%>"
            id="btnGoDirectlyToCouponNumber" title="<%=GetLocaleResourceString("Admin.Discounts.SearchButton.Tooltip")%>" />
        </td>
    </tr>
</table>
<p>
</p>
<asp:GridView ID="gvDiscounts" runat="server" AutoGenerateColumns="False" Width="100%">
    <Columns>
        <asp:TemplateField HeaderText="<% $NopResources:Admin.Discounts.Name %>" ItemStyle-Width="20%">
            <ItemTemplate>
                <%#Server.HtmlEncode(Eval("Name").ToString())%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="UsePercentage" HeaderText="<% $NopResources:Admin.Discounts.UsePercentage %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="13%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>
        <asp:BoundField DataField="DiscountPercentage" HeaderText="<% $NopResources:Admin.Discounts.DiscountPercentage %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>
        <asp:BoundField DataField="DiscountAmount" HeaderText="<% $NopResources:Admin.Discounts.DiscountAmount %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>
        <asp:BoundField DataField="StartDate" HeaderText="<% $NopResources:Admin.Discounts.StartDate %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>
        <asp:BoundField DataField="CouponCode" HeaderText="<% $NopResources:Admin.Discounts.Coupon %>"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
        </asp:BoundField>

        <asp:TemplateField HeaderText="<% $NopResources:Admin.Discounts.Edit %>" HeaderStyle-HorizontalAlign="Center"
            ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
            <ItemTemplate>
                <a href="DiscountDetails.aspx?DiscountID=<%#Eval("DiscountId")%>" title="<%#GetLocaleResourceString("Admin.Discounts.Edit.Tooltip")%>">
                    <%#GetLocaleResourceString("Admin.Discounts.Edit")%></a>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<br />
<asp:Label runat="server" ID="lblNoCouponFound" Text="<% $NopResources:Admin.Discounts.Coupon.NoCouponsFound %>"
    Visible="false"></asp:Label>
12 years ago
Discounts.ascx.cs      Note: nop v1.9


using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.ExportImport;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Messages;
using NopSolutions.NopCommerce.BusinessLogic.Promo.Discounts;
using NopSolutions.NopCommerce.BusinessLogic.Utils;
using NopSolutions.NopCommerce.Common;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;

namespace NopSolutions.NopCommerce.Web.Administration.Modules
{
    public partial class DiscountsControl : BaseNopAdministrationUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindGrid();
            }
        }

        //void BindGrid()
        //{
        //    var discounts = this.DiscountService.GetAllDiscounts(null);
        //    gvDiscounts.DataSource = discounts;
        //    gvDiscounts.DataBind();
        //}

        protected void BindGrid()
        {
            var discounts = this.DiscountService.GetAllDiscounts(null);
            if (gvDiscounts.Count > 0)
            {
                this.gvDiscounts.Visible = true;
                this.lblNoCouponFound.Visible = false;
                this.gvDiscounts.DataSource = discounts;
                this.gvDiscounts.DataBind();
            }
            else
            {
                this.gvDiscounts.Visible = false;
                this.lblNoCouponFound.Visible = true;
            }
        }

        protected void gvDiscounts_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.gvDiscounts.PageIndex = e.NewPageIndex;
            BindGrid();
        }

        protected override void OnPreRender(EventArgs e)
        {
            BindJQuery();
            base.OnPreRender(e);
        }

        protected void btnGoDirectlyToCouponNumber_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    int CouponCode = 0;
                    if (int.TryParse(txtCoupon.Text.Trim(), out CouponCode))
                    {
                        string url = string.Format("{0}DiscountDetails.aspx?DiscountID={1}", CommonHelper.GetStoreAdminLocation(), CouponCode);
                        Response.Redirect(url);
                    }
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }


    }
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.