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 WebMain_Product_Search_highseach : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        if (!IsPostBack)
        {
            SqlCommand smdlb;
            SqlDataAdapter sdalb;
            DataSet dslb;
            DataTable tb;
            DataRow dr;
            SqlDataReader sdrlb;
            tb = new DataTable();
            tb.Columns.Add("id", typeof(int));
            tb.Columns.Add("BigCategory", typeof(string));
            tb.Columns.Add("sort", typeof(int));
            smdlb = new SqlCommand("select * from BigProductCategory where id<>10000034 order by Sort", conn);
            dr = tb.NewRow();
            dr["id"] = 0;
            dr["BigCategory"] = "请选择大类产品";
            dr["sort"] = 0;
            tb.Rows.Add(dr);
            sdrlb = smdlb.ExecuteReader();
            while (sdrlb.Read())
            {
                dr = tb.NewRow();
                dr["id"] = sdrlb["id"].ToString();
                dr["BigCategory"] = sdrlb["BigCategory"].ToString();
                dr["sort"] = sdrlb["sort"].ToString();
                tb.Rows.Add(dr);
            }
            sdrlb.Close();
            Doadmin.ddldatabind2(biglb, tb, "BigCategory", "id");
            if (biglb.SelectedValue.ToString() == "0")
            {
                tb = new DataTable();
                tb.Columns.Add("id", typeof(int));
                tb.Columns.Add("SmallCategory", typeof(string));
                tb.Columns.Add("sort", typeof(string));
                dr = tb.NewRow();
                dr["id"] = 0;
                dr["SmallCategory"] = "请选择小类产品";
                dr["sort"] = 0;
                tb.Rows.Add(dr);
                Doadmin.ddldatabind2(smalllb, tb, "SmallCategory", "id");
            }
        }
        conn.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ist = "";
        string ish = "";
        if (isy.Checked)
        {
            ist = "0";
        }
        else
        {
            if (isn.Checked)
            {
                ist = "1";
            }
            else
            {
                ist = "2";
            }
        }
        if (isyt.Checked)
        {
            ish = "0";
        }
        else
        {
            if (isnt.Checked)
            {
                ish = "1";
            }
            else
            {
                ish = "2";
            }
        }
        Response.Redirect("~/china/highsearchresult.aspx?pcount=20&keyword=" + this.biglb.SelectedValue.ToString() + "|" + this.smalllb.SelectedValue + "|" + productname.Text + "|" + this.pno.Text + "|" + pder.Text + "|" + pcont.Text + "|" + pbrand.Text + "|" + price1.Text + "|" + price2.Text + "|" + ist + "|" + ish);
    }
    protected void biglb_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlConnection conn;
        conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand smdlb;
        SqlDataAdapter sdalb;
        DataSet dslb;
        DataTable tb;
        DataRow dr;
        SqlDataReader sdrlb;
        if (this.biglb.SelectedValue.ToString() != "0")
        {
            tb = new DataTable();
            tb.Columns.Add("id", typeof(int));
            tb.Columns.Add("SmallCategory", typeof(string));
            tb.Columns.Add("sort", typeof(int));
            smdlb = new SqlCommand("select * from SmallProductCategory where BigCategoryId=" + this.biglb.SelectedValue + " order by Sort", conn);
            sdrlb = smdlb.ExecuteReader();
            while (sdrlb.Read())
            {
                dr = tb.NewRow();
                dr["id"] = sdrlb["id"].ToString();
                dr["SmallCategory"] = sdrlb["SmallCategory"].ToString();
                dr["sort"] = sdrlb["sort"].ToString();
                tb.Rows.Add(dr);
            }
            sdrlb.Close();
            Doadmin.ddldatabind2(smalllb, tb, "SmallCategory", "id");
        }
        else
        {
            tb = new DataTable();
            tb.Columns.Add("id", typeof(int));
            tb.Columns.Add("SmallCategory", typeof(string));
            tb.Columns.Add("sort", typeof(int));
            dr = tb.NewRow();
            dr["id"] = 0;
            dr["SmallCategory"] = "请选择小类产品";
            dr["sort"] = 0;
            tb.Rows.Add(dr);
            Doadmin.ddldatabind2(smalllb, tb, "SmallCategory", "id");
        }
    }
}
