using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class usercontrol_orderbook : System.Web.UI.UserControl
{
  
    protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection conn = DB.connstr();
        conn.Open();
        
        int id = Convert.ToInt32(Request.QueryString["id"]);
        string OleDbcmd = "select * from book_info where book_ID=" + id;
    //    DataSet ds = DB.getdata(OleDbcmd);
       OleDbDataAdapter sda = new OleDbDataAdapter(OleDbcmd, conn);
       DataSet ds = new DataSet();
       sda.Fill(ds);
        this.fvOrder.DataSource = ds.Tables[0].DefaultView;
        this.fvOrder.DataBind();
        conn.Close();
        bbsload();
    }
    protected void bbsload()
    {
     int id = Convert.ToInt32(Request.QueryString["id"]);
     string OleDbbbs = "select * from book_bbs where book_ID=" + id+ " order by bbsTime desc";
     DataSet bbs = DB.getdata(OleDbbbs);
     this.msg.DataSource = bbs;
     this.msg.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);
        if (this.saymsg.Value.Length != 0)
        {
            if (this.saymsg.Value.Length < 255)
            {
                string OleDbcmd = "insert into book_bbs(bbsText,bbsTime,book_ID) values('" + this.saymsg.Value + "','" + DateTime.Now + "',"+id+")";
                OleDbConnection conn = DB.connstr();
                conn.Open();
                OleDbCommand cmd = new OleDbCommand(OleDbcmd, conn);
                cmd.ExecuteNonQuery();
                conn.Close();
                this.saymsg.Value = "";
            }
            
        }
        bbsload();
    
       
    }
}
