public void NapTheLoai()
 {
     TheLoaiDropdown.Items.Clear();
     PhanLoaiCollection source = new PhanLoaiCollection();      
     PhanLoaiBO phanloaiBO = new PhanLoaiBO();
     phanloaiBO.TenPhanLoai = "Tất cả";
     phanloaiBO.MaPhanLoai = "";
     source.Add(phanloaiBO);
     //add
     PhanLoaiCollection temp = new PhanLoaiCollection();
     temp=phanloaiBUS.TimDSPhanLoai();
     for (int i = 0; i < temp.Count; i++)
     {
         source.Add(temp.Index(i));
     }
     TheLoaiDropdown.DataSource = source;
     TheLoaiDropdown.DataTextField = "Tenphanloai";
     TheLoaiDropdown.DataValueField = "Maphanloai";
     TheLoaiDropdown.DataBind();
 }
 public PhanLoaiCollection TimDSPhanLoai()
 {
     PhanLoaiCollection plColl = new PhanLoaiCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     SqlCommand cmd = new SqlCommand("select * from PhanLoai order by TenPhanLoai", cnn);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         PhanLoaiBO plBO = new PhanLoaiBO();
         plBO.MaPhanLoai = dr["MaPhanLoai"].ToString();
         plBO.TenPhanLoai=dr["TenPhanLoai"].ToString();
         plColl.Add(plBO);
       //  string mapl = dr["maphanloai"].ToString();
       //  plColl.Add(Tim1PhanLoai(mapl));
     }
     cnn.Close();
     return plColl;
 }
        public PhanLoaiCollection TimDSCapNhatPhanLoai(string tenphanloai)
        {
            PhanLoaiCollection phanloaicoll = new PhanLoaiCollection();

            SqlConnection cnn = new SqlConnection(cnnstr);
            string query = "select * from PhanLoai where tenphanloai <> '' ";
            query += "order by tenphanloai";
            SqlCommand cmd = new SqlCommand(query, cnn);
            if (tenphanloai != "")
            {
                query = "select * from PhanLoai where tenphanloai like @tenphanloai and tenphanloai <>''";
                query += "order by tenphanloai";
                cmd = new SqlCommand(query, cnn);
                cmd.Parameters.AddWithValue("@tenphanloai", "%" + tenphanloai + "%");
            }
            cnn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                PhanLoaiBO phanloaiBO = new PhanLoaiBO();
                phanloaiBO.MaPhanLoai = dr["maphanloai"].ToString();
                phanloaiBO.TenPhanLoai = dr["tenphanloai"].ToString();
                phanloaicoll.Add(phanloaiBO);

            }
            cnn.Close();
            return phanloaicoll;
        }