Example #1
0
    /// <summary>
    /// Search Promotion
    /// </summary>
    private void SearchPromotions()
    {
        DataView dv = new DataView();

        if (ViewState["PromotionsList"]!=null)
        {
            dv = new DataView(ViewState["PromotionsList"] as DataTable);
        }
        else
        {
            ZNode.Libraries.Admin.PromotionAdmin couponbind = new ZNode.Libraries.Admin.PromotionAdmin();
            DataSet ds = couponbind.GetAllPromotions().ToDataSet(false);
            string filterQuery = "";

            dv = new DataView(ds.Tables[0]);
            dv.Sort = "displayorder asc";

            # region Create row filter query
            if (ddlDiscountTypes.SelectedValue != "0")
            {
                filterQuery = "DiscountTypeId = " +ddlDiscountTypes.SelectedValue + " and  ";
            }
            if (txtStartDate.Text.Trim().Length > 0 && txtEndDate.Text.Trim().Length == 0)
            {
                filterQuery = "StartDate >= '" + txtStartDate.Text.Trim() + "' and  ";
            }
            else if (txtEndDate.Text.Trim().Length > 0 && txtStartDate.Text.Trim().Length == 0)
            {
                filterQuery = "EndDate <='" + txtEndDate.Text.Trim() + "' and ";
            }
            else if(txtStartDate.Text.Trim().Length > 0 && txtEndDate.Text.Trim().Length > 0)
            {
                filterQuery = "StartDate >= '" + txtStartDate.Text.Trim() + "' and  EndDate <='" + txtEndDate.Text.Trim() + "' and ";
            }

            if (txtName.Text.Trim().Length > 0)
                filterQuery += "Name like '%" + txtName.Text.Trim() + "%' and ";

            if (txtAmount.Text.Trim().Length > 0)
                filterQuery += "Discount >= " + txtAmount.Text.Trim() + " and ";

            if (CouponCode.Text.Trim().Length > 0)
                filterQuery += "CouponCode like '%" + CouponCode.Text.Trim() + "%' and ";

            #endregion

            //if filter query has conditition, if any
            if (filterQuery.Length > 0)
            {
                //Apply filter
                dv.RowFilter = filterQuery + "description like '%'";
            }

            ViewState.Add("PromotionsList", dv.ToTable());
        }

        uxGrid.DataSource = dv;
        uxGrid.DataBind();
    }
Example #2
0
    // Bind data to grid
    private void BindGridData()
    {
        ZNode.Libraries.Admin.PromotionAdmin couponbind = new ZNode.Libraries.Admin.PromotionAdmin();
        DataSet ds = couponbind.GetAllPromotions().ToDataSet(false);
        DataView dv = new DataView(ds.Tables[0]);
        dv.Sort = "displayorder asc";

        uxGrid.DataSource = dv;
        uxGrid.DataBind();
    }