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_qqproductmanager : 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)
            {
                getData();
                getddlClassData();
            }
        }


        private void getData()//绑定数据
        {
            DBConn myDB = new DBConn();
            string sql = "select * from qqproduct Left Outer join Category on  qqproduct.qlb = Category.CID where uname='" + Request.Cookies["norkeyangjian"].Value + "' order by qID desc";
            DataGrid1.DataSource = myDB.getDataReader(sql);
            DataGrid1.DataBind();
            mySqlPager.setAttribute(SqlPager1, "DataGrid1", sql, "1000000-PID", 20);
        }

        private void getddlClassData()//绑定 类别选框
        {
            DBConn myDB = new DBConn();
            string sql = "select * from Category order by CID desc";
            ddlClass.DataSource = myDB.getDataReader(sql);
            ddlClass.DataTextField = "CName";
            ddlClass.DataValueField = "CID";
            ddlClass.DataBind();
            myDB.Close();

            ddlClass.Items.Insert(0, new ListItem("所有分类", "-1"));
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {

        }
        protected void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            string strid = e.Item.Cells[0].Text;
            DBConn myDB = new DBConn();
            string mySql = "Delete from qqproduct where qID=" + strid;
            myDB.Delete(mySql);
            myDB.Close();
            getData();
        }
}
}