Exemplo n.º 1
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Update(ProductPropInfo model)
        {
            string strSQL = "UPDATE ProductProps SET Name = @Name WHERE Id = @Id";

            SqlParameter[] parms =
            {
                new SqlParameter("Id",   SqlDbType.Int),
                new SqlParameter("Name", SqlDbType.NVarChar),
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.Name.Replace('"', '”');;
            return(SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Insert(ProductPropInfo model)
        {
            string strSQL = "INSERT INTO ProductProps(CategoryId,Name,IsDeleted) VALUES(@CategoryId,@Name,0);SELECT @@IDENTITY;";

            SqlParameter[] parms =
            {
                new SqlParameter("Id",         SqlDbType.Int),
                new SqlParameter("CategoryId", SqlDbType.Int),
                new SqlParameter("Name",       SqlDbType.NVarChar),
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.CategoryId;
            parms[2].Value = model.Name.Replace('"', '”');;
            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms)));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加或编辑
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static ProductPropInfo Create(ProductPropInfo model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         return(model);
     }
     if (model.Id == 0)
     {
         model.Id = ProductPropManage.Insert(model);
     }
     else
     {
         ProductPropManage.Update(model);
     }
     return(model);
 }