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 CTPhanLoai Tim1CTPhanLoai(string mactphanloai)
 {
     CTPhanLoai ctphanloai = new CTPhanLoai();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "SELECT * FROM chitietphanloai where mactphanloai=@mactphanloai";
     SqlCommand cmd = new SqlCommand(query, cnn);
     cmd.Parameters.AddWithValue("@mactphanloai", mactphanloai);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         ctphanloai.MaCTPhanLoai=dr["mactphanloai"].ToString();
         ctphanloai.TenCTPhanLoai=dr["tenctphanloai"].ToString();
         break;
     }
     cnn.Close();
     return ctphanloai;
 }
 public void Add(CTPhanLoai ctphanloai)
 {
     List.Add(ctphanloai);
 }
 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;
 }