public List <lienheDAL> getLienHeP(int row, int hide) { List <lienheDAL> list = new List <lienheDAL>(); SqlConnection cn = cnn.connectToSql(); cn.Open(); string sql = "select top " + row + " * from lien_he where id_lienhe not in (select top " + hide + " id_lienhe from lien_he order by id_lienhe DESC ) order by id_lienhe DESC"; SqlCommand cmd = new SqlCommand(sql, cn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { lienheDAL ds = new lienheDAL(); ds.id_lienhe = rd.GetInt32(0); ds.hoten = rd.GetString(1); ds.email = rd.GetString(2); ds.sdt = rd.GetString(3); ds.noidung = rd.GetString(4); ds.ngaygui = rd.GetDateTime(5); list.Add(ds); } return(list); cmd.Dispose(); cn.Close(); }
public List <lienheDAL> getLienHe() { List <lienheDAL> list = new List <lienheDAL>(); SqlConnection cn = cnn.connectToSql(); cn.Open(); string sql = "SELECT * FROM lien_he"; SqlCommand cmd = new SqlCommand(sql, cn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { lienheDAL ds = new lienheDAL(); ds.id_lienhe = rd.GetInt32(0); ds.hoten = rd.GetString(1); ds.email = rd.GetString(2); ds.sdt = rd.GetString(3); ds.noidung = rd.GetString(4); ds.ngaygui = rd.GetDateTime(5); list.Add(ds); } return(list); cmd.Dispose(); cn.Close(); }
// danh sach lien he da xem: public List <lienheDAL> lienhe_view(int id_user) { List <lienheDAL> list = new List <lienheDAL>(); SqlConnection cn = cnn.connectToSql(); cn.Open(); string sql = "SELECT lien_he.id_lienhe FROM lien_he, view_lienhe WHERE lien_he.id_lienhe = view_lienhe.id_lienhe AND view_lienhe.id_user = "******" ORDER BY lien_he.id_lienhe ASC"; SqlCommand cmd = new SqlCommand(sql, cn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { lienheDAL ds = new lienheDAL(); ds.id_lienhe = rd.GetInt32(0); list.Add(ds); } return(list); cmd.Dispose(); cn.Close(); }