Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataAccessLayer dao   = new DataAccessLayer();
            string          pname = null;
            string          ploc  = null;
            string          ptype = null;
            string          pfeat = null;
            string          pbed  = null;
            string          pbath = null;
            string          psqft = null;
            string          query = "SELECT tblProperties.*, tblUsers.userEmail FROM tblProperties, tblUsers WHERE";

            if (!String.IsNullOrEmpty(Request.QueryString["pname"]))
            {
                // Query string value is there so now use it
                pname = Request.QueryString["pname"];
                if (pname != "null")
                {
                    query += " tblProperties.propertyName LIKE '" + pname + "%' AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ploc"]))
            {
                // Query string value is there so now use it
                ploc = Request.QueryString["ploc"];
                if (ploc != "null")
                {
                    query += " tblProperties.propertyLocation LIKE '" + ploc + "%' AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["ptype"]))
            {
                // Query string value is there so now use it
                ptype = Request.QueryString["ptype"];
                if (ptype != "0")
                {
                    int propType = int.Parse(ptype);
                    query += " tblProperties.propertyType = " + propType + " AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["feat"]))
            {
                // Query string value is there so now use it
                pfeat = Request.QueryString["feat"];
                if (pfeat != "0")
                {
                    int propFeatured = int.Parse(pfeat);
                    query += " tblProperties.propertyFeatured = " + propFeatured + " AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["bed"]))
            {
                // Query string value is there so now use it
                pbed = Request.QueryString["bed"];
                if (pbed != "null")
                {
                    int propBed = int.Parse(pbed);
                    query += " tblProperties.propertyBedroom <= " + propBed + " AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["bath"]))
            {
                // Query string value is there so now use it
                pbath = Request.QueryString["bath"];
                if (pbath != "null")
                {
                    int propBath = int.Parse(pbath);
                    query += " tblProperties.propertyBathroom <= " + propBath + " AND";
                }
            }
            if (!String.IsNullOrEmpty(Request.QueryString["sqft"]))
            {
                // Query string value is there so now use it
                psqft = Request.QueryString["sqft"];
                if (psqft != "null")
                {
                    int propSQFT = int.Parse(psqft);
                    query += " tblProperties.propertySquareFeet <= " + propSQFT + " AND";
                }
            }

            query += " tblProperties.propertyApproved = " + Constants.isApproved + " AND tblProperties.propertyStatus = " + Constants.isApproved + " AND tblProperties.propertyUser = tblUsers.userID";

            SqlDataReader reader = dao.SearchProperties(query);

            if (!reader.HasRows)
            {
                searchStatus.InnerText = "Unfortunately No results found";
            }
            else
            {
                searchStatus.InnerText = "View your Properties Below";
                Repeater2.DataSource   = reader;
                Repeater2.DataBind();
            }
        }