/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.photo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,channel_id,seo_description,content,sort_id,click,digg_good,digg_act,is_msg,is_top,is_red,is_hot,is_slide,is_lock,title,add_time,category_id,photo_no,market_price,sell_price,link_url,img_url,seo_title,seo_keywords from dt_photo "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.photo model = new Model.photo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region ������Ϣ if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); model.content = ds.Tables[0].Rows[0]["content"].ToString(); if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["click"].ToString() != "") { model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString()); } if (ds.Tables[0].Rows[0]["digg_good"] != null && ds.Tables[0].Rows[0]["digg_good"].ToString() != "") { model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString()); } if (ds.Tables[0].Rows[0]["digg_act"] != null && ds.Tables[0].Rows[0]["digg_act"].ToString() != "") { model.digg_act = int.Parse(ds.Tables[0].Rows[0]["digg_act"].ToString()); } if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "") { model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"].ToString() != "") { model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_red"].ToString() != "") { model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString()); } if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "") { model.is_hot = int.Parse(ds.Tables[0].Rows[0]["is_hot"].ToString()); } if (ds.Tables[0].Rows[0]["is_slide"].ToString() != "") { model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.photo_no = ds.Tables[0].Rows[0]["photo_no"].ToString(); if (ds.Tables[0].Rows[0]["market_price"].ToString() != "") { model.market_price = decimal.Parse(ds.Tables[0].Rows[0]["market_price"].ToString()); } if (ds.Tables[0].Rows[0]["sell_price"].ToString() != "") { model.sell_price = decimal.Parse(ds.Tables[0].Rows[0]["sell_price"].ToString()); } model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); #endregion ������Ϣend #region �����Ϣ StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,photo_id,big_img,small_img from dt_photo_album "); strSql2.Append(" where photo_id=@photo_id "); SqlParameter[] parameters2 = { new SqlParameter("@photo_id", SqlDbType.Int,4)}; parameters2[0].Value = id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { #region �ӱ��ֶ���Ϣ int i = ds2.Tables[0].Rows.Count; List<Model.photo_album> models = new List<Model.photo_album>(); Model.photo_album modelt; for (int n = 0; n < i; n++) { modelt = new Model.photo_album(); if (ds2.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString()); } if (ds2.Tables[0].Rows[n]["photo_id"].ToString() != "") { modelt.photo_id = int.Parse(ds2.Tables[0].Rows[n]["photo_id"].ToString()); } modelt.big_img = ds2.Tables[0].Rows[n]["big_img"].ToString(); modelt.small_img = ds2.Tables[0].Rows[n]["small_img"].ToString(); models.Add(modelt); } model.photo_albums = models; #endregion �ӱ��ֶ���Ϣend } #endregion �����Ϣend #region ������Ϣ StringBuilder strSql3 = new StringBuilder(); strSql3.Append("select id,photo_id,attribute_id,title,content from dt_photo_attribute_value "); strSql3.Append(" where photo_id=@photo_id "); SqlParameter[] parameters3 = { new SqlParameter("@photo_id", SqlDbType.Int,4)}; parameters3[0].Value = id; DataSet ds3 = DbHelperSQL.Query(strSql3.ToString(), parameters3); if (ds3.Tables[0].Rows.Count > 0) { #region �ӱ��ֶ���Ϣ int i = ds3.Tables[0].Rows.Count; List<DTcms.Model.photo_attribute_value> models = new List<DTcms.Model.photo_attribute_value>(); DTcms.Model.photo_attribute_value modelt; for (int n = 0; n < i; n++) { modelt = new DTcms.Model.photo_attribute_value(); if (ds3.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds3.Tables[0].Rows[n]["id"].ToString()); } if (ds3.Tables[0].Rows[n]["photo_id"].ToString() != "") { modelt.photo_id = int.Parse(ds3.Tables[0].Rows[n]["photo_id"].ToString()); } if (ds3.Tables[0].Rows[n]["attribute_id"].ToString() != "") { modelt.attribute_id = int.Parse(ds3.Tables[0].Rows[n]["attribute_id"].ToString()); } modelt.title = ds3.Tables[0].Rows[n]["title"].ToString(); modelt.content = ds3.Tables[0].Rows[n]["content"].ToString(); models.Add(modelt); } model.photo_attribute_values = models; #endregion �ӱ��ֶ���Ϣend } #endregion ������Ϣend return model; } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.photo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,channel_id,seo_description,content,sort_id,click,digg_good,digg_act,is_msg,is_top,is_red,is_hot,is_slide,is_lock,title,add_time,category_id,photo_no,market_price,sell_price,link_url,img_url,seo_title,seo_keywords from dt_photo "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.photo model = new Model.photo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region 父表信息 if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); model.content = ds.Tables[0].Rows[0]["content"].ToString(); if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["click"].ToString() != "") { model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString()); } if (ds.Tables[0].Rows[0]["digg_good"] != null && ds.Tables[0].Rows[0]["digg_good"].ToString() != "") { model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString()); } if (ds.Tables[0].Rows[0]["digg_act"] != null && ds.Tables[0].Rows[0]["digg_act"].ToString() != "") { model.digg_act = int.Parse(ds.Tables[0].Rows[0]["digg_act"].ToString()); } if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "") { model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"].ToString() != "") { model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_red"].ToString() != "") { model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString()); } if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "") { model.is_hot = int.Parse(ds.Tables[0].Rows[0]["is_hot"].ToString()); } if (ds.Tables[0].Rows[0]["is_slide"].ToString() != "") { model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.photo_no = ds.Tables[0].Rows[0]["photo_no"].ToString(); if (ds.Tables[0].Rows[0]["market_price"].ToString() != "") { model.market_price = decimal.Parse(ds.Tables[0].Rows[0]["market_price"].ToString()); } if (ds.Tables[0].Rows[0]["sell_price"].ToString() != "") { model.sell_price = decimal.Parse(ds.Tables[0].Rows[0]["sell_price"].ToString()); } model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); #endregion 父表信息end #region 相册信息 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,photo_id,big_img,small_img from dt_photo_album "); strSql2.Append(" where photo_id=@photo_id "); SqlParameter[] parameters2 = { new SqlParameter("@photo_id", SqlDbType.Int, 4) }; parameters2[0].Value = id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { #region 子表字段信息 int i = ds2.Tables[0].Rows.Count; List <Model.photo_album> models = new List <Model.photo_album>(); Model.photo_album modelt; for (int n = 0; n < i; n++) { modelt = new Model.photo_album(); if (ds2.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString()); } if (ds2.Tables[0].Rows[n]["photo_id"].ToString() != "") { modelt.photo_id = int.Parse(ds2.Tables[0].Rows[n]["photo_id"].ToString()); } modelt.big_img = ds2.Tables[0].Rows[n]["big_img"].ToString(); modelt.small_img = ds2.Tables[0].Rows[n]["small_img"].ToString(); models.Add(modelt); } model.photo_albums = models; #endregion 子表字段信息end } #endregion 相册信息end #region 属性信息 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("select id,photo_id,attribute_id,title,content from dt_photo_attribute_value "); strSql3.Append(" where photo_id=@photo_id "); SqlParameter[] parameters3 = { new SqlParameter("@photo_id", SqlDbType.Int, 4) }; parameters3[0].Value = id; DataSet ds3 = DbHelperSQL.Query(strSql3.ToString(), parameters3); if (ds3.Tables[0].Rows.Count > 0) { #region 子表字段信息 int i = ds3.Tables[0].Rows.Count; List <DTcms.Model.photo_attribute_value> models = new List <DTcms.Model.photo_attribute_value>(); DTcms.Model.photo_attribute_value modelt; for (int n = 0; n < i; n++) { modelt = new DTcms.Model.photo_attribute_value(); if (ds3.Tables[0].Rows[n]["id"].ToString() != "") { modelt.id = int.Parse(ds3.Tables[0].Rows[n]["id"].ToString()); } if (ds3.Tables[0].Rows[n]["photo_id"].ToString() != "") { modelt.photo_id = int.Parse(ds3.Tables[0].Rows[n]["photo_id"].ToString()); } if (ds3.Tables[0].Rows[n]["attribute_id"].ToString() != "") { modelt.attribute_id = int.Parse(ds3.Tables[0].Rows[n]["attribute_id"].ToString()); } modelt.title = ds3.Tables[0].Rows[n]["title"].ToString(); modelt.content = ds3.Tables[0].Rows[n]["content"].ToString(); models.Add(modelt); } model.photo_attribute_values = models; #endregion 子表字段信息end } #endregion 属性信息end return(model); } else { return(null); } }