Exemple #1
0
        public void ShowArticleInfo(string strID)
        {
            DC_HouseDAL dal   = new DC_HouseDAL();
            DataSet     ds    = dal.GetDCHouseDetail(strID);
            DC_House    model = DataConvert.DataRowToModel <DC_House>(ds.Tables[0].Rows[0]);

            Summary.Text = model.Summary;
            img0.Src     = "../../" + model.Photo;
            ddlCategory.SelectedIndex = ddlCategory.Items.IndexOf(ddlCategory.Items.FindByValue(model.SaleRental.ToString()));
            Price.Text       = model.Price.ToString();
            HouseType.Text   = model.HouseType;
            Faces.Text       = model.Faces;
            Area.Text        = model.Area.ToString();
            Renovation.Text  = model.Renovation;
            Floor.Text       = model.Floor;
            UseType.Text     = model.UseType;
            Buildings.Text   = model.Buildings;
            CreateYear.Text  = model.CreateYear;
            Regions.Text     = model.Regions;
            Address.Text     = model.Address;
            hd_content.Value = model.Content;
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strHouseID  = string.Empty;
                string strSiteCode = string.Empty;
                string siteid      = string.Empty;
                if (null == Request.QueryString["id"])
                {
                    return;
                }
                if (Request["siteid"] != null && Request["siteid"] != "")
                {
                    siteid = Request["siteid"];
                }
                #region 房屋详细
                strHouseID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
                DC_HouseDAL dal   = new DC_HouseDAL();
                DataSet     ds    = dal.GetDCHouseDetail(strHouseID);
                DC_House    model = new DC_House();
                if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    model       = DataConvert.DataRowToModel <DC_House>(ds.Tables[0].Rows[0]);
                    strSiteCode = model.SiteCode;
                }
                #endregion

                #region 相关房屋列表
                List <DC_House> HouseList       = new List <DC_House>();
                DataSet         RelevantHouseDs = dal.GetRelevantHouseList(3, strHouseID);
                if (null != RelevantHouseDs && RelevantHouseDs.Tables.Count > 0 && RelevantHouseDs.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in RelevantHouseDs.Tables[0].Rows)
                    {
                        DC_House RelevantModel = DataConvert.DataRowToModel <DC_House>(row);
                        HouseList.Add(RelevantModel);
                    }
                }
                #endregion

                //读取模板内容
                string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Realty/NewHomeDetail.html"));

                JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();

                context.TempData["sitecode"]      = strSiteCode;
                context.TempData["title"]         = "房产详细信息";
                context.TempData["HouseDetail"]   = model;
                context.TempData["siteid"]        = siteid;
                context.TempData["RelevantHouse"] = HouseList;
                context.TempData["footer"]        = "奥琦微商易";

                JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
                t.Render(Response.Output);
            }
        }
        protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context)
        {
            List <DC_House> HouseList  = new List <DC_House>();
            DC_HouseDAL     dal        = new DC_HouseDAL();
            DataSet         Houseds    = dal.GetDCHouseList(SiteCode, "0");
            string          housecount = Houseds.Tables[0].Rows.Count.ToString();

            foreach (DataRow row in Houseds.Tables[0].Rows)
            {
                DC_House model = DataConvert.DataRowToModel <DC_House>(row);
                HouseList.Add(model);
            }
            context.TempData["HouseCount"] = housecount;
            context.TempData["HouseList"]  = HouseList;
        }
