using System; using System.Data; using System.Text; using System.Data.SqlClient; namespace Mtxfw.DAL { /// /// 数据访问类:User_openids /// public partial class User_openids : Mtxfw.Utility.Myabstract { public User_openids() : base("User_openids") { } /// /// 增加一条数据 /// public int Add(Mtxfw.Model.User_openids model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into User_openids("); strSql.Append("MemberId,SJId,openid,addtime,ttype,gtype)"); strSql.Append(" values ("); strSql.Append("@MemberId,@SJId,@openid,@addtime,@ttype,@gtype)"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Int), new SqlParameter("@SJId", SqlDbType.Int), new SqlParameter("@openid", SqlDbType.VarChar,50), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@ttype", SqlDbType.Int), new SqlParameter("@gtype", SqlDbType.Int)}; parameters[0].Value = model.MemberId; parameters[1].Value = model.SJId; parameters[2].Value = model.openid; parameters[3].Value = model.addtime; parameters[4].Value = model.ttype; parameters[5].Value = model.gtype; object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public int Update(int MemberId, int ttype, string openid) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update User_openids Set "); strSql.Append("MemberId=@MemberId"); strSql.Append(" Where ttype=@ttype And openid=@openid"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Int), new SqlParameter("@ttype", SqlDbType.Int,4), new SqlParameter("@openid", SqlDbType.VarChar,50)}; parameters[0].Value = MemberId; parameters[1].Value = ttype; parameters[2].Value = openid; object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public int UpdateSJId(int SJId, int ttype, string openid) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update User_openids Set "); strSql.Append("SJId=@SJId"); strSql.Append(" Where ttype=@ttype And openid=@openid"); SqlParameter[] parameters = { new SqlParameter("@SJId", SqlDbType.Int), new SqlParameter("@ttype", SqlDbType.Int,4), new SqlParameter("@openid", SqlDbType.VarChar,50)}; parameters[0].Value = SJId; parameters[1].Value = ttype; parameters[2].Value = openid; object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 删除一条数据 /// public bool Delete(Int64 Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from User_openids "); int rows = 0; if (Id > 0) { strSql.Append(" where 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; } } } }