Пример #1
0
    public IList <BsBook> FindBsBooks()
    {
        IList <BsBook> list = new List <BsBook>();
        string         sort = "";

        string    sql = String.Format("select * from BsBook");
        DataTable dt  = SqlHelper.ExecuteQuery(sql);

        if (dt != null)
        {
            BsBook bsBook = null;
            foreach (DataRow row in dt.Rows)
            {
                bsBook = new BsBook();
                //bsBook.BsCategory.Name = row["CatName"].ToString();
                bsBook.ID      = Int32.Parse(row["id"].ToString());
                bsBook.CatID   = Int32.Parse(row["catID"].ToString());
                bsBook.Name    = row["name"].ToString();
                bsBook.Image   = row["image"].ToString();
                bsBook.Price   = decimal.Parse(row["price"].ToString());
                bsBook.Summary = row["summary"].ToString();
                bsBook.Author  = row["author"].ToString();
                list.Add(bsBook);
            }
        }
        return(list);
    }
Пример #2
0
    public IList <BsBook> FindBsBooks(int catID, string name, string author, string sortExpression, int startRowIndex, int maximumRows)
    {
        IList <BsBook> list = new List <BsBook>();
        string         sort = "";

        if (!String.IsNullOrEmpty(sortExpression))
        {
            sort = string.Format("order by b.{0}", sortExpression);
        }
        string    sql = String.Format("select a.name as CatName,b.* from BsCategory a,BsBook b where a.id=b.catID and {0} b.Name like '%{1}%' and b.author like '%{2}%' {3}", (catID == 0 ? "" : "b.catID=" + catID + " and"), name, author, sort);
        DataTable dt  = SqlHelper.ExecuteQuery(sql, startRowIndex, maximumRows);

        if (dt != null)
        {
            BsBook bsBook = null;
            foreach (DataRow row in dt.Rows)
            {
                bsBook = new BsBook();
                bsBook.BsCategory.Name = row["CatName"].ToString();
                bsBook.ID      = Int32.Parse(row["id"].ToString());
                bsBook.CatID   = Int32.Parse(row["catID"].ToString());
                bsBook.Name    = row["name"].ToString();
                bsBook.Image   = row["image"].ToString();
                bsBook.Price   = decimal.Parse(row["price"].ToString());
                bsBook.Summary = row["summary"].ToString();
                bsBook.Author  = row["author"].ToString();
                list.Add(bsBook);
            }
        }
        return(list);
    }
Пример #3
0
    public BsBook FindBsBook(int id)
    {
        BsBook        bsBook = null;
        string        sql    = String.Format("select a.name as CatName,b.* from BsCategory a, BsBook b where a.id=b.catID and b.id={0}", id);
        SqlDataReader sdr    = SqlHelper.ExecuteReader(sql);

        if (sdr.Read())
        {
            bsBook = new BsBook(sdr.GetString(0), sdr.GetInt32(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4), sdr.GetDecimal(5), sdr.GetString(6), sdr.GetString(7));
        }
        sdr.Close();
        return(bsBook);
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int id = Int32.Parse(Request.QueryString["id"]);

        BsBook bsBook = bsBookBLL.FindBsBook(id);

        CartItem item = new CartItem();

        item.ID       = id;
        item.Name     = bsBook.Name;
        item.Price    = bsBook.Price;
        item.Quantity = 1;
        Profile.BsCartBLL.AddItem(item);
        Profile.Save();
        Response.Redirect("~/Web/User/CartBrowse.aspx");
    }
Пример #5
0
 public int AddBsBook(BsBook bsBook)
 {
     return(bsBookDAL.AddBsBook(bsBook));
 }
Пример #6
0
 public int EditBsBook(BsBook bsBook)
 {
     return(bsBookDAL.EditBsBook(bsBook));
 }
Пример #7
0
    public int AddBsBook(BsBook bsBook)
    {
        string sql = String.Format("insert into BsBook(catID,name,image,price,summary,author) values ({0},'{1}','{2}',{3},'{4}','{5}')", bsBook.CatID, bsBook.Name, bsBook.Image, bsBook.Price, bsBook.Summary, bsBook.Author);

        return(SqlHelper.ExecuteNonQuery(sql));
    }
Пример #8
0
    public int EditBsBook(BsBook bsBook)
    {
        string sql = String.Format("update BsBook set catID={0},name='{1}',price={2},summary='{3}',author='{4}' where id={5}", bsBook.CatID, bsBook.Name, bsBook.Price, bsBook.Summary, bsBook.Author, bsBook.ID);

        return(SqlHelper.ExecuteNonQuery(sql));
    }