Exemple #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"])
            {
                Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>");
                Response.End();
            }
            //上传图像
            string strIconFileName     = string.Empty; //图像路径
            string strIconSaveFileName = string.Empty; //网址路径

            try
            {
                if (this.file0.PostedFile.FileName == "")
                {
                    strIconSaveFileName = "";
                }
                else
                {
                    if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                    }
                    if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                    {
                        System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                    }
                    string orignalName = this.file0.PostedFile.FileName;                      //获取客户机上传文件的文件名
                    string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                    if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                    {
                        MessageBox.Show(this, "文件格式有误!");
                        return;
                    }//检查文件格式
                    string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名
                    strIconFileName     = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                    strIconSaveFileName = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                    file0.PostedFile.SaveAs(strIconFileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
            }

            DC_HouseDAL dal   = new DC_HouseDAL();
            DC_House    model = new DC_House();

            model.ID       = strID;
            model.SiteCode = Session["strSiteCode"].ToString();
            if (Summary.Text.Trim() != null && Summary.Text.Trim() != "")
            {
                model.Summary = Summary.Text;
            }
            if (strIconSaveFileName != null && strIconSaveFileName != "")
            {
                model.Photo = strIconSaveFileName;
            }
            if (ddlCategory.SelectedValue != null && ddlCategory.SelectedValue != "")
            {
                model.SaleRental = Convert.ToInt32(ddlCategory.SelectedValue);
            }
            if (Price.Text.Trim() != null && Price.Text.Trim() != "")
            {
                model.Price = Convert.ToDecimal(Price.Text);
            }
            if (HouseType.Text.Trim() != null && HouseType.Text.Trim() != "")
            {
                model.HouseType = HouseType.Text;
            }
            if (Faces.Text.Trim() != null && Faces.Text.Trim() != "")
            {
                model.Faces = Faces.Text;
            }
            if (Area.Text.Trim() != null && Area.Text.Trim() != "")
            {
                model.Area = Convert.ToDecimal(Area.Text);
            }
            if (Renovation.Text.Trim() != null && Renovation.Text.Trim() != "")
            {
                model.Renovation = Renovation.Text;
            }
            if (Floor.Text.Trim() != null && Floor.Text.Trim() != "")
            {
                model.Floor = Floor.Text;
            }
            if (UseType.Text.Trim() != null && UseType.Text.Trim() != "")
            {
                model.UseType = UseType.Text;
            }
            if (Buildings.Text.Trim() != null && Buildings.Text.Trim() != "")
            {
                model.Buildings = Buildings.Text;
            }
            if (CreateYear.Text.Trim() != null && CreateYear.Text.Trim() != "")
            {
                model.CreateYear = CreateYear.Text;
            }
            if (Regions.Text.Trim() != null && Regions.Text.Trim() != "")
            {
                model.Regions = Regions.Text;
            }
            if (Address.Text.Trim() != null && Address.Text.Trim() != "")
            {
                model.Address = Address.Text;
            }
            if (hd_content.Value.Trim() != null && hd_content.Value.Trim() != "")
            {
                model.Content = hd_content.Value;
            }
            if (dal.UpdateDCHouse(model))
            {
                MessageBox.Show(this, "操作成功!");
            }
            else
            {
                MessageBox.Show(this, "操作失败!");
            }
        }
