Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionService   sectionService = new SectionService();
            HousetypeService hyService      = new HousetypeService();
            AreaService      areaSevice     = new AreaService();

            sectionList = sectionService.GetModelList("");
            hyList      = hyService.GetModelList("");
            areaList    = areaSevice.GetModelList("");

            hid = Int32.Parse(Request["hid"]);

            house = houseService.GetModel(hid);

            hmode = (int)house.hmode;

            sid = house.sid;

            htype = (int)house.htype;

            areaid = (int)house.harea;

            if (IsPostBack)
            {
                this.update();
            }
        }
Beispiel #2
0
        //条件分页查询
        protected void showhouse()
        {
            sectionList = sectionService.GetModelList("");
            hyList      = hyService.GetModelList("");
            areaList    = areaService.GetModelList("");

            //分页参数分开获取post提交的查询条件与get提交分页参数
            if (IsPostBack)
            {
                hname   = Request.Form["hname"];
                sid     = Request.Form["sid"];
                htype   = Request.Form["htype"];
                harea   = Request.Form["harea"];
                hmode   = Request.Form["hmode"];
                hstatus = Request.Form["hstatus"];
                order   = Request.Form["order"];
            }
            else
            {
                hname   = Request.QueryString["hname"];
                sid     = Request.QueryString["sid"];
                htype   = Request.QueryString["htype"];
                harea   = Request.QueryString["harea"];
                hmode   = Request.QueryString["hmode"];
                hstatus = Request.QueryString["hstatus"];
                order   = Request.QueryString["order"];
            }

            int page = 1;

            if (!Int32.TryParse(Request["page"], out page))
            {
                page = 1;
            }
            //传递参数获取房屋列表和分页链接
            ArrayList arraylist = houseService.FindHosueListOnWhereByPage(page, hname, sid, htype, harea, hmode, hstatus, order);

            //从动态数组中取出
            houseList = (List <House>)arraylist[0];
            pageCode  = arraylist[1].ToString();

            //封装房屋板块,房屋类型,房屋地区到房屋model下
            foreach (House house in houseList)
            {
                house.area      = areaService.GetModel((int)house.harea);
                house.housetype = hyService.GetModel((int)house.htype);
                house.section   = sectionService.GetModel(house.sid);
                house.userinfo  = userService.GetModel(house.uid);
            }
        }
        //添加分页查询被举报的信息(若房屋已处理设置为不合法,则不再显示此房屋的相关信息)
        protected void showreporte()
        {
            sectionList = sectionService.GetModelList("");
            hyList      = hyService.GetModelList("");

            int page = 1;

            if (!Int32.TryParse(Request["page"], out page))
            {
                page = 1;
            }
            //查询与分页条件分开获取
            if (IsPostBack)
            {
                hid     = Request.Form["hid"];
                cstatus = Request.Form["cstatus"];
                order   = Request.Form["order"];
            }
            else
            {
                hid     = Request.QueryString["hid"];
                cstatus = Request.QueryString["cstatus"];
                order   = Request.QueryString["order"];
            }
            //调用获取arraylist
            ArrayList list = contractService.FindReportByPageOnWhere(page, hid, cstatus, order);

            //取出信息列表与分页链接
            reportList = (List <Contract>)list[0];
            pageCode   = list[1].ToString();

            //封装信息
            foreach (Contract contract in reportList)
            {
                contract.house = houseService.GetModel(contract.hid);
                contract.user  = userService.GetModel(contract.uid);

                contract.house.housetype = hyService.GetModel((int)contract.house.htype);
                contract.house.section   = sectionService.GetModel(contract.house.sid);
                contract.house.userinfo  = userService.GetModel(contract.house.uid);
            }
        }
