public void NapCTPhanLoai(string maphanloai)
 {
     CTPhanLoaiDropdown.Items.Clear();
     CTPhanLoaiCollection source = new CTPhanLoaiCollection();
     CTPhanLoai ctphanloai = new CTPhanLoai();
     ctphanloai.TenCTPhanLoai = "...";
     ctphanloai.MaCTPhanLoai = "";
     source.Add(ctphanloai);
     //add
     if (maphanloai != "")
     {
         CTPhanLoaiCollection temp = new CTPhanLoaiCollection();
         temp = phanloaiBUS.TimDSCTPhanLoai(maphanloai);
         if (temp != null)
         {
             for (int i = 0; i < temp.Count; i++)
             {
                 source.Add(temp.Index(i));
             }
         }
     }
     CTPhanLoaiDropdown.DataSource = source;
     CTPhanLoaiDropdown.DataTextField = "TenCTphanloai";
     CTPhanLoaiDropdown.DataValueField = "MaCtphanloai";
     CTPhanLoaiDropdown.DataBind();
 }
 public PhanLoaiBO Tim1PhanLoai(string MaPhanLoai)
 {
     PhanLoaiBO plBO = new PhanLoaiBO();
     CTPhanLoaiCollection ctPhanLoaiColl = new CTPhanLoaiCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     SqlCommand cmd = new SqlCommand("select * from chitietPhanLoai where MaPhanLoai=@maphanloai", cnn);
     cmd.Parameters.AddWithValue("@maphanloai", MaPhanLoai);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         //lấy thông tin của phân loại
         plBO.MaPhanLoai = dr["MaPhanLoai"].ToString();
         plBO.TenPhanLoai = dr["TenPhanLoai"].ToString();
         //lấy chi tiết phân lọai
         CTPhanLoai ctphanloai = new CTPhanLoai();
         ctphanloai.MaCTPhanLoai = dr["MaCTPhanLoai"].ToString();
         ctphanloai.TenCTPhanLoai=dr["TenCTPhanLoai"].ToString();
         ctPhanLoaiColl.Add(ctphanloai);
     }
     //gán chi tiết phân lọai
     plBO.chitietphanloaiColl = ctPhanLoaiColl;
     cnn.Close();
     return plBO;
 }
 ////////////////////////////////////////
 public CTPhanLoaiCollection TimDSCTPhanLoai(string maphanloai)
 {
     CTPhanLoaiCollection ctphanloaiColl= new CTPhanLoaiCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "SELECT * FROM chitietphanloai where maphanloai=@maphanloai order by tenctphanloai";
     SqlCommand cmd = new SqlCommand(query,cnn);
     cmd.Parameters.AddWithValue("@maphanloai",maphanloai);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         CTPhanLoai ctphanloai = new CTPhanLoai();
         ctphanloai.MaCTPhanLoai = dr["mactphanloai"].ToString();
         ctphanloai.TenCTPhanLoai=dr["tenctphanloai"].ToString();
         ctphanloaiColl.Add(ctphanloai);
     }
     cnn.Close();
     return ctphanloaiColl;
 }