public int DeleteNewsTab(int Newsid) { string sql = "delete NewsTab where Newsid=@Newsid "; int result = DBHelpe.ExecuteSql(sql, new SqlParameter("Newsid", Newsid)); return(result); }
/// <summary> /// 查询总条数 /// </summary> /// <param name="name"></param> /// <param name="statu"></param> /// <returns></returns> public int pageIndex(string name, int statu, int loantype, string loanstitles) { int num = 0; string sdt = "and 1=1"; if (loanstitles != "") { sdt += " and NTitle like '" + loanstitles + "%'"; } if (loantype != -1) { sdt += " and TypeID=" + loantype + ""; } string sql = "select Count(Newsid) from NewsTab where audit=@statu " + sdt + " and UserName=@name"; SqlParameter[] para = { new SqlParameter("@name", SqlDbType.VarChar, 50), new SqlParameter("@statu", SqlDbType.Int, 4) }; para[0].Value = name; para[1].Value = statu; num = Convert.ToInt32(DBHelpe.GetSingle(sql, para)); return(num); }
public int UpdateNewsTabaudit(int newsid) { string sql = "Update NewsTab set Audit=5 where Newsid=@Newsid ";//ɾ³ýÓà ¸Ä±äÉóºË״̬ SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Newsid", newsid) }; int result = DBHelpe.ExecuteSql(sql, ps); return(result); }
public int UpdateNewsTabUrl(string url, int newsid) { string sql = "Update NewsTab set urlhtml=@urlhtml where Newsid=@Newsid "; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@urlhtml", url) , new SqlParameter("@Newsid", newsid) }; int result = DBHelpe.ExecuteSql(sql, ps); return(result); }
public string GetMaxNewsId() { string sql = "select Max(Newsid)as Newsid from NewsTab"; DataSet set = DBHelpe.Query(sql); string par = ""; foreach (DataRow row in set.Tables[0].Rows) { par = row["Newsid"].ToString().Trim(); } return(par); }
//通过ID获取一个实体对象 public ErrowTab GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,LinkURL,QuestionDescript,Connetions,BoolChuLi,BoolReturn,ReturnContext,Descript,LoginName,createtime,updatetime from ErrowTab "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; ErrowTab model = new ErrowTab(); DataSet ds = DBHelpe.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.LinkURL = ds.Tables[0].Rows[0]["LinkURL"].ToString(); model.QuestionDescript = ds.Tables[0].Rows[0]["QuestionDescript"].ToString(); model.Connetions = ds.Tables[0].Rows[0]["Connetions"].ToString(); if (ds.Tables[0].Rows[0]["BoolChuLi"].ToString() != "") { model.BoolChuLi = int.Parse(ds.Tables[0].Rows[0]["BoolChuLi"].ToString()); } if (ds.Tables[0].Rows[0]["BoolReturn"].ToString() != "") { model.BoolReturn = int.Parse(ds.Tables[0].Rows[0]["BoolReturn"].ToString()); } model.ReturnContext = ds.Tables[0].Rows[0]["ReturnContext"].ToString(); model.Descript = ds.Tables[0].Rows[0]["Descript"].ToString(); model.LoginName = ds.Tables[0].Rows[0]["LoginName"].ToString(); if (ds.Tables[0].Rows[0]["createtime"].ToString() != "") { model.createtime = ds.Tables[0].Rows[0]["createtime"].ToString(); } if (ds.Tables[0].Rows[0]["updatetime"].ToString() != "") { model.updatetime = ds.Tables[0].Rows[0]["updatetime"].ToString(); } return(model); } else { return(null); } }
public Tz888.Model.NewsTypeTab GetNewsTypeByTypeId(int typeId) { string sql = "select TypeID ,TypeName from NewsTypeTab where TypeID=@typeid"; DataSet set = DBHelpe.Query(sql, new SqlParameter("typeid", typeId)); Tz888.Model.NewsTypeTab newstypetab = null; foreach (DataRow row in set.Tables[0].Rows) { newstypetab = new Tz888.Model.NewsTypeTab(); newstypetab.TypeID = Convert.ToInt32(row["TypeID"]); newstypetab.TypeName = row["TypeName"].ToString().Trim(); } return(newstypetab); }
public int UpdateNewsTab(Tz888.Model.NewsTab newstab, int newsid) { string sql = "Update NewsTab set NTitle=@ntitle ,TypeID=@typeid,recommendID=@recommendID,urlhtml=@urlhtml where Newsid=@Newsid "; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@ntitle", newstab.NTitle) , new SqlParameter("@typeid", newstab.TypeID) , new SqlParameter("@recommendID", newstab.RecommendID) , new SqlParameter("@urlhtml", newstab.Urlhtml) , new SqlParameter("@Newsid", newsid) }; int result = DBHelpe.ExecuteSql(sql, ps); return(result); }
public List <Tz888.Model.NewsTypeTab> GetAllNewsType() { string sql = "select TypeID ,TypeName from NewsTypeTab where BoolStar=1 and outid=1"; List <Tz888.Model.NewsTypeTab> list = new List <NewsTypeTab>(); DataSet set = null; set = DBHelpe.Query(sql); foreach (DataRow row in set.Tables[0].Rows) { Tz888.Model.NewsTypeTab newstypetab = new Tz888.Model.NewsTypeTab(); newstypetab.TypeID = Convert.ToInt32(row["TypeID"]); newstypetab.TypeName = row["TypeName"].ToString().Trim(); list.Add(newstypetab); } return(list); }
public int UpdateNewsViewTab(Tz888.Model.NewsViewTab newsviewtab, int newsid) { string sql = "Update NewsViewTab set Title=@title ,Keywords=@keywords,Description=@descript,NewView=@newview,form=@form,Author=@author,Zhaiyao=@zhaiyao where Newsid=@Newsid "; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@title", newsviewtab.Title) , new SqlParameter("@keywords", newsviewtab.Keywords) , new SqlParameter("@descript", newsviewtab.Description) , new SqlParameter("@newview", newsviewtab.NewView) , new SqlParameter("@form", newsviewtab.Formid) , new SqlParameter("@author", newsviewtab.Author) , new SqlParameter("@zhaiyao", newsviewtab.Zhaiyao) , new SqlParameter("@Newsid", newsid) }; int result = DBHelpe.ExecuteSql(sql, ps); return(result); }
/// <summary> /// 增加错误处理的一条数据 /// </summary> public int Add(ErrowTab model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ErrowTab("); strSql.Append("LoginName,LinkURL,QuestionDescript,Connetions,BoolChuLi,BoolReturn,ReturnContext,Descript,createtime,updatetime)"); strSql.Append(" values ("); strSql.Append("@LoginName,@LinkURL,@QuestionDescript,@Connetions,@BoolChuLi,@BoolReturn,@ReturnContext,@Descript,@createtime,@updatetime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.NVarChar, 300), new SqlParameter("@LinkURL", SqlDbType.NVarChar, 300), new SqlParameter("@QuestionDescript", SqlDbType.Text), new SqlParameter("@Connetions", SqlDbType.NVarChar, 300), new SqlParameter("@BoolChuLi", SqlDbType.Int, 4), new SqlParameter("@BoolReturn", SqlDbType.Int, 4), new SqlParameter("@ReturnContext", SqlDbType.Text), new SqlParameter("@Descript", SqlDbType.NVarChar, 500), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@updatetime", SqlDbType.DateTime) }; parameters[0].Value = model.LoginName; parameters[1].Value = model.LinkURL; parameters[2].Value = model.QuestionDescript; parameters[3].Value = model.Connetions; parameters[4].Value = model.BoolChuLi; parameters[5].Value = model.BoolReturn; parameters[6].Value = model.ReturnContext; parameters[7].Value = model.Descript; parameters[8].Value = model.createtime; parameters[9].Value = model.updatetime; object obj = DBHelpe.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
//修改数据 public int Update(ErrowTab model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ErrowTab set "); strSql.Append("LinkURL=@LinkURL,"); strSql.Append("QuestionDescript=@QuestionDescript,"); strSql.Append("Connetions=@Connetions,"); strSql.Append("BoolChuLi=@BoolChuLi,"); strSql.Append("BoolReturn=@BoolReturn,"); strSql.Append("ReturnContext=@ReturnContext,"); strSql.Append("Descript=@Descript,"); strSql.Append("LoginName=@LoginName,"); strSql.Append("createtime=@createtime,"); strSql.Append("updatetime=@updatetime"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@LinkURL", SqlDbType.NVarChar, 300), new SqlParameter("@QuestionDescript", SqlDbType.Text), new SqlParameter("@Connetions", SqlDbType.NVarChar, 300), new SqlParameter("@BoolChuLi", SqlDbType.Int, 4), new SqlParameter("@BoolReturn", SqlDbType.Int, 4), new SqlParameter("@ReturnContext", SqlDbType.Text), new SqlParameter("@Descript", SqlDbType.NVarChar, 500), new SqlParameter("@LoginName", SqlDbType.NVarChar, 300), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@updatetime", SqlDbType.DateTime) }; parameters[0].Value = model.Id; parameters[1].Value = model.LinkURL; parameters[2].Value = model.QuestionDescript; parameters[3].Value = model.Connetions; parameters[4].Value = model.BoolChuLi; parameters[5].Value = model.BoolReturn; parameters[6].Value = model.ReturnContext; parameters[7].Value = model.Descript; parameters[8].Value = model.LoginName; parameters[9].Value = model.createtime; parameters[10].Value = model.updatetime; return(DBHelpe.ExecuteCommand(strSql.ToString(), parameters)); }
public int InsertNewsTab(Tz888.Model.NewsTab newstab, Tz888.Model.NewsTypeTab newstypetab, Tz888.Model.NewsViewTab newsviewtab) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@TypeID", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.VarChar, 200), new SqlParameter("@NTitle", SqlDbType.VarChar, 200), new SqlParameter("@audit", SqlDbType.Int, 4), new SqlParameter("@FromID", SqlDbType.Int, 4), new SqlParameter("@urlhtml", SqlDbType.VarChar, 200), new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@title", SqlDbType.VarChar, 200), new SqlParameter("@keywords", SqlDbType.VarChar, 200), new SqlParameter("@description", SqlDbType.VarChar, 200), new SqlParameter("@NewView", SqlDbType.Text, 10000), new SqlParameter("@form", SqlDbType.VarChar, 2000), new SqlParameter("@author", SqlDbType.VarChar, 200), new SqlParameter("@zhaiyao", SqlDbType.VarChar, 200), new SqlParameter("@recommendID", SqlDbType.Int, 4), new SqlParameter("@ImagesUrls", SqlDbType.NVarChar, 400) }; parameters[0].Value = newstab.TypeID; parameters[1].Value = newstab.UserName; parameters[2].Value = newstab.NTitle; parameters[3].Value = newstab.Audit; parameters[4].Value = newstab.FromID; parameters[5].Value = newstab.Urlhtml; parameters[6].Value = newstab.Createdate; parameters[7].Value = newsviewtab.Title; parameters[8].Value = newsviewtab.Keywords; parameters[9].Value = newsviewtab.Description; parameters[10].Value = newsviewtab.NewView; parameters[11].Value = newsviewtab.Formid; parameters[12].Value = newsviewtab.Author; parameters[13].Value = newsviewtab.Zhaiyao; parameters[14].Value = newstab.RecommendID; parameters[15].Value = "NULL"; DBHelpe.RunProcedure("NewsTab_InsertList", parameters, out rowsAffected); return(rowsAffected); }
//获取实体对象集合 public List <ErrowTab> GetModelList() { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,LinkURL,QuestionDescript,Connetions,BoolChuLi,BoolReturn,ReturnContext,Descript,LoginName,createtime,updatetime from ErrowTab "); List <ErrowTab> list = new List <ErrowTab>(); DataSet ds = DBHelpe.Query(strSql.ToString()); foreach (DataRow row in ds.Tables[0].Rows) { ErrowTab model = new ErrowTab(); if (row["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.LinkURL = ds.Tables[0].Rows[0]["LinkURL"].ToString(); model.QuestionDescript = ds.Tables[0].Rows[0]["QuestionDescript"].ToString(); model.Connetions = ds.Tables[0].Rows[0]["Connetions"].ToString(); if (ds.Tables[0].Rows[0]["BoolChuLi"].ToString() != "") { model.BoolChuLi = int.Parse(ds.Tables[0].Rows[0]["BoolChuLi"].ToString()); } if (ds.Tables[0].Rows[0]["BoolReturn"].ToString() != "") { model.BoolReturn = int.Parse(ds.Tables[0].Rows[0]["BoolReturn"].ToString()); } model.ReturnContext = ds.Tables[0].Rows[0]["ReturnContext"].ToString(); model.Descript = ds.Tables[0].Rows[0]["Descript"].ToString(); model.LoginName = ds.Tables[0].Rows[0]["LoginName"].ToString(); if (ds.Tables[0].Rows[0]["createtime"].ToString() != "") { model.createtime = ds.Tables[0].Rows[0]["createtime"].ToString(); } if (ds.Tables[0].Rows[0]["updatetime"].ToString() != "") { model.updatetime = ds.Tables[0].Rows[0]["updatetime"].ToString(); } list.Add(model); } return(list); }
public Tz888.Model.NewsViewTab GetNewsViewByNewId(int NewId) { string sql = "select * from NewsViewTab where Newsid=@newid"; Tz888.Model.NewsViewTab newsviewtab = null; DataSet set = DBHelpe.Query(sql, new SqlParameter("newid", NewId)); foreach (DataRow row in set.Tables[0].Rows) { newsviewtab = new Tz888.Model.NewsViewTab(); newsviewtab.NViewID = Convert.ToInt32(row["NViewID"]); newsviewtab.Newsid = newstab.GetNewsTabByNewId(Convert.ToInt32(row["Newsid"])); newsviewtab.Title = row["Title"].ToString().Trim(); newsviewtab.Keywords = row["Keywords"].ToString().Trim(); newsviewtab.Description = row["Description"].ToString().Trim(); newsviewtab.NewView = row["NewView"].ToString().Trim(); newsviewtab.Formid = row["form"].ToString().Trim(); newsviewtab.Author = row["Author"].ToString().Trim(); newsviewtab.Zhaiyao = row["Zhaiyao"].ToString().Trim(); } return(newsviewtab); }
public Tz888.Model.NewsTab GetNewsTabByNewId(int NewId) { string sql = "select * from NewsTab where Newsid=@newid"; Tz888.Model.NewsTab newstab = null; DataSet set = DBHelpe.Query(sql, new SqlParameter("newid", NewId)); foreach (DataRow row in set.Tables[0].Rows) { newstab = new Tz888.Model.NewsTab(); newstab.Newsid = Convert.ToInt32(row["Newsid"]); newstab.NTitle = row["NTitle"].ToString().Trim(); newstab.UserName = row["UserName"].ToString().Trim(); newstab.TypeID = Convert.ToInt32(row["TypeID"]); newstab.Audit = Convert.ToInt32(row["Audit"]); newstab.FromID = Convert.ToInt32(row["FromID"]); newstab.Urlhtml = row["urlhtml"].ToString().Trim(); newstab.Createdate = row["Createdate"].ToString().Trim(); newstab.RecommendID = Convert.ToInt32(row["RecommendID"]); } return(newstab); }
public string GetStringPerson(string name, int status, int index, int loantype, string loanstitles) { string loansinfoIds = ""; string loansTitles = ""; string loanscreatetimes = ""; string loanstypes = ""; string LoginNames = ""; string auditings = ""; string htmls = ""; string updatetimes = ""; StringBuilder sb = new StringBuilder(); string sdt = " and 1=1"; if (loanstitles != "") { sdt += " and NTitle like '" + loanstitles + "%'"; } if (loantype != -1) { sdt += " and TypeID=" + loantype + ""; } string sql = "select top 20 Newsid,UserName,NTitle,TypeID,audit,urlhtml,createdate,recommendID from NewsTab where " + " audit=@statu and UserName=@name " + sdt + " and Newsid not in (select top " + 20 * index + " Newsid from NewsTab where audit=@statu " + sdt + " and UserName=@name" + " order by createdate desc) order by createdate desc"; SqlParameter[] para = { new SqlParameter("@name", SqlDbType.VarChar, 50), new SqlParameter("@statu", SqlDbType.Int, 4) }; para[0].Value = name; para[1].Value = status; DataSet ds = DBHelpe.Query(sql, para); sb.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><thead><tr>"); sb.Append("<td width=\"12%\"><a href=\"javascript:SelectAll();\">全选</a>│<a href=\"javascript:ReSelect();\">反选</a></td>"); sb.Append("<td width=\"8%\">类别</td>"); sb.Append("<td width=\"20%\">标题</td>"); sb.Append("<td width=\"12%\">发布时间</td>"); sb.Append("<td width=\"12%\">是否推荐</td>"); sb.Append("<td width=\"33%\">管理</td></tr></thead>"); if (ds != null & ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < (ds.Tables[0].Rows.Count > 20 ? 20 : ds.Tables[0].Rows.Count); i++) { DataRow row = ds.Tables[0].Rows[i]; loansinfoIds = row["Newsid"].ToString().Trim(); //编号 loansTitles = row["NTitle"].ToString().Trim(); //标题 loanscreatetimes = row["createdate"].ToString().Trim(); // 发布时间 loanstypes = row["TypeID"].ToString().Trim(); // 类别 LoginNames = row["UserName"].ToString().Trim(); // 用户名 auditings = row["audit"].ToString().Trim(); //审核状态 htmls = row["urlhtml"].ToString().Trim(); // html updatetimes = row["recommendID"].ToString().Trim(); // 是否推荐 DateTime beg = Convert.ToDateTime(loanscreatetimes); string begTime = beg.ToString("yyyy-MM-dd"); sb.Append("<tr><td><input id=\"cbxSelect\" name=\"cbxSelect\" type=\"checkbox\" value=\"" + loansinfoIds + "\" /></td>"); sb.Append("<td>" + SetDaikuanType(loanstypes) + "</td>"); sb.Append("<td><span class=\"lanl\"><a href='http://www.topfo.com/" + htmls + "' target=\"_blank\" class=\"lan1\" title='" + loansTitles + "'>" + StrLength(loansTitles) + "</a></span></td>"); sb.Append("<td>" + begTime + "</td>"); sb.Append("<td>" + Tuijian(updatetimes) + "</td>"); sb.Append("<td>"); sb.Append("<a href='javascript:updateloans(" + 0 + "," + loansinfoIds + ");' class=\"lan1\">修改</a> "); sb.Append("<a href='javascript:DelNav(" + loansinfoIds + ");' onclick='javascript:Del()' class=\"lan1\">删除</a></td></tr>"); } } sb.Append("</table>"); return(sb.ToString()); }