public LoaiSanPhamCollection()
 {
     DataTable dt = DataAccess.ViewForGridView("Loaisanpham_ViewAll");
     foreach (DataRow dr in dt.Rows)
     {
         LoaiSanPham lsp = new LoaiSanPham();
         lsp.LoaisanphamID = int.Parse(dr["LoaisanphamID"].ToString());
         lsp.Tenloaisanpham = dr["Tenloaisanpham"].ToString();
         lst.Add(lsp);
     }
 }
 public static List<LoaiSanPham> ViewAll()
 {
     if (conn.State == ConnectionState.Open) conn.Close();
     conn.Open();
     SqlCommand sc = new SqlCommand("Loaisanpham_ProcViewAll", conn);
     sc.CommandType = CommandType.StoredProcedure;
     SqlDataReader reader = sc.ExecuteReader();
     List<LoaiSanPham> lstLsp = new List<LoaiSanPham>();
     while (reader.Read())
     {
         LoaiSanPham lsp = new LoaiSanPham();
         lsp.Tenloaisanpham = (reader["Tenloaisanpham"] != null ? reader["Tenloaisanpham"].ToString() : "");
         lsp.LoaisanphamID = (reader["LoaisanphamID"] != null ? int.Parse(reader["LoaisanphamID"].ToString()) : 0);
         lstLsp.Add(lsp);
     }
     reader.Close();
     conn.Close();
     return lstLsp;
 }