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.SqlClient;

public partial class SystemManage_product_open : System.Web.UI.Page
{
    private readonly static string sqlcmd1 = "select name,product_type,PRODYCT_FORMAT,price,mome from product where id=";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["username"]) == "")
        {
            Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
        }
        if (!IsPostBack)
        {
            using (SqlConnection sqlconn = new SqlConnection(Tools.strConn))
            {
                SqlCommand cmd = new SqlCommand((sqlcmd1 + Request["id"]), sqlconn);
                sqlconn.Open();
                SqlDataReader sr= cmd.ExecuteReader();
                while(sr.Read())
                {
                    this.name.Text = Convert.ToString(sr["name"]);
                    this.productType.Text = Convert.ToString(sr["product_type"]);
                    this.productFormat.Text = Convert.ToString(sr["PRODYCT_FORMAT"]);
                    this.price.Text = Convert.ToString(sr["price"]);
                    this.mome.Text = Convert.ToString(sr["mome"]);
                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        using (SqlConnection sqlconn = new SqlConnection(Tools.strConn))
        {
            SqlCommand cmd = new SqlCommand("update product set name= '" + Request["name"] + "',product_type = '" + Request["productType"] + "',PRODYCT_FORMAT = '" + Request["productFormat"] + "',price='" + Request["price"] + "',mome = '" + Request["mome"] + "' where id = '" + Request["id"] + "'", sqlconn);
            sqlconn.Open();
            cmd.ExecuteNonQuery();
            Response.Write("<script>alert('商品信息修改成功');opener.location='ProductManage.aspx';window.close()</script>");
        }
    }
}
