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;
namespace norke
{
    public partial class viste_qqproductadd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["norkeyangjian"];
            if (cookie == null)
            {
                Response.Redirect("~/login.aspx");
                return;
            }

            if (!IsPostBack)
            {
                getCategory();//绑定类别下拉列表           
            }
        }
        private void getCategory()//绑定类别下拉列表
        {
            DBConn myDB = new DBConn();
            string sql = "select * from Category";
            ddlCategory.DataSource = myDB.getDataReader(sql);
            ddlCategory.DataTextField = "CName";
            ddlCategory.DataValueField = "CID";
            ddlCategory.DataBind();
            myDB.Close();
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string sql = "insert  into qqproduct (qname,qlb,qjiage,qxh,qjs,uname) values ('" + txtName.Text.Trim() + "','" + ddlCategory.SelectedValue + "','" + txtNPrice.Text.Trim() + "','" + txtFPrice.Text.Trim() + "','" + txtBewrite.Text + "','" + Request.Cookies["norkeyangjian"].Value + "')";
            DBConn mydb = new DBConn();
            mydb.Insert(sql);
            mydb.Close();
            Response.Redirect("qqproductmanager.aspx");
        }
}
}
