Example #1
0
    //根据一条Catid选出一条数据
    public Ep229Category SelectById(int CatId)
    {
        Ep229Category category = null;
        string        sql      = String.Format("select * from ep229_category where cat_id={0}", CatId);
        SqlDataReader sdr      = SqlHelper.ExecuteReader(sql);

        if (sdr.Read())
        {
            category = new Ep229Category
            {
                CatId   = sdr.GetInt32(0),
                CatName = sdr.GetString(1)
            };
        }
        sdr.Close();
        return(category);
    }
Example #2
0
    //选出数据库的全部数据
    public IList <Ep229Category> SelectAll()
    {
        IList <Ep229Category> list = new List <Ep229Category>();
        string    sql = String.Format("select * from Ep229_category");
        DataTable dt  = SqlHelper.ExecuteQuery(sql);

        if (dt != null)
        {
            Ep229Category c = null;
            foreach (DataRow row in dt.Rows)
            {
                c = new Ep229Category
                {
                    CatId   = Int32.Parse(row["cat_id"].ToString()),
                    CatName = row["cat_name"].ToString()
                };
                list.Add(c);
            }
        }
        return(list);
    }
Example #3
0
 //编辑一个类别
 public int EditCategory(Ep229Category category)
 {
     return(CategoryDAL.Update(category));
 }
Example #4
0
 //删除一个类别(先删选该类下的全部产品再删除该类)
 public int DeleteCategory(Ep229Category category)
 {
     ProductDAL.DeleteByCid(category.CatId);
     return(CategoryDAL.Delete(category.CatId));
 }
Example #5
0
 //增加一个类别
 public int AddCategory(Ep229Category category)
 {
     return(CategoryDAL.Insert(category));
 }
Example #6
0
    //更新一条数据
    public int Update(Ep229Category category)
    {
        string sql = String.Format("update ep229_category set cat_name='{0}'where cat_id={1}", category.CatName, category.CatId);

        return(SqlHelper.ExecuteNonQuery(sql));
    }
Example #7
0
    //插入数据
    public int Insert(Ep229Category category)
    {
        string sql = String.Format("insert into ep229_category(cat_name)values('{0}')", category.CatName);

        return(SqlHelper.ExecuteNonQuery(sql));
    }