Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BCW.SSE.Model.SseGetPrize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_SseGetPrize(");
            strSql.Append("orderId,userId,isGet,getDateTime,openDateTime)");
            strSql.Append(" values (");
            strSql.Append("@orderId,@userId,@isGet,@getDateTime,@openDateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderId",      SqlDbType.Int,       4),
                new SqlParameter("@userId",       SqlDbType.Int,       4),
                new SqlParameter("@isGet",        SqlDbType.Bit,       1),
                new SqlParameter("@getDateTime",  SqlDbType.DateTime),
                new SqlParameter("@openDateTime", SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.orderId;
            parameters[1].Value = model.userId;
            parameters[2].Value = model.isGet;
            parameters[3].Value = model.getDateTime;
            parameters[4].Value = model.openDateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BCW.SSE.Model.SseGetPrize DataRowToModel(DataRow row)
 {
     BCW.SSE.Model.SseGetPrize model = new BCW.SSE.Model.SseGetPrize();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["orderId"] != null && row["orderId"].ToString() != "")
         {
             model.orderId = int.Parse(row["orderId"].ToString());
         }
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].ToString());
         }
         if (row["isGet"] != null && row["isGet"].ToString() != "")
         {
             if ((row["isGet"].ToString() == "1") || (row["isGet"].ToString().ToLower() == "true"))
             {
                 model.isGet = true;
             }
             else
             {
                 model.isGet = false;
             }
         }
         if (row["getDateTime"] != null && row["getDateTime"].ToString() != "")
         {
             model.getDateTime = DateTime.Parse(row["getDateTime"].ToString());
         }
         if (row["openDateTime"] != null)
         {
             model.openDateTime = DateTime.Parse(row["openDateTime"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BCW.SSE.Model.SseGetPrize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_SseGetPrize set ");
            strSql.Append("orderId=@orderId,");
            strSql.Append("userId=@userId,");
            strSql.Append("isGet=@isGet,");
            strSql.Append("getDateTime=@getDateTime,");
            strSql.Append("openDateTime=@openDateTime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderId",      SqlDbType.Int,        4),
                new SqlParameter("@userId",       SqlDbType.Int,        4),
                new SqlParameter("@isGet",        SqlDbType.Bit,        1),
                new SqlParameter("@getDateTime",  SqlDbType.DateTime),
                new SqlParameter("@openDateTime", SqlDbType.NChar,     10),
                new SqlParameter("@id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.orderId;
            parameters[1].Value = model.userId;
            parameters[2].Value = model.isGet;
            parameters[3].Value = model.getDateTime;
            parameters[4].Value = model.openDateTime;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BCW.SSE.Model.SseGetPrize GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,orderId,userId,isGet,getDateTime,openDateTime from tb_SseGetPrize ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            BCW.SSE.Model.SseGetPrize model = new BCW.SSE.Model.SseGetPrize();
            DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);

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