public LoaiDocGiaCollection TimDSLoaiDocGia(string tenloai)
 {
     LoaiDocGiaCollection loaiColl = new LoaiDocGiaCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "select * from LoaiDocGia where tenloai <> '' ";
     query += "order by tenloai";
     SqlCommand cmd = new SqlCommand(query, cnn);
     if (tenloai != "")
     {
         query = "select * from LoaiDocGia where tenloai like @tenloai and tenloai <>''";
         query += "order by tenloai";
         cmd = new SqlCommand(query, cnn);
         cmd.Parameters.AddWithValue("@tenloai", "%" + tenloai + "%");
     }
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         LoaiDocGiaBO loaiBO = new LoaiDocGiaBO();
         loaiBO.MaLoai = dr["maloai"].ToString();
         loaiBO.TenLoai = dr["tenloai"].ToString();
         loaiColl.Add(loaiBO);
     }
     cnn.Close();
     return loaiColl;
 }
 public void SuaLoaiDocGia(LoaiDocGiaBO loaidocgiaBO)
 {
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "update LoaiDocGia set tenloai=@tenloai where maloai=@maloai ";
     SqlCommand cmd = new SqlCommand(query, cnn);
     cmd.Parameters.AddWithValue("@tenloai", loaidocgiaBO.TenLoai);
     cmd.Parameters.AddWithValue("@maloai", loaidocgiaBO.MaLoai);
     cnn.Open();
     cmd.ExecuteNonQuery();
     cnn.Close();
 }
        public bool SuaLoaiDocGia(string maloaidocgia, string tenloaidocgia)
        {
            try
            {
                LoaiDocGiaBO loaidocgiaBO = new LoaiDocGiaBO();
                loaidocgiaBO.MaLoai = maloaidocgia;
                loaidocgiaBO.TenLoai = tenloaidocgia;
                loaidocgiaDAO.SuaLoaiDocGia(loaidocgiaBO);
                return true;
            }
            catch
            {
                return false;
            }

        }
 public LoaiDocGiaBO Tim1LoaiDocGia(string maloai)
 {
     LoaiDocGiaBO loaidocgiaBO = new LoaiDocGiaBO();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "select top 1 * from LoaiDocGia WHERE maloai=@maloai";
     SqlCommand cmd = new SqlCommand(query, cnn);
     cmd.Parameters.AddWithValue("@maloai", maloai);
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         loaidocgiaBO.MaLoai = dr["maloai"].ToString();
         loaidocgiaBO.TenLoai = dr["tenloai"].ToString();
     }
     cnn.Close();
     return loaidocgiaBO;
 }
 public void Add (LoaiDocGiaBO loaidocgiaBO)
 {
     List.Add(loaidocgiaBO);
 }