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

            strSql.Append("update wx_ggkUsersTemp set ");
            strSql.Append("actId=@actId,");
            strSql.Append("openid=@openid,");
            strSql.Append("times=@times,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@actId",      SqlDbType.Int,         4),
                new SqlParameter("@openid",     SqlDbType.VarChar,   100),
                new SqlParameter("@times",      SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.actId;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.times;
            parameters[3].Value = model.createDate;
            parameters[4].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 WeiXinPF.Model.wx_ggkUsersTemp getModelByAidOpenid(int actId, string openid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,actId,openid,times,createDate from wx_ggkUsersTemp ");
            strSql.Append(" where actId=@actId and openid=@openid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@actId",  SqlDbType.Int,     4),
                new SqlParameter("@openid", SqlDbType.VarChar, 100)
            };
            parameters[0].Value = actId;
            parameters[1].Value = openid;
            WeiXinPF.Model.wx_ggkUsersTemp model = new WeiXinPF.Model.wx_ggkUsersTemp();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_ggkUsersTemp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ggkUsersTemp(");
            strSql.Append("actId,openid,times,createDate)");
            strSql.Append(" values (");
            strSql.Append("@actId,@openid,@times,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@actId",      SqlDbType.Int,       4),
                new SqlParameter("@openid",     SqlDbType.VarChar, 100),
                new SqlParameter("@times",      SqlDbType.Int,       4),
                new SqlParameter("@createDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.actId;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.times;
            parameters[3].Value = model.createDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_ggkUsersTemp DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_ggkUsersTemp model = new WeiXinPF.Model.wx_ggkUsersTemp();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["actId"] != null && row["actId"].ToString() != "")
         {
             model.actId = int.Parse(row["actId"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["times"] != null && row["times"].ToString() != "")
         {
             model.times = int.Parse(row["times"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }