Beispiel #1
0
    public string[] getAutocomplete(string prefixText, int count, string contextKey)
    {
        DataSet      ds   = new DataSet();
        showproperty prop = new showproperty();

        prefixText = prefixText.Replace("'", "`"); // all suburbs in the database have back-ticks instead of apostrophes

        ds = prop.getAutocomplete(contextKey, "Any", prefixText);

        int ct1 = ds.Tables[0].Rows.Count;                                          // these are suburbs
        int ct2 = ds.Tables[1].Rows.Count > 5 ? 5 : ds.Tables[1].Rows.Count;        // these are regions
        int ct3 = ds.Tables[2].Rows.Count > 5 ? 5 : ds.Tables[2].Rows.Count;        // these are properties
        //int ct4 = ds.Tables[3].Rows.Count > 5 ? 5 : ds.Tables[3].Rows.Count;      // these are also properties....

        ArrayList arr = new ArrayList();

        if (ct1 > 0)
        {
            arr.Add("Select Suburb" + "##suburb");
        }
        for (int i = 0; i < ct1; i++)
        {
            arr.Add(ds.Tables[0].Rows[i]["nameandpostcode"].ToString().Replace(";", "-") + "##suburb");
        }

        if (ct2 > 0)
        {
            arr.Add("Select Region" + "##region");
        }
        for (int i = 0; i < ct2; i++)
        {
            arr.Add(ds.Tables[1].Rows[i]["region"].ToString().Replace(";", "-") + "##region");
        }

        if (ct3 > 0)
        {
            arr.Add("Select ID" + "##pid");
        }
        for (int i = 0; i < ct3; i++)
        {
            arr.Add(ds.Tables[2].Rows[i]["pid"].ToString().Replace(";", "-") + "##pid");
        }

        //if (ct4 > 0)
        //    arr.Add("Select Address" + "##address");
        //for (int i = 0; i < ct4; i++)
        //{
        //    arr.Add(ds.Tables[3].Rows[i]["address"].ToString().Replace(";", "-") + "##address");
        //}

        string[] suburb = new string[arr.Count];

        for (int i = 0; i < arr.Count; i++)
        {
            suburb[i] = arr[i].ToString();
        }

        return(suburb);
    }
Beispiel #2
0
    public string[] getsuburbsearch(string prefixText, int count, string contextKey)
    {
        DataTable    dtsuburb = new DataTable();
        showproperty prop     = new showproperty();

        string[] filter = contextKey.Split('@');

        string tempstatus = filter[0];
        string re         = filter[1];
        string map        = filter[2];



        if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["re"]))
        {
            dtsuburb = prop.GetSuburbsByStatusAndregion(tempstatus, "Any", "qld", prop.convertListToSQL(re), prefixText);
        }
        else if (HttpContext.Current.Request.QueryString["map"] != null)
        {
            dtsuburb = prop.GetSuburbsByStatusAndMaparea(tempstatus, "Any", "qld", prop.convertListToSQL(map), prefixText);
        }
        else
        {
            dtsuburb = prop.GetSuburbsByStatusAndMaparea(tempstatus, "Any", "qld", "Any", prefixText);
        }

        int count1 = dtsuburb.Rows.Count;

        if (count1 > 5)
        {
            count1 = 5;
        }


        string[] suburb = new string[count1];

        for (int i = 0; i < count1; i++)
        {
            suburb[i] = dtsuburb.Rows[i]["nameandpostcode"].ToString().Replace(", ", " - ");
        }

        return(suburb);
    }
Beispiel #3
0
    public string getAutocompletejson(string prefixText, int count, string contextKey)
    {
        DataSet      ds   = new DataSet();
        showproperty prop = new showproperty();

        ds = prop.getAutocomplete(contextKey, "Any", prefixText);

        int ct1 = ds.Tables[0].Rows.Count > 5 ? 5 : ds.Tables[0].Rows.Count;
        int ct2 = ds.Tables[1].Rows.Count > 5 ? 5 : ds.Tables[1].Rows.Count;
        int ct3 = ds.Tables[2].Rows.Count > 5 ? 5 : ds.Tables[2].Rows.Count;
        int ct4 = ds.Tables[3].Rows.Count > 5 ? 5 : ds.Tables[3].Rows.Count;

        ArrayList arr = new ArrayList();

        if (ct1 > 0)
        {
            arr.Add("Select Suburb");
        }
        for (int i = 0; i < ct1; i++)
        {
            arr.Add(ds.Tables[0].Rows[i]["nameandpostcode"].ToString().Replace(", ", " - "));
        }

        if (ct2 > 0)
        {
            arr.Add("Select Region");
        }
        for (int i = 0; i < ct2; i++)
        {
            arr.Add(ds.Tables[1].Rows[i]["region"].ToString().Replace(", ", " - "));
        }

        if (ct3 > 0)
        {
            arr.Add("Select ID");
        }
        for (int i = 0; i < ct3; i++)
        {
            arr.Add(ds.Tables[2].Rows[i]["pid"].ToString().Replace(", ", " - "));
        }

        if (ct4 > 0)
        {
            arr.Add("Select Address");
        }
        for (int i = 0; i < ct4; i++)
        {
            arr.Add(ds.Tables[3].Rows[i]["address"].ToString().Replace(", ", " - "));
        }

        string strresult = "{\"data\": [";

        for (int i = 0; i < arr.Count; i++)
        {
            strresult += "{ \"suburb\":\"" + arr[i].ToString() + "\"}";
            if (i < arr.Count - 1)
            {
                strresult += ", ";
            }
        }
        strresult += "]}";

        return(strresult);
    }