Exemple #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();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataAccessLayer dao = new DataAccessLayer();

            txtDescription.Disabled = true;

            List <string> imageFiles = new List <string>();


            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    // Query string value is there so now use it
                    param = Convert.ToInt32(Request.QueryString["id"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["status"]))
                {
                    // Query string value is there so now use it
                    status = Convert.ToInt32(Request.QueryString["status"]);

                    switch (status)
                    {
                    case 1:
                        btnAction.Text = "Unapprove";
                        break;

                    case 2:
                        btnAction.Text = "Approve";
                        break;

                    case 3:
                        btnAction.Text    = "Enlist as Unapproved";
                        btnDelist.Visible = false;
                        break;
                    }
                }

                SqlDataReader reader = dao.SelectPropertyByID(param);

                while (reader.Read())
                {
                    string propertyType;
                    string featured;
                    string approved;
                    string agentID = dao.GetUserEmail(reader.GetInt32(14));
                    hiddenAgent.Text     = agentID;
                    hiddenAgent.Visible  = false;
                    hiddenUserID.Text    = "" + reader.GetInt32(0);
                    hiddenUserID.Visible = false;
                    SqlDataReader reader1 = dao.GetImagesByID(reader.GetInt32(0));

                    while (reader1.Read())
                    {
                        imageFiles.Add((string)reader1.GetString(0));
                    }

                    Repeater1.DataSource = imageFiles;
                    Repeater1.DataBind();


                    if (reader.GetByte(1) == 1)
                    {
                        propertyType = "For Sale";
                    }
                    else
                    {
                        propertyType = "For Rent";
                    }
                    if (reader.GetByte(9) == 1)
                    {
                        featured = "Yes";
                    }
                    else
                    {
                        featured = "No";
                    }

                    if (reader.GetByte(10) == 1)
                    {
                        approved = "Approved";
                    }
                    else
                    {
                        approved = "Not Approved";
                    }
                    //   propertyID = reader.GetInt32(0);
                    //   propertyType = reader.GetByte(1);
                    //   propertyName = reader.GetString(2);
                    //   propertyLocation = reader.GetString(3);
                    //   propertyAddress = reader.GetString(4);
                    //   propertySquareFeet = reader.GetInt32(5);
                    //   propertyBedroom = reader.GetByte(6);
                    //   propertyBathroom = reader.GetByte(7);
                    //   propertyDescription = reader.GetString(8);
                    //   propertyFeatured = reader.GetByte(9);
                    //   propertyApproved = reader.GetByte(10);
                    //   propertyStatus = reader.GetByte(12);
                    //   propertyPrice = reader.Getint32(13);
                    //   propertyUser = reader.GetInt32(14);


                    if (!IsPostBack)
                    {
                        txtPropertyName.Text     = reader.GetString(2);
                        txtPropertyAddress.Text  = reader.GetString(4);
                        txtPropertyLocation.Text = reader.GetString(3);
                        txtAgent.Text            = agentID;
                        txtPropertyType.Text     = propertyType;
                        txtPropertySqft.Text     = Convert.ToString(reader.GetInt32(5));
                        txtBedrooms.Text         = Convert.ToString(reader.GetByte(6));
                        txtBathrooms.Text        = Convert.ToString(reader.GetByte(7));
                        txtFeatured.Text         = featured;
                        txtApproved.Text         = approved;
                        txtDescription.InnerText = reader.GetString(8);
                    }
                }
            }
            catch (System.NullReferenceException r)
            {
                //exception handling
            }
        }