Files
g.hnyhua.cn/Mtxfw.DAL/bbs.cs
2026-02-07 15:48:27 +08:00

392 lines
17 KiB
C#

using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
namespace Mtxfw.DAL
{
/// <summary>
/// 数据访问类:bbs
/// </summary>
public partial class bbs : Mtxfw.Utility.Myabstract
{
public bbs()
: base("bbs")
{ }
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Mtxfw.Model.bbs model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into bbs(");
strSql.Append("B_ForumId,B_ForumIds,B_Title,B_TitleColor,B_Body,B_Layer,B_FatherId,B_MemberId,B_IP,B_LastMemberId,B_TPDA_LinkID,B_TP_StarDate,B_TP_EndDate,B_Url,B_Pic,B_TType,B_seef,B_IFReBack,B_IFLogin,B_IFShow,B_IFGG)");
strSql.Append(" values (");
strSql.Append("@B_ForumId,@B_ForumIds,@B_Title,@B_TitleColor,@B_Body,@B_Layer,@B_FatherId,@B_MemberId,@B_IP,@B_LastMemberId,@B_TPDA_LinkID,@B_TP_StarDate,@B_TP_EndDate,@B_Url,@B_Pic,@B_TType,@B_seef,@B_IFReBack,@B_IFLogin,@B_IFShow,@B_IFGG)");
SqlParameter[] parameters = {
new SqlParameter("@B_ForumId", SqlDbType.Int),
new SqlParameter("@B_ForumIds", SqlDbType.VarChar,250),
new SqlParameter("@B_Title", SqlDbType.VarChar,255),
new SqlParameter("@B_TitleColor", SqlDbType.VarChar,50),
new SqlParameter("@B_Body", SqlDbType.NText),
new SqlParameter("@B_Layer", SqlDbType.Int),
new SqlParameter("@B_FatherId", SqlDbType.BigInt),
new SqlParameter("@B_MemberId", SqlDbType.Int),
new SqlParameter("@B_IP", SqlDbType.VarChar,20),
new SqlParameter("@B_LastMemberId", SqlDbType.Int),
new SqlParameter("@B_TPDA_LinkID", SqlDbType.Int),
new SqlParameter("@B_TP_StarDate", SqlDbType.DateTime),
new SqlParameter("@B_TP_EndDate", SqlDbType.DateTime),
new SqlParameter("@B_Url", SqlDbType.VarChar,250),
new SqlParameter("@B_Pic", SqlDbType.VarChar,250),
new SqlParameter("@B_TType", SqlDbType.Int),
new SqlParameter("@B_seef", SqlDbType.Int),
new SqlParameter("@B_IFReBack", SqlDbType.Int),
new SqlParameter("@B_IFLogin", SqlDbType.Int),
new SqlParameter("@B_IFShow", SqlDbType.Int),
new SqlParameter("@B_IFGG", SqlDbType.Int)};
parameters[0].Value = model.B_ForumId;
parameters[1].Value = model.B_ForumIds;
parameters[2].Value = model.B_Title;
parameters[3].Value = model.B_TitleColor;
parameters[4].Value = model.B_Body;
parameters[5].Value = model.B_Layer;
parameters[6].Value = model.B_FatherId;
parameters[7].Value = model.B_MemberId;
parameters[8].Value = model.B_IP;
parameters[9].Value = model.B_LastMemberId;
parameters[10].Value = model.B_TPDA_LinkID;
parameters[11].Value = model.B_TP_StarDate;
parameters[12].Value = model.B_TP_EndDate;
parameters[13].Value = model.B_Url;
parameters[14].Value = model.B_Pic;
parameters[15].Value = model.B_TType;
parameters[16].Value = model.B_seef;
parameters[17].Value = model.B_IFReBack;
parameters[18].Value = model.B_IFLogin;
parameters[19].Value = model.B_IFShow;
parameters[20].Value = model.B_IFGG;
object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Update(Mtxfw.Model.bbs model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update bbs set B_Title=@B_Title,B_TitleColor=@B_TitleColor,B_Body=@B_Body,B_ForumId=@B_ForumId,B_ForumIds=@B_ForumIds,B_Url=@B_Url,B_Pic=@B_Pic,B_UpDate=GetDate(),B_IFReBack=@B_IFReBack,B_IFLogin=@B_IFLogin,B_IFShow=@B_IFShow,B_IFGG=@B_IFGG where B_MemberId=B_MemberId And B_Layer=@B_Layer And B_Id=@B_Id");
SqlParameter[] parameters = {
new SqlParameter("@B_Title", SqlDbType.VarChar,250),
new SqlParameter("@B_TitleColor", SqlDbType.VarChar,50),
new SqlParameter("@B_Body", SqlDbType.NText),
new SqlParameter("@B_ForumId", SqlDbType.Int),
new SqlParameter("@B_ForumIds", SqlDbType.VarChar,250),
new SqlParameter("@B_MemberId", SqlDbType.Int),
new SqlParameter("@B_Layer", SqlDbType.Int),
new SqlParameter("@B_Url", SqlDbType.VarChar,250),
new SqlParameter("@B_Pic", SqlDbType.VarChar,250),
new SqlParameter("@B_IFReBack", SqlDbType.Int),
new SqlParameter("@B_IFLogin", SqlDbType.Int),
new SqlParameter("@B_IFShow", SqlDbType.Int),
new SqlParameter("@B_IFGG", SqlDbType.Int),
new SqlParameter("@B_Id", SqlDbType.BigInt)};
parameters[0].Value = model.B_Title;
parameters[1].Value = model.B_TitleColor;
parameters[2].Value = model.B_Body;
parameters[3].Value = model.B_ForumId;
parameters[4].Value = model.B_ForumIds;
parameters[5].Value = model.B_MemberId;
parameters[6].Value = model.B_Layer;
parameters[7].Value = model.B_Url;
parameters[8].Value = model.B_Pic;
parameters[9].Value = model.B_IFReBack;
parameters[10].Value = model.B_IFLogin;
parameters[11].Value = model.B_IFShow;
parameters[12].Value = model.B_IFGG;
parameters[13].Value = model.B_Id;
object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Update0(int B_LastMemberId, Int64 B_Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update bbs set B_LastMemberId=@B_LastMemberId,B_LastSubmitDate=GetDate(),B_Childs=B_Childs+1 where B_Id=@B_Id");
SqlParameter[] parameters = {
new SqlParameter("@B_LastMemberId", SqlDbType.Int),
new SqlParameter("@B_Id", SqlDbType.BigInt)};
parameters[0].Value = B_LastMemberId;
parameters[1].Value = B_Id;
object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Update(string Sel,int ISelValue,Int64 B_Id)
{
StringBuilder strSql = new StringBuilder();
if (Sel == "B_Childs" || Sel == "B_Hits" || Sel == "B_TPDA_Num")
{
strSql.Append("update bbs set " + Sel + "=" + Sel + "+@ISelValue where B_Id=@B_Id");
}
else
{
strSql.Append("update bbs set " + Sel + "=@ISelValue where B_Id=@B_Id");
}
SqlParameter[] parameters = {
new SqlParameter("@ISelValue", SqlDbType.Int),
new SqlParameter("@B_Id", SqlDbType.BigInt)};
parameters[0].Value = ISelValue;
parameters[1].Value = B_Id;
object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(Int64 Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from bbs ");
int rows = 0;
if (Id > 0)
{
strSql.Append(" where B_Id=@Id");
SqlParameter[] parameters = {
new SqlParameter("@Id", SqlDbType.BigInt)};
parameters[0].Value = Id;
rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
}
else
{
rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString());
}
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Mtxfw.Model.bbs GetModel(Int64 Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 * from bbs ");
strSql.Append(" where B_Id=@Id");
SqlParameter[] parameters = {
new SqlParameter("@Id", SqlDbType.BigInt)
};
parameters[0].Value = Id;
Mtxfw.Model.bbs model = new Mtxfw.Model.bbs();
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["B_Id"].ToString() != "")
{
model.B_Id = int.Parse(ds.Tables[0].Rows[0]["B_Id"].ToString());
}
if (ds.Tables[0].Rows[0]["B_ForumId"].ToString() != "")
{
model.B_ForumId = Convert.ToInt32(ds.Tables[0].Rows[0]["B_ForumId"].ToString());
}
model.B_ForumIds = ds.Tables[0].Rows[0]["B_ForumIds"].ToString();
model.B_Title = ds.Tables[0].Rows[0]["B_Title"].ToString();
model.B_TitleColor = ds.Tables[0].Rows[0]["B_TitleColor"].ToString();
model.B_Body = ds.Tables[0].Rows[0]["B_Body"].ToString();
if (ds.Tables[0].Rows[0]["B_Layer"].ToString() != "")
{
model.B_Layer = Convert.ToInt32(ds.Tables[0].Rows[0]["B_Layer"].ToString());
}
if (ds.Tables[0].Rows[0]["B_FatherId"].ToString() != "")
{
model.B_FatherId = Convert.ToInt32(ds.Tables[0].Rows[0]["B_FatherId"].ToString());
}
if (ds.Tables[0].Rows[0]["B_Childs"].ToString() != "")
{
model.B_Childs = Convert.ToInt32(ds.Tables[0].Rows[0]["B_Childs"].ToString());
}
if (ds.Tables[0].Rows[0]["B_Hits"].ToString() != "")
{
model.B_Hits = Convert.ToInt32(ds.Tables[0].Rows[0]["B_Hits"].ToString());
}
if (ds.Tables[0].Rows[0]["B_MemberId"].ToString() != "")
{
model.B_MemberId = Convert.ToInt32(ds.Tables[0].Rows[0]["B_MemberId"].ToString());
}
model.B_IP = ds.Tables[0].Rows[0]["B_IP"].ToString();
if (ds.Tables[0].Rows[0]["B_SubmitDate"].ToString() != "")
{
model.B_SubmitDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["B_SubmitDate"].ToString());
}
if (ds.Tables[0].Rows[0]["B_UpDate"].ToString() != "")
{
model.B_UpDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["B_UpDate"].ToString());
}
if (ds.Tables[0].Rows[0]["B_LastMemberId"].ToString() != "")
{
model.B_LastMemberId = Convert.ToInt32(ds.Tables[0].Rows[0]["B_LastMemberId"].ToString());
}
if (ds.Tables[0].Rows[0]["B_LastSubmitDate"].ToString() != "")
{
model.B_LastSubmitDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["B_LastSubmitDate"].ToString());
}
if (ds.Tables[0].Rows[0]["B_SetTop"].ToString() != "")
{
model.B_SetTop = Convert.ToInt32(ds.Tables[0].Rows[0]["B_SetTop"].ToString());
}
if (ds.Tables[0].Rows[0]["B_seef"].ToString() != "")
{
model.B_seef = Convert.ToInt32(ds.Tables[0].Rows[0]["B_seef"].ToString());
}
if (ds.Tables[0].Rows[0]["B_Lock"].ToString() != "")
{
model.B_Lock = Convert.ToInt32(ds.Tables[0].Rows[0]["B_Lock"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFHot"].ToString() != "")
{
model.B_IFHot = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFHot"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFTJ"].ToString() != "")
{
model.B_IFTJ = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFTJ"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFSell"].ToString() != "")
{
model.B_IFSell = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFSell"].ToString());
}
if (ds.Tables[0].Rows[0]["B_SellPrice"].ToString() != "")
{
model.B_SellPrice = Convert.ToInt32(ds.Tables[0].Rows[0]["B_SellPrice"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFReBack"].ToString() != "")
{
model.B_IFReBack = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFReBack"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFLogin"].ToString() != "")
{
model.B_IFLogin = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFLogin"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFShow"].ToString() != "")
{
model.B_IFShow = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFShow"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFGG"].ToString() != "")
{
model.B_IFGG = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFGG"].ToString());
}
model.B_Url = ds.Tables[0].Rows[0]["B_Url"].ToString();
model.B_Pic = ds.Tables[0].Rows[0]["B_Pic"].ToString();
if (ds.Tables[0].Rows[0]["B_TPDA_LinkID"].ToString() != "")
{
model.B_TPDA_LinkID = Convert.ToInt32(ds.Tables[0].Rows[0]["B_TPDA_LinkID"].ToString());
}
if (ds.Tables[0].Rows[0]["B_TPDA_Num"].ToString() != "")
{
model.B_TPDA_Num = Convert.ToInt32(ds.Tables[0].Rows[0]["B_TPDA_Num"].ToString());
}
if (ds.Tables[0].Rows[0]["B_TP_StarDate"].ToString() != "")
{
model.B_TP_StarDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["B_TP_StarDate"].ToString());
}
if (ds.Tables[0].Rows[0]["B_TP_EndDate"].ToString() != "")
{
model.B_TP_EndDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["B_TP_EndDate"].ToString());
}
if (ds.Tables[0].Rows[0]["B_TType"].ToString() != "")
{
model.B_TType = Convert.ToInt32(ds.Tables[0].Rows[0]["B_TType"].ToString());
}
if (ds.Tables[0].Rows[0]["B_IFDelete"].ToString() != "")
{
model.B_IFDelete = Convert.ToInt32(ds.Tables[0].Rows[0]["B_IFDelete"].ToString());
}
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM bbs ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
}
/// <summary>
/// 获得前几行数据
/// </summary>
public DataSet GetList(int Top, string strWhere, string filedOrder)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select ");
if (Top > 0)
{
strSql.Append(" top " + Top.ToString());
}
strSql.Append(" * ");
strSql.Append(" FROM bbs ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
}
}
}