Beispiel #4
0
        //房屋信息添加方法
        protected void add()
        {
            if (IsPostBack)
            {
                HttpFileCollection files = HttpContext.Current.Request.Files;  //多文件上传

                string photo1 = "", photo2 = "", photo3 = "", photo4 = "";

                string[] photo = { photo1, photo2, photo3, photo4 };

                //通过for循环判断并存储所有上传的图片
                for (int i = 0; i < files.Count; i++)
                {
                    if (files[i] != null && !files[i].FileName.Equals(""))
                    {                                                                                                            //判断文件是否为空
                        string fileName = files[i].FileName;                                                                     //得到上传图片的文件名字

                        string ext = Path.GetExtension(fileName);                                                                //得到上传图片的文件扩展名

                        if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".jpeg" || ext == ".JPG" || ext == ".bmp") //设定文件的类型
                        {
                            string newFileNames = Guid.NewGuid().ToString() + ext;

                            string fileSavePath = Request.MapPath("/HousePhoto/" + newFileNames);   //保存路径HousePhoto

                            photo[i] = "/HousePhoto/" + newFileNames;

                            files[i].SaveAs(fileSavePath);   //保存图片到服务器指定的目录中去
                        }
                        else
                        {
                            photo[i] = "/Images/House/wu.jpg";  //默认头像
                        }
                    }
                    else
                    {
                        photo[i] = "/Images/House/wu.jpg";
                    }
                }

                HouseService houseService = new HouseService();
                House        house        = new House();

                house.uid          = ((User)Session["userInfo"]).uid;
                house.hname        = Request["hname"];
                house.sid          = Int32.Parse(Request["sid"]);
                house.htype        = Int32.Parse(Request["htype"]);
                house.hsize        = Request["hsize"];
                house.hfloor       = Request["hfloor"];
                house.hmoney       = Request["hmoney"];
                house.hcommunity   = Request["hcommunity"];
                house.harea        = Int32.Parse(Request["harea"]);
                house.hadress      = Request["hadress"];
                house.hdescription = Request["hdescription"];
                house.hphotoone    = photo[0];
                house.hphototwo    = photo[1];
                house.hphotothree  = photo[2];
                house.hphotofour   = photo[3];

                house.htime   = DateTime.Now;
                house.hmode   = Int32.Parse(Request["hmode"]);
                house.hstatus = Int32.Parse(Request["hstatus"]);

                if (houseService.Add(house) > 0)
                {
                    Response.Redirect("/MyHouse.aspx");
                }
                else
                {
                    Response.Write("<script>alter(发布失败!)</script>");
                }
            }
            else
            {
                SectionService   sectionService = new SectionService();
                HousetypeService hyService      = new HousetypeService();
                AreaService      areaSevice     = new AreaService();

                sectionList = sectionService.GetModelList("");
                hyList      = hyService.GetModelList("");
                areaList    = areaSevice.GetModelList("");
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //防止sid非法
            if (!Int32.TryParse(Request["sid"], out sid))
            {
                sid = 1;
            }

            //当前房屋板块名
            sectionname = sectionService.GetModel(sid).sname;

            //地区与房屋类型选择
            areaList = areaService.GetModelList("");
            hyList   = hyService.GetModelList("");

            //防止请求的page非法
            if (!Int32.TryParse(Request["page"], out page))
            {
                page = 1;
            }

            //获取条件进行条件语句拼接和回显(form表单提交的参数查询,get方式提交的方便分页和回显)
            if (IsPostBack)
            {
                areaid = Request.Form["harea"];
                tid    = Request.Form["htype"];
                money  = Request.Form["hmoney"];
            }
            else
            {
                areaid = Request.QueryString["harea"];
                tid    = Request.QueryString["htype"];
                money  = Request.QueryString["hmoney"];
            }

            //将租金900-1200根据"-"分割并存放在数组中,取出即为最小值与最大值
            if (money != null && !"".Equals(money))
            {
                string[] mArray = money.Split('-');
                min = mArray[0];
                max = mArray[1];
            }

            //分页列表条件拼接  strWhere
            if (sid.ToString() != "")
            {
                strWhere.Append("sid= '" + sid + "'");
            }
            if (areaid != null && !"".Equals(areaid))
            {
                strWhere.Append(" and harea= '" + areaid + "'");
            }
            if (tid != null && !"".Equals(tid))
            {
                strWhere.Append(" and htype= '" + tid + "'");
            }
            if (min != null && !"".Equals(min) && max != null && !"".Equals(max))
            {
                strWhere.Append(" and hmoney between '" + min + "' and '" + max + "'");
            }
            if (sid.ToString() != "")
            {
                strWhere.Append(" and hstatus= '" + hstatus + "'");
            }

            //获取信息的排序方式
            flag = Request["flag"];

            //分页链接条件拼接 param  注意空格
            if (sid.ToString() != "")
            {
                param.Append("sid=" + sid);
            }
            if (areaid != null && !"".Equals(areaid))
            {
                param.Append("&harea=" + areaid);
            }
            if (tid != null && !"".Equals(tid))
            {
                param.Append("&htype=" + tid);
            }
            if (min != null && !"".Equals(min) && max != null && !"".Equals(max))
            {
                param.Append("&hmoney=" + min + "-" + max);
            }
            if (sid.ToString() != "")
            {
                param.Append("&hstatus=" + hstatus);
            }
            if (flag != null && !"".Equals(flag))
            {
                param.Append("&flag=" + flag);
            }

            //根据不同条件查询出的信息的最大数,然后判断page与最大页的大小,防止最后一页为空
            recordcount = houseService.GetRecordCount(strWhere.ToString());
            if (recordcount % houseService.pagecount == 0)
            {
                maxpage = recordcount / houseService.pagecount;
            }
            else
            {
                maxpage = recordcount / houseService.pagecount + 1;
            }

            if (page > maxpage)
            {
                page = maxpage;
            }

            //通过页面传递的不同参数执行不同的操作   未审核房屋信息不查询
            if (flag == null || "".Equals(flag))
            {
                //默认发布时间倒序
                houseList = houseService.FindHouseByPageWhere(strWhere.ToString(), "htime desc", page, houseService.pagecount);
            }
            else if (flag == "moneydown")
            {
                //房屋租金从高到低
                houseList = houseService.FindHouseByPageWhere(strWhere.ToString(), "hmoney desc", page, houseService.pagecount);
            }
            else if (flag == "moneyup")
            {
                //房屋租金从低到高
                houseList = houseService.FindHouseByPageWhere(strWhere.ToString(), "hmoney asc", page, houseService.pagecount);
            }

            //分页链接
            pageCode = PageUtil.genPagination("/HouseList.aspx", recordcount, page, houseService.pagecount, param.ToString());

            //封装房屋地区到house,area下
            foreach (House house in houseList)
            {
                house.area = areaService.GetModel((int)house.harea);
            }
        }