public partial class productinfo : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.Bind();
                pro.updatepointnum(int.Parse(this.Request.QueryString["pid"].ToString()));
                this.BindTwo();
                dgBookList.Attributes.Add("style", "word-break:break-all;word-wrap:word");
                if (user.IsLogin() == true)
                {
                    this.peAddReply.Visible = true;
                }
            }
        }        ClothesShop.BLL.product pro = new ClothesShop.BLL.product();
        ClothesShop.BLL.type_1 t_1 = new ClothesShop.BLL.type_1();
        ClothesShop.BLL.type_2 t_2 = new ClothesShop.BLL.type_2();        ClothesShop.BLL.message msg = new ClothesShop.BLL.message();
        ClothesShop.BLL.userinfo user = new ClothesShop.BLL.userinfo();
        private void BindTwo()
        {
            DataTable table = msg.GetMessageList();
            this.dgBookList.DataSource = table.DefaultView;
            this.dgBookList.DataBind();
        }        protected void ibSumbit_Click(object sender, ImageClickEventArgs e)
        {
            if (Page.IsValid)
            {
                if (msg.createmessage(user.getUserName(), this.tbContent.Text, false) == 1)
                {
                    this.Bind();
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('恭喜!留言成功!')</script>", false);
                    tbContent.Text = "";
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('遗憾!留言失败!')</script>", false);
                }
            }
        }        protected void dgBookList_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Panel panel = (Panel)e.Item.Cells[0].FindControl("peReply");
                DataRowView drv = (DataRowView)e.Item.DataItem;
                if (drv["Relay_Time"].ToString() == "" || drv["Relay_Content"].ToString() == "")
                {
                    panel.Visible = false;
                }
            }
        }        private void Bind()
        {
            int pid = int.Parse(this.Request.QueryString["pid"].ToString());
            DataRow row = pro.getoneproduct(pid);
            this.productnameliteral.Text = row["productname"].ToString();
            this.ltProductorders.Text = row["productorders"].ToString();
            this.IMG1.Src = "pic/" + row["imagepath"].ToString();
            this.IMG1.Alt = "pic/" + row["imagepath"].ToString();
            this.type_1nameliteral.Text = t_1.gettypename(int.Parse(row["typeid_1"].ToString()));
            this.type_2nameliteral.Text = t_2.gettypename(int.Parse(row["typeid_2"].ToString()));
            this.pointcountliteral.Text = row["pointcount"].ToString();
            this.countliteral.Text = (int.Parse(row["count"].ToString()) > int.Parse(row["sellcount"].ToString())) ? row["count"].ToString() : "<font color='red'>缺货</font>";
            this.sellcountliteral.Text = row["sellcount"].ToString();
            this.priceliteral.Text = row["price"].ToString();
            this.userpriceliteral.Text = row["userprice"].ToString();
            this.specialsliteral.Text = row["specialsprice"].ToString();
            this.descriptionliteral.Text = row["description"].ToString();            string[] mykey = row["pcolor"].ToString().Split(new char[] { ',' });
            for (int i = 0; i < mykey.Length-1; i++)
            {
                //this.drpColor.DataSource = row["pcolor"].ToString();
                //this.drpColor.DataBind();
                //this.drpColor.Items.Insert(0, new ListItem(mykey[i].ToString(), "0"));
                this.drpColor.Items.Add(mykey[i].ToString());
            }            string[] mykeys = row["psize"].ToString().Split(new char[] { ',' });
            for (int i = 0; i < mykeys.Length-1; i++)
            {
                //this.drpSize.DataSource = row["psize"].ToString();
                //this.drpSize.DataBind();
                //this.drpSize.Items.Insert(0, new ListItem(mykeys[i].ToString(), "0"));
                this.drpSize.Items.Add(mykeys[i].ToString());
            }            //this.drpColor.Items.Insert(0, new ListItem("=请选择颜色=", "0"));
            //this.drpSize.Items.Insert(0, new ListItem("=请选择尺寸=", "0"));        }        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("Desimage.aspx?id=" + int.Parse(this.Request.QueryString["pid"].ToString()));
            //Server.Transfer("Desimage.aspx?id=" + int.Parse(this.Request.QueryString["pid"].ToString()));
        }
        /// <summary>
        /// 添加到购物车
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void addcart_Click(object sender, ImageClickEventArgs e)
        {
            ClothesShop.BLL.userinfo user = new ClothesShop.BLL.userinfo();
            if (user.IsLogin() == true)
            {
                //if (this.countliteral.Text.Trim() != "抱歉!该商品缺货")
                //{
                ClothesShop.BLL.cart ocart = new ClothesShop.BLL.cart();
                //if (ocart.isexitproduct(int.Parse(this.Request.QueryString["pid"].ToString()),user.getUserID()) == false)
                //{
                if (ocart.createcart(int.Parse(this.Request.QueryString["pid"].ToString()), user.getUserID(), 1, false, this.drpColor.SelectedItem.Value, this.drpSize.SelectedItem.Value) == 1)
                {                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script type='text/javascript'>alert('恭喜!购物成功');location.href='Cart.aspx';</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script type='text/javascript'>alert('遗憾!购物失败');location.href='Cart.aspx';</script>", false);
                }
                //}
                //else
                //{
                //    if (ocart.updatecart(int.Parse(this.Request.QueryString["pid"].ToString()),user.getUserID()) == 1)
                //    {
                //        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script type='text/javascript'>alert('恭喜!购物成功');location.href='Cart.aspx';</script>", false);
                //    }
                //    else
                //    {
                //        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script type='text/javascript'>alert('遗憾!购物失败');location.href='Cart.aspx';</script>", false);
                //    }
                //}
                //}
                //else
                //{
                //    this.addcart.Enabled = false;
                //}
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('遗憾!您还未登录!');location.href='login_1.aspx';</script>");
            }
        }