示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(EShop.Model.Account_Coupon model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Account_Coupon set ");
            strSql.Append("UserCode=@UserCode,");
            strSql.Append("CouponCode=@CouponCode");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",   SqlDbType.VarChar, 50),
                new SqlParameter("@CouponCode", SqlDbType.VarChar, 50),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserCode;
            parameters[1].Value = model.CouponCode;
            parameters[2].Value = model.Id;

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

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

            strSql.Append("insert into Account_Coupon(");
            strSql.Append("UserCode,CouponCode)");
            strSql.Append(" values (");
            strSql.Append("@UserCode,@CouponCode)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserCode",   SqlDbType.VarChar, 50),
                new SqlParameter("@CouponCode", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.UserCode;
            parameters[1].Value = model.CouponCode;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public EShop.Model.Account_Coupon DataRowToModel(DataRow row)
 {
     EShop.Model.Account_Coupon model = new EShop.Model.Account_Coupon();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["UserCode"] != null)
         {
             model.UserCode = row["UserCode"].ToString();
         }
         if (row["CouponCode"] != null)
         {
             model.CouponCode = row["CouponCode"].ToString();
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EShop.Model.Account_Coupon GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,UserCode,CouponCode from Account_Coupon ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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