using System; using System.Data; using System.Text; using System.Data.SqlClient; namespace Mtxfw.DAL { /// /// 数据访问类:user_live_tclog /// public partial class user_live_tclog : Mtxfw.Utility.Myabstract { public user_live_tclog() : base("user_live_tclog") { } /// /// 增加一条数据 /// public int Add(Mtxfw.Model.user_live_tclog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into user_live_tclog("); strSql.Append("MemberId,liveid,ttype,addtime,gtype)"); strSql.Append(" values ("); strSql.Append("@MemberId,@liveid,@ttype,@addtime,@gtype)"); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Int), new SqlParameter("@liveid", SqlDbType.Int), new SqlParameter("@ttype", SqlDbType.Int), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@gtype", SqlDbType.Int)}; parameters[0].Value = model.MemberId; parameters[1].Value = model.liveid; parameters[2].Value = model.ttype; parameters[3].Value = model.addtime; parameters[4].Value = model.gtype; string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString(); if (obj == "") { return 0; } else { return Convert.ToInt32(obj); } } /// /// 删除一条数据 /// public bool Delete(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from user_live_tclog "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM user_live_tclog "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); } /// /// 获得前几行数据 /// 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 user_live_tclog "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by " + filedOrder); return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); } } }