public NhanVienCollection TimDSNhanVien(string tennv)
 {
     NhanVienCollection nhanvienColl = new NhanVienCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "SELECT Manv,macv,tennv,diachi,gioitinh,convert(varchar(10),ngaysinh,103) ngaysinh,dienthoai,hinhanh,taikhoan FROM NhanVien WHERE Ngunghoatdong=0";
     SqlCommand cmd = new SqlCommand(query, cnn);
     if(tennv!="")
     {
         query = "SELECT Manv,macv,tennv,diachi,gioitinh,convert(varchar(10),ngaysinh,103) ngaysinh,dienthoai,hinhanh,taikhoan FROM NhanVien WHERE tennv like @tennv AND Ngunghoatdong=0";
         cmd = new SqlCommand(query, cnn);
         cmd.Parameters.AddWithValue("@tennv", "%"+tennv+"%");
     }
     cnn.Open();
     SqlDataReader dr= cmd.ExecuteReader();
     while(dr.Read())
     {
         NhanVienBO nvBO = new NhanVienBO();
         nvBO.MaNV =dr["MaNV"].ToString();
         nvBO.MaCV = dr["MaCV"].ToString();
         nvBO.TenNV = dr["TenNV"].ToString();
         nvBO.DiaChi = dr["Diachi"].ToString();
         nvBO.GioiTinh =Convert.ToBoolean(dr["GioiTinh"]);
     //    nvBO.NgaySinh = DateTime.ParseExact(dr["Ngaysinh"].ToString(),"ddMMyyyy",System.Globalization.CultureInfo.CurrentCulture);
         nvBO.NgaySinh = dr["ngaysinh"].ToString();
         nvBO.DienThoai = dr["DienThoai"].ToString();
         nvBO.HinhAnh = dr["HinhAnh"].ToString();
         nvBO.TaiKhoan = dr["TaiKhoan"].ToString();
       //  nvBO.MatKhau = dr["MatKhau"].ToString();
         nhanvienColl.Add(nvBO);
     }
     cnn.Close();
     return nhanvienColl;
 }
 public NhanVienCollection TimDSNhanVien_NgungHoatDong(string tennv)
 {
     NhanVienCollection nhanvienColl = new NhanVienCollection();
     SqlConnection cnn = new SqlConnection(cnnstr);
     string query = "SELECT * FROM NhanVien WHERE Ngunghoatdong=1";
     SqlCommand cmd = new SqlCommand(query, cnn);
     if (tennv != "")
     {
         query = "SELECT * FROM NhanVien WHERE tennv like @tennv AND Ngunghoatdong=1";
         cmd = new SqlCommand(query, cnn);
         cmd.Parameters.AddWithValue("@tennv", "%" + tennv + "%");
     }
     cnn.Open();
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         NhanVienBO nvBO = new NhanVienBO();
         nvBO.MaNV = dr["MaNV"].ToString();
         nvBO.MaCV = dr["MaCV"].ToString();
         nvBO.TenNV = dr["TenNV"].ToString();
         nvBO.DiaChi = dr["Diachi"].ToString();
         nvBO.GioiTinh = Convert.ToBoolean(dr["GioiTinh"]);
        // nvBO.NgaySinh = Convert.ToDateTime(dr["Ngaysinh"]);
         nvBO.NgaySinh =dr["Ngaysinh"].ToString();
         nvBO.DienThoai = dr["DienThoai"].ToString();
         nvBO.HinhAnh = dr["HinhAnh"].ToString();
         if (nvBO.HinhAnh == "")//nếu hình ảnh bằng rỗng
             nvBO.HinhAnh = "../images/nhanvien/questionface.jpg";
         nvBO.TaiKhoan = dr["TaiKhoan"].ToString();
         //  nvBO.MatKhau = dr["MatKhau"].ToString();
         nhanvienColl.Add(nvBO);
     }
     cnn.Close();
     return nhanvienColl;
 }