Example #1
0
    protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        if ((string.IsNullOrEmpty(Keyword) ||
             Keyword.Length < 2) &&
            ddlBloodGroup.SelectedIndex == 0
            )
        {
            e.Cancel = true;
        }
        else
        {
            string search = "%" + Keyword + "%";

            if (Keyword.ToLower().Trim() == "all")
            {
                search = "%";
            }
            RedBloodDataContext db = new RedBloodDataContext();

            var v = db.Donations.Where(r =>
                                       (ddlBloodGroup.SelectedIndex == 0 || r.BloodGroup == ddlBloodGroup.SelectedValue)
                                       &&
                                       (SqlMethods.Like(r.People.Name, search) || SqlMethods.Like(r.People.NameNoDiacritics, search))
                                       ).Select(r => r.People).Distinct();

            List <People> filter = v.ToList().Where(g =>
                                                    (string.IsNullOrEmpty(SexName) || (g.Sex != null && g.Sex.Name == SexName)) &&
                                                    (string.IsNullOrEmpty(Geo1Name) || g.ResidentGeo1.Name == Geo1Name) &&
                                                    (string.IsNullOrEmpty(DOBYear) || g.DOBInDecade == DOBYear.ToInt())
                                                    ).ToList();
            e.Result = filter;

            LoadFilter(filter);
        }
    }
Example #2
0
    protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        if (string.IsNullOrEmpty(Keyword) || Keyword.Length < 2)
        {
            e.Cancel = true;
            return;
        }

        string search = "%" + Keyword + "%";

        if (Keyword.ToLower().Trim() == "all")
        {
            search = "%";
        }
        RedBloodDataContext db = new RedBloodDataContext();

        var r = (from rs in db.Peoples
                 where SqlMethods.Like(rs.Name, search) || SqlMethods.Like(rs.NameNoDiacritics, search)
                 select rs);

        //LoadFilter(r.ToList());

        List <People> filter = r.ToList().Where(g =>
                                                (string.IsNullOrEmpty(SexName) || (g.Sex != null && g.Sex.Name == SexName)) &&
                                                (string.IsNullOrEmpty(Geo1Name) || g.ResidentGeo1.Name == Geo1Name)
                                                //&& (string.IsNullOrEmpty(DOBYear) || (g.DOB != null && g.DOB.Value.Decade() == DOBYear.ToInt()
                                                //    || (g.DOBYear != null && g.DOBYear.ToString() == DOBYear)))
                                                && (string.IsNullOrEmpty(DOBYear) || g.DOBInDecade == DOBYear.ToInt())
                                                ).ToList();

        e.Result = filter;
        LoadFilter(filter);
    }
Example #3
0
 public void ClickDOBYear() => DOBYear.Click();