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

            strSql.Append("update ProductProperty set ");
            strSql.Append("productId=@productId,");
            strSql.Append("properType=@properType,");
            strSql.Append("properTypeName=@properTypeName,");
            strSql.Append("properValue=@properValue,");
            strSql.Append("status=@status,");
            strSql.Append("remark=@remark,");
            strSql.Append("infoType=@infoType");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productId",      SqlDbType.Int,       4),
                new SqlParameter("@properType",     SqlDbType.Int,       4),
                new SqlParameter("@properTypeName", SqlDbType.VarChar, 150),
                new SqlParameter("@properValue",    SqlDbType.VarChar, 250),
                new SqlParameter("@status",         SqlDbType.Int,       4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 150),
                new SqlParameter("@infoType",       SqlDbType.Int,       4),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.properType;
            parameters[2].Value = model.properTypeName;
            parameters[3].Value = model.properValue;
            parameters[4].Value = model.status;
            parameters[5].Value = model.remark;
            parameters[6].Value = model.infoType;
            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 Model.ProductProperty DataRowToModel(DataRow row)
 {
     Model.ProductProperty model = new Model.ProductProperty();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["productId"] != null && row["productId"].ToString() != "")
         {
             model.productId = int.Parse(row["productId"].ToString());
         }
         if (row["properType"] != null && row["properType"].ToString() != "")
         {
             model.properType = int.Parse(row["properType"].ToString());
         }
         if (row["properTypeName"] != null)
         {
             model.properTypeName = row["properTypeName"].ToString();
         }
         if (row["properValue"] != null)
         {
             model.properValue = row["properValue"].ToString();
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["infoType"] != null && row["infoType"].ToString() != "")
         {
             model.infoType = int.Parse(row["infoType"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.ProductProperty model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductProperty(");
            strSql.Append("productId,properType,properTypeName,properValue,status,remark,infoType)");
            strSql.Append(" values (");
            strSql.Append("@productId,@properType,@properTypeName,@properValue,@status,@remark,@infoType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productId",      SqlDbType.Int,       4),
                new SqlParameter("@properType",     SqlDbType.Int,       4),
                new SqlParameter("@properTypeName", SqlDbType.VarChar, 150),
                new SqlParameter("@properValue",    SqlDbType.VarChar, 250),
                new SqlParameter("@status",         SqlDbType.Int,       4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 150),
                new SqlParameter("@infoType",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.properType;
            parameters[2].Value = model.properTypeName;
            parameters[3].Value = model.properValue;
            parameters[4].Value = model.status;
            parameters[5].Value = model.remark;
            parameters[6].Value = model.infoType;

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

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

            strSql.Append("select  top 1 id,productId,properType,properTypeName,properValue,status,remark,infoType from ProductProperty ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.ProductProperty model = new Model.ProductProperty();
            DataSet ds = DBHelperSQL.Query(strSql.ToString(), parameters);

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