using System; using System.Data; using System.Text; using System.Data.SqlClient; namespace Mtxfw.DAL { /// /// 数据访问类:user_Results /// public partial class duihuanma : Mtxfw.Utility.Myabstract { public duihuanma() : base("duihuanma") { } /// /// 增加一条数据 /// public Int64 Add(Mtxfw.Model.duihuanma model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into duihuanma("); strSql.Append("MemberId,dhm,yxq,addtime,seef,gtype)"); strSql.Append(" values ("); strSql.Append("@MemberId,@dhm,@yxq,@addtime,@seef,@gtype)"); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Int), new SqlParameter("@dhm", SqlDbType.VarChar,50), new SqlParameter("@yxq", SqlDbType.Int), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@Seef", SqlDbType.Int), new SqlParameter("@gtype", SqlDbType.Int)}; parameters[0].Value = model.MemberId; parameters[1].Value = model.dhm; parameters[2].Value = model.yxq; parameters[3].Value = model.addtime; parameters[4].Value = model.seef; parameters[5].Value = model.gtype; string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString(); if (obj == "") { return 0; } else { return Convert.ToInt64(obj); } } /// /// 审核或者假删除 /// public int UpdateSeef(string Sel, int SelValue, Int64 Id) { String sql = "update duihuanma set " + Sel + "=@SelValue where Id=@Id"; SqlParameter[] para = { new SqlParameter("@SelValue", SqlDbType.Int), new SqlParameter("@Id", SqlDbType.BigInt) }; para[0].Value = SelValue; para[1].Value = Id; return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sql, para); } /// /// 删除一条数据 /// public bool Delete(Int64 Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from duihuanma"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt) }; parameters[0].Value = Id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public Mtxfw.Model.duihuanma GetModel(Int64 Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from duihuanma"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt) }; parameters[0].Value = Id; Mtxfw.Model.duihuanma model = new Mtxfw.Model.duihuanma(); DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(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()); } if (ds.Tables[0].Rows[0]["MemberId"].ToString() != "") { model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString()); } model.dhm = ds.Tables[0].Rows[0]["dhm"].ToString(); model.yxq = int.Parse(ds.Tables[0].Rows[0]["yxq"].ToString()); if (ds.Tables[0].Rows[0]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString()); } model.seef = int.Parse(ds.Tables[0].Rows[0]["seef"].ToString()); model.gtype = int.Parse(ds.Tables[0].Rows[0]["gtype"].ToString()); return model; } else { return null; } } /// /// 得到一个对象实体 /// public Mtxfw.Model.duihuanma GetModel(Int32 MemberId,string dhm) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from duihuanma"); strSql.Append(" where MemberId=@MemberId and dhm=@dhm"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Int), new SqlParameter("@dhm", SqlDbType.VarChar,50) }; parameters[0].Value = MemberId; parameters[1].Value = dhm; Mtxfw.Model.duihuanma model = new Mtxfw.Model.duihuanma(); DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(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()); } if (ds.Tables[0].Rows[0]["MemberId"].ToString() != "") { model.MemberId = int.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString()); } model.dhm = ds.Tables[0].Rows[0]["dhm"].ToString(); model.yxq = int.Parse(ds.Tables[0].Rows[0]["yxq"].ToString()); if (ds.Tables[0].Rows[0]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString()); } model.seef = int.Parse(ds.Tables[0].Rows[0]["seef"].ToString()); model.gtype = int.Parse(ds.Tables[0].Rows[0]["gtype"].ToString()); return model; } else { return null; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM duihuanma "); 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 duihuanma "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by " + filedOrder); return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); } } }