示例#1
0
        protected void loadHTML()
        {
            DataAccessLayer dao = new DataAccessLayer();

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

                    switch (param)
                    {
                    case 1:
                        query = "select * from tblProperties where propertyStatus=" + Constants.propertyEnabled + " and propertyApproved=" + Constants.isApproved;
                        break;

                    case 2:
                        query = "select * from tblProperties where propertyStatus=" + Constants.propertyEnabled + " and propertyApproved=" + Constants.isNotApproved;
                        break;

                    case 3:
                        query = "select * from tblProperties where propertyStatus=" + Constants.propertyDisabled;
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    query = "select * from tblProperties where propertyStatus=" + Constants.propertyEnabled;
                }

                SqlDataReader reader = dao.GetProperties(query);

                Response.Write("<ol class='breadcrumb mb-4' style='margin-top:20px;'>");
                Response.Write("<li class='breadcrumb-item active'>Properties</li>");
                Response.Write("</ol>");
                Response.Write("<div class='container-fluid'>");
                Response.Write("<div class='table-responsive'>");
                Response.Write("<table class='table'>");
                Response.Write("<thead class='thead-dark'>");
                Response.Write("<tr>");
                Response.Write("<th scope='col'>Thumbnail</th>");
                Response.Write("<th scope='col'>Name</th>");
                Response.Write("<th scope='col'>User ID</th>");
                Response.Write("<th scope='col'>Type</th>");
                Response.Write("<th scope='col'>Location</th>");
                Response.Write("<th scope='col'>View</th>");
                Response.Write("</tr>");
                Response.Write("</thead>");
                Response.Write("<tbody>");

                while (reader.Read())
                {
                    string propertyType;
                    string imageName = dao.GetImageName(reader.GetInt32(0));
                    string userEmail = dao.GetUserEmail(reader.GetInt32(14));

                    if (reader.GetByte(1) == 1)
                    {
                        propertyType = "For Sale";
                    }
                    else
                    {
                        propertyType = "For Rent";
                    }
                    //   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);

                    Response.Write("<tr>");
                    Response.Write("<td><img src='userassets/" + userEmail + @"/propertyImages/" + @reader.GetInt32(0) + "/" + imageName + "' alt='recent-properties-1' class=' img-thumbnail' style='width:180px;'></td>"); //thumbnail
                    Response.Write("<td>" + reader.GetString(2) + "</td>");                                                                                                                                                  //user
                    Response.Write("<td>" + userEmail + "</td>");                                                                                                                                                            //user
                    Response.Write("<td>" + propertyType + "</td>");                                                                                                                                                         //type
                    Response.Write("<td>" + reader.GetString(3) + "</td>");                                                                                                                                                  //Location
                    Response.Write("<td><a class='btn btn-primary' href='ViewProperty.aspx?id=" + reader.GetInt32(0) + "&status=" + param + "' role='button'>View</a></td>");
                    Response.Write("</tr>");
                }

                Response.Write("</tbody>");
                Response.Write("</table>");
                Response.Write("</div>");
                Response.Write("</div>");
            }
            catch (System.NullReferenceException r)
            {
                //exception handling
            }
        }