/// <summary> /// 更新一条数据 /// </summary> public bool Update(NovelManager.Model.novel_chapter_content model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update novel_chapter_content set "); strSql.Append("base_id=" + model.base_id + ","); if (model.content != null) { strSql.Append("Content='" + model.content + "',"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where Nid='" + model.nid + "' and Cid=" + model.cid + " "); int rowsAffected = DbHelperMySQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(NovelManager.Model.novel_chapter_content model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); strSql1.Append("base_id,"); strSql2.Append("" + model.base_id + ","); if (model.nid != null) { strSql1.Append("Nid,"); strSql2.Append("'" + model.nid + "',"); } strSql1.Append("Cid,"); strSql2.Append("" + model.cid + ","); if (model.content != null) { strSql1.Append("Content,"); strSql2.Append("'" + model.content + "',"); } strSql.Append("insert into novel_chapter_content("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperMySQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NovelManager.Model.novel_chapter_content GetModel(string nid, int cid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" base_id,Nid,Cid,Content "); strSql.Append(" from novel_chapter_content "); strSql.Append(" where Nid='" + nid + "' and Cid=" + cid + " "); NovelManager.Model.novel_chapter_content model = new NovelManager.Model.novel_chapter_content(); DataSet ds = DbHelperMySQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["base_id"] != null && ds.Tables[0].Rows[0]["base_id"].ToString() != "") { model.base_id = long.Parse(ds.Tables[0].Rows[0]["base_id"].ToString()); } if (ds.Tables[0].Rows[0]["Nid"] != null && ds.Tables[0].Rows[0]["Nid"].ToString() != "") { model.nid = ds.Tables[0].Rows[0]["Nid"].ToString(); } if (ds.Tables[0].Rows[0]["Cid"] != null && ds.Tables[0].Rows[0]["Cid"].ToString() != "") { model.cid = int.Parse(ds.Tables[0].Rows[0]["Cid"].ToString()); } if (ds.Tables[0].Rows[0]["Content"] != null && ds.Tables[0].Rows[0]["Content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["Content"].ToString(); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public NovelManager.Model.novel_chapter_content GetModel(string nid,int cid) { StringBuilder strSql=new StringBuilder(); strSql.Append("select "); strSql.Append(" base_id,Nid,Cid,Content "); strSql.Append(" from novel_chapter_content "); strSql.Append(" where Nid='"+nid+"' and Cid="+cid+" " ); NovelManager.Model.novel_chapter_content model=new NovelManager.Model.novel_chapter_content(); DataSet ds=DbHelperMySQL.Query(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["base_id"]!=null && ds.Tables[0].Rows[0]["base_id"].ToString()!="") { model.base_id=long.Parse(ds.Tables[0].Rows[0]["base_id"].ToString()); } if(ds.Tables[0].Rows[0]["Nid"]!=null && ds.Tables[0].Rows[0]["Nid"].ToString()!="") { model.nid=ds.Tables[0].Rows[0]["Nid"].ToString(); } if(ds.Tables[0].Rows[0]["Cid"]!=null && ds.Tables[0].Rows[0]["Cid"].ToString()!="") { model.cid=int.Parse(ds.Tables[0].Rows[0]["Cid"].ToString()); } if(ds.Tables[0].Rows[0]["Content"]!=null && ds.Tables[0].Rows[0]["Content"].ToString()!="") { model.content=ds.Tables[0].Rows[0]["Content"].ToString(); } return model; } else { return null; } }