Esempio n. 1
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool Add(CategoryInfo category)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("inser into BigDog_Category (Category_Name,Description,Link_Url)");
     sql.Append("values(@Category_Name,@Description,@Link_Url)");
     SqlParameter[] parms = new SqlParameter[]{
         new SqlParameter("@Category_Name",SqlDbType.NVarChar,50),
         new SqlParameter("@Description",SqlDbType.Int),
         new SqlParameter("@Link_Url",SqlDbType.NVarChar,200)
     };
     parms[0].Value = category.Category_Name;
     parms[1].Value = category.Description;
     parms[2].Value = category.Link_Url;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }
Esempio n. 2
0
 /// <summary>
 /// 根据Id获取实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public CategoryInfo GetById(int id)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select Id,Category_Name,Description,Link_Url from BigDog_Category where Id=@Id");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@Id",SqlDbType.Int)
     };
     parms[0].Value = id;
     CategoryInfo category = new CategoryInfo();
     DataTable dt = SQLHelper.GetDs(sql.ToString()).Tables[0];
     if (dt.Rows.Count > 0)
     {
         category.Id = Convert.ToInt32(dt.Rows[0]["Id"]);
         category.Category_Name = dt.Rows[0]["Category_Name"].ToString();
         category.Link_Url = dt.Rows[0]["Link_Url"].ToString();
         return category;
     }
     return null;
 }
Esempio n. 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool Update(CategoryInfo category)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update BigDog_Shop set Category_Name=@Category_Name,Description=@Description,Link_Url=@Link_Url where Id=@Id");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@Category_Name",SqlDbType.NVarChar,50),
         new SqlParameter("@Description",SqlDbType.NVarChar,100),
         new SqlParameter("@Link_Url",SqlDbType.NVarChar,200),
         new SqlParameter("@Id",SqlDbType.Int)
     };
     parms[0].Value = category.Category_Name;
     parms[1].Value = category.Description;
     parms[2].Value = category.Link_Url;
     parms[3].Value = category.Id;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }
Esempio n. 4
0
 /// <summary>
 /// 获取数据集
 /// </summary>
 /// <returns></returns>
 public DataTable GetList(int father_id)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("select distinct Type_Id from BigDog_Category where Father_Id=@Father_Id");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@Father_Id",SqlDbType.Int)
     };
     parms[0].Value = father_id;
     CategoryInfo category = new CategoryInfo();
     DataTable dt = SQLHelper.GetDs(sql.ToString(),parms).Tables[0];
     if (dt.Rows.Count > 0)
     {
         return dt;
     }
     return null;
 }
Esempio n. 5
0
 public static bool Update(CategoryInfo category)
 {
     return Dal.Update(category);
 }
Esempio n. 6
0
 public static bool Add(CategoryInfo category)
 {
     return Dal.Add(category);
 }