Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cms.Model.ws_Prize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ws_Prize set ");
            strSql.Append("pid=@pid,");
            strSql.Append("pname=@pname,");
            strSql.Append("prize=@prize,");
            strSql.Append("quantity=@quantity,");
            strSql.Append("probability=@probability,");
            strSql.Append("orderNumber=@orderNumber,");
            strSql.Append("updatetime=@updatetime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@pid",         SqlDbType.Int,         4),
                new SqlParameter("@pname",       SqlDbType.NVarChar,  100),
                new SqlParameter("@prize",       SqlDbType.NVarChar,   50),
                new SqlParameter("@quantity",    SqlDbType.Int,         4),
                new SqlParameter("@probability", SqlDbType.Int,         4),
                new SqlParameter("@orderNumber", SqlDbType.Int,         4),
                new SqlParameter("@updatetime",  SqlDbType.DateTime),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.pid;
            parameters[1].Value = model.pname;
            parameters[2].Value = model.prize;
            parameters[3].Value = model.quantity;
            parameters[4].Value = model.probability;
            parameters[5].Value = model.orderNumber;
            parameters[6].Value = model.updatetime;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Cms.Model.ws_Prize DataRowToModel(DataRow row)
 {
     Cms.Model.ws_Prize model = new Cms.Model.ws_Prize();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["pid"] != null && row["pid"].ToString() != "")
         {
             model.pid = int.Parse(row["pid"].ToString());
         }
         if (row["pname"] != null)
         {
             model.pname = row["pname"].ToString();
         }
         if (row["prize"] != null)
         {
             model.prize = row["prize"].ToString();
         }
         if (row["quantity"] != null && row["quantity"].ToString() != "")
         {
             model.quantity = int.Parse(row["quantity"].ToString());
         }
         if (row["probability"] != null && row["probability"].ToString() != "")
         {
             model.probability = int.Parse(row["probability"].ToString());
         }
         if (row["orderNumber"] != null && row["orderNumber"].ToString() != "")
         {
             model.orderNumber = int.Parse(row["orderNumber"].ToString());
         }
         if (row["updatetime"] != null && row["updatetime"].ToString() != "")
         {
             model.updatetime = DateTime.Parse(row["updatetime"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Cms.Model.ws_Prize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ws_Prize(");
            strSql.Append("pid,pname,prize,quantity,probability,orderNumber,updatetime)");
            strSql.Append(" values (");
            strSql.Append("@pid,@pname,@prize,@quantity,@probability,@orderNumber,@updatetime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@pid",         SqlDbType.Int,        4),
                new SqlParameter("@pname",       SqlDbType.NVarChar, 100),
                new SqlParameter("@prize",       SqlDbType.NVarChar,  50),
                new SqlParameter("@quantity",    SqlDbType.Int,        4),
                new SqlParameter("@probability", SqlDbType.Int,        4),
                new SqlParameter("@orderNumber", SqlDbType.Int,        4),
                new SqlParameter("@updatetime",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.pid;
            parameters[1].Value = model.pname;
            parameters[2].Value = model.prize;
            parameters[3].Value = model.quantity;
            parameters[4].Value = model.probability;
            parameters[5].Value = model.orderNumber;
            parameters[6].Value = model.updatetime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Cms.Model.ws_Prize GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,pid,pname,prize,quantity,probability,orderNumber,updatetime from ws_Prize ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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