Exemple #5
0
        /// <summary>
        /// 更新房产信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateDCHouse(DC_House model)
        {
            string safesql = "";

            safesql = "update DC_House set ";
            if (model.SiteCode != null && model.SiteCode != "")
            {
                safesql += "[SiteCode]='" + model.SiteCode + "',";
            }
            if (model.Photo != null && model.Photo != "")
            {
                safesql += "[Photo]='" + model.Photo + "',";
            }
            if (model.Summary != null && model.Summary != "")
            {
                safesql += "[Summary]='" + model.Summary + "',";
            }
            if (model.SaleRental > 0 && model.SaleRental.ToString() != "")
            {
                safesql += "[SaleRental]=" + model.SaleRental + ",";
            }
            if (model.Price > 0 && model.Price.ToString() != "")
            {
                safesql += "[Price]='" + model.Price + "',";
            }
            if (model.HouseType != null && model.HouseType != "")
            {
                safesql += "[HouseType]='" + model.HouseType + "',";
            }
            if (model.Faces != null && model.Faces != "")
            {
                safesql += "[Faces]='" + model.Faces + "',";
            }
            if (model.Area > 0 && model.Area.ToString() != "")
            {
                safesql += "[Area]='" + model.Area + "',";
            }
            if (model.Renovation != null && model.Renovation != "")
            {
                safesql += "[Renovation]='" + model.Renovation + "',";
            }
            if (model.Floor != null && model.Floor != "")
            {
                safesql += "[Floor]='" + model.Floor + "',";
            }
            if (model.UseType != null && model.UseType != "")
            {
                safesql += "[UseType]='" + model.UseType + "',";
            }
            if (model.Buildings != null && model.Buildings != "")
            {
                safesql += "[Buildings]='" + model.Buildings + "',";
            }
            if (model.CreateYear != null && model.CreateYear != "")
            {
                safesql += "[CreateYear]='" + model.CreateYear + "',";
            }
            if (model.Regions != null && model.Regions != "")
            {
                safesql += "[Regions]='" + model.Regions + "',";
            }
            if (model.Address != null && model.Address != "")
            {
                safesql += "[Address]='" + model.Address + "',";
            }
            if (model.Content != null && model.Content != "")
            {
                safesql += "[Content]='" + model.Content + "',";
            }
            safesql += "[IsDel]=" + model.IsDel + ",";
            safesql += "[CreateTime]='" + DateTime.Now + "'";
            safesql += " where id='" + model.ID + "'";
            int rowsAffected = DbHelperSQL.ExecuteSql(safesql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        /// <summary>
        /// 添加房产信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddDCHouse(DC_House model)
        {
            string sql = @"INSERT INTO [DC_House]
                        ([ID]
                       ,[SiteCode]
                       ,[Photo]
                       ,[Summary]
                       ,[SaleRental]
                       ,[Price]
                       ,[HouseType]
                       ,[Faces]
                       ,[Area]
                       ,[Renovation]
                       ,[Floor]
                       ,[UseType]
                       ,[Buildings]
                       ,[CreateYear]
                       ,[Regions]
                       ,[Address]
                       ,[Content]
                       ,[IsDel]
                       ,[CreateTime])
                 VALUES
                        (@ID
                       ,@SiteCode
                       ,@Photo
                       ,@Summary
                       ,@SaleRental
                       ,@Price
                       ,@HouseType
                       ,@Faces
                       ,@Area
                       ,@Renovation
                       ,@Floor
                       ,@UseType
                       ,@Buildings
                       ,@CreateYear
                       ,@Regions
                       ,@Address
                       ,@Content
                       ,@IsDel
                       ,@CreateTime)";

            System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[]
            {
                new System.Data.SqlClient.SqlParameter("@ID", model.ID),
                new System.Data.SqlClient.SqlParameter("@SiteCode", model.SiteCode),
                new System.Data.SqlClient.SqlParameter("@Photo", model.Photo),
                new System.Data.SqlClient.SqlParameter("@Summary", model.Summary),
                new System.Data.SqlClient.SqlParameter("@SaleRental", model.SaleRental),
                new System.Data.SqlClient.SqlParameter("@Price", model.Price),
                new System.Data.SqlClient.SqlParameter("@HouseType", model.HouseType),
                new System.Data.SqlClient.SqlParameter("@Faces", model.Faces),
                new System.Data.SqlClient.SqlParameter("@Area", model.Area),
                new System.Data.SqlClient.SqlParameter("@Renovation", model.Renovation),
                new System.Data.SqlClient.SqlParameter("@Floor", model.Floor),
                new System.Data.SqlClient.SqlParameter("@UseType", model.UseType),
                new System.Data.SqlClient.SqlParameter("@Buildings", model.Buildings),
                new System.Data.SqlClient.SqlParameter("@CreateYear", model.CreateYear),
                new System.Data.SqlClient.SqlParameter("@Regions", model.Regions),
                new System.Data.SqlClient.SqlParameter("@Address", model.Address),
                new System.Data.SqlClient.SqlParameter("@Content", model.Content),
                new System.Data.SqlClient.SqlParameter("@IsDel", model.IsDel),
                new System.Data.SqlClient.SqlParameter("@CreateTime", DateTime.Now)
            };
            return(DbHelperSQL.ExecuteSql(sql, paras));
        }