/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WechatBuilder.Model.wx_cards_gl model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_cards_gl set ");
            strSql.Append("cardsid=@cardsid,");
            strSql.Append("openid=@openid");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cardsid", SqlDbType.Int,       4),
                new SqlParameter("@openid",  SqlDbType.VarChar, 200),
                new SqlParameter("@id",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.cardsid;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WechatBuilder.Model.wx_cards_gl model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_cards_gl(");
            strSql.Append("cardsid,openid)");
            strSql.Append(" values (");
            strSql.Append("@cardsid,@openid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cardsid", SqlDbType.Int,     4),
                new SqlParameter("@openid",  SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.cardsid;
            parameters[1].Value = model.openid;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WechatBuilder.Model.wx_cards_gl DataRowToModel(DataRow row)
 {
     WechatBuilder.Model.wx_cards_gl model = new WechatBuilder.Model.wx_cards_gl();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["cardsid"] != null && row["cardsid"].ToString() != "")
         {
             model.cardsid = int.Parse(row["cardsid"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
     }
     return(model);
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WechatBuilder.Model.wx_cards_gl GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,cardsid,openid from wx_cards_gl ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            WechatBuilder.Model.wx_cards_gl model = new WechatBuilder.Model.wx_cards_gl();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WechatBuilder.Model.wx_cards_gl DataRowToModel(DataRow row)
		{
			WechatBuilder.Model.wx_cards_gl model=new WechatBuilder.Model.wx_cards_gl();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=int.Parse(row["id"].ToString());
				}
				if(row["cardsid"]!=null && row["cardsid"].ToString()!="")
				{
					model.cardsid=int.Parse(row["cardsid"].ToString());
				}
				if(row["openid"]!=null)
				{
					model.openid=row["openid"].ToString();
				}
			}
			return model;
		}
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WechatBuilder.Model.wx_cards_gl GetModel(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,cardsid,openid from wx_cards_gl ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			WechatBuilder.Model.wx_cards_gl model=new WechatBuilder.Model.wx_cards_gl();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}