protected void Page_Load(object sender, EventArgs e) { // string newsid = Request.Params["newsid"].ToString(); SchSystem.BLL.WebSchChnNewsV bll = new SchSystem.BLL.WebSchChnNewsV();// SchSystem.Model.WebSchChnNewsV model = bll.GetModel(int.Parse(newsid)); if (model != null) { newlv = model.Lv.ToString(); chnname = model.ChnName; SchSystem.BLL.SchGradeInfo bllgrade = new SchSystem.BLL.SchGradeInfo(); gradename = bllgrade.GetName(model.GradeId); SchSystem.BLL.SchClassInfo bllclass = new SchSystem.BLL.SchClassInfo(); classname = bllclass.GetName(model.ClassId); content = model.Content; isqur = model.IsQuo.ToString(); qurl = model.QuoUrl; topic = model.Topic; isrep = model.IsReply.ToString(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.WebSchChnNewsV GetModel(int NewsId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ChnName,ChnId,Topic,RecTime,Stat,SchId,NewsId,Lv,ClassId,GradeId,IsReply,IsQuo,QuoUrl,Content,IsTop from WebSchChnNewsV "); strSql.Append(" where NewsId=@NewsId "); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int, 4) }; parameters[0].Value = NewsId; SchSystem.Model.WebSchChnNewsV model = new SchSystem.Model.WebSchChnNewsV(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.WebSchChnNewsV DataRowToModel(DataRow row) { SchSystem.Model.WebSchChnNewsV model = new SchSystem.Model.WebSchChnNewsV(); if (row != null) { if (row["ChnName"] != null) { model.ChnName = row["ChnName"].ToString(); } if (row["ChnId"] != null && row["ChnId"].ToString() != "") { model.ChnId = int.Parse(row["ChnId"].ToString()); } if (row["Topic"] != null) { model.Topic = row["Topic"].ToString(); } if (row["RecTime"] != null && row["RecTime"].ToString() != "") { model.RecTime = DateTime.Parse(row["RecTime"].ToString()); } if (row["Stat"] != null && row["Stat"].ToString() != "") { model.Stat = int.Parse(row["Stat"].ToString()); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } if (row["NewsId"] != null && row["NewsId"].ToString() != "") { model.NewsId = int.Parse(row["NewsId"].ToString()); } if (row["Lv"] != null && row["Lv"].ToString() != "") { model.Lv = int.Parse(row["Lv"].ToString()); } if (row["ClassId"] != null && row["ClassId"].ToString() != "") { model.ClassId = int.Parse(row["ClassId"].ToString()); } if (row["GradeId"] != null && row["GradeId"].ToString() != "") { model.GradeId = int.Parse(row["GradeId"].ToString()); } if (row["IsReply"] != null && row["IsReply"].ToString() != "") { model.IsReply = int.Parse(row["IsReply"].ToString()); } if (row["IsQuo"] != null && row["IsQuo"].ToString() != "") { model.IsQuo = int.Parse(row["IsQuo"].ToString()); } if (row["QuoUrl"] != null) { model.QuoUrl = row["QuoUrl"].ToString(); } if (row["Content"] != null) { model.Content = row["Content"].ToString(); } if (row["IsTop"] != null && row["IsTop"].ToString() != "") { model.IsTop = int.Parse(row["IsTop"].ToString()); } } return(model); }