public IList <BsCategory> FindBsCategories(int _id = -1) { DBConnect.StartConnection(); IList <BsCategory> list = new List <BsCategory>(); string sql; sql = "select * from BsCategory where ID=" + _id; SqlCommand cmd = new SqlCommand(sql, DBConnect.connection); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt != null) { BsCategory c = null; foreach (DataRow row in dt.Rows) { c = new BsCategory(); c.ID = Int32.Parse(row["id"].ToString()); c.Name = row["name"].ToString(); list.Add(c); } } DBConnect.EndConnection(); return(list); }
public int AddBsCategory(BsCategory bsCategory) { DBConnect.StartConnection(); string sql = String.Format("insert into BsCategory(name) values('{0}')", bsCategory.Name); SqlCommand cmd = new SqlCommand(sql, DBConnect.connection); int num = cmd.ExecuteNonQuery(); DBConnect.EndConnection(); return(num); }
public int EditBsCategory(BsCategory bsCategory) { DBConnect.StartConnection(); string sql = String.Format("update BsCategory set name='{0}' where id={1}", bsCategory.Name, bsCategory.ID); SqlCommand cmd = new SqlCommand(sql, DBConnect.connection); int num = cmd.ExecuteNonQuery(); DBConnect.EndConnection(); return(num); }
public BsBook(string catName, int id, int catID, string name, string image, decimal price, string summary, string author) { _BsCategory = new BsCategory(); _BsCategory.ID = catID; _BsCategory.Name = catName; _ID = id; _CatID = catID; _Name = name; _Image = image; _Price = price; _Summary = summary; _Author = author; }
public BsBook() { _BsCategory = new BsCategory(); }
public int AddBsCategory(BsCategory bsCategory) { return(bsCategoryDAL.AddBsCategory(bsCategory)); }
public int EditBsCategory(BsCategory bsCategory) { return(bsCategoryDAL.EditBsCategory(bsCategory)); }