Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_ucard_usercard model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_ucard_usercard set ");
            strSql.Append("uid=@uid,");
            strSql.Append("sid=@sid,");
            strSql.Append("addDate=@addDate");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@uid",     SqlDbType.Int,       4),
                new SqlParameter("@sid",     SqlDbType.Int,       4),
                new SqlParameter("@addDate", SqlDbType.DateTime),
                new SqlParameter("@id",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.uid;
            parameters[1].Value = model.sid;
            parameters[2].Value = model.addDate;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WeiXinPF.Model.wx_ucard_usercard model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_usercard(");
            strSql.Append("id,uid,sid,addDate)");
            strSql.Append(" values (");
            strSql.Append("@id,@uid,@sid,@addDate)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",      SqlDbType.Int, 4),
                new SqlParameter("@uid",     SqlDbType.Int, 4),
                new SqlParameter("@sid",     SqlDbType.Int, 4),
                new SqlParameter("@addDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.uid;
            parameters[2].Value = model.sid;
            parameters[3].Value = model.addDate;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_ucard_usercard DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_ucard_usercard model = new WeiXinPF.Model.wx_ucard_usercard();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["uid"] != null && row["uid"].ToString() != "")
         {
             model.uid = int.Parse(row["uid"].ToString());
         }
         if (row["sid"] != null && row["sid"].ToString() != "")
         {
             model.sid = int.Parse(row["sid"].ToString());
         }
         if (row["addDate"] != null && row["addDate"].ToString() != "")
         {
             model.addDate = DateTime.Parse(row["addDate"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_ucard_usercard GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }