public List <KhachSanDTO> TimKiemKhachSan(string TenKS, string TenDDDL, int iPage, int numberItem) { connect(); SqlDataAdapter da = new SqlDataAdapter(); DataSet dataset = new DataSet(); List <KhachSanDTO> ds = new List <KhachSanDTO>(); command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_TimKiemKhachSan"; paramater = new SqlParameter("Start", SqlDbType.Int, 4); paramater.Direction = ParameterDirection.Input; paramater.Value = (iPage - 1) * numberItem; command.Parameters.Add(paramater); paramater = new SqlParameter("End", SqlDbType.Int, 4); paramater.Direction = ParameterDirection.Input; paramater.Value = iPage * numberItem; command.Parameters.Add(paramater); paramater = new SqlParameter("TenKS", SqlDbType.NVarChar); paramater.Direction = ParameterDirection.Input; paramater.Value = TenKS; command.Parameters.Add(paramater); paramater = new SqlParameter("TenDDDL", SqlDbType.NVarChar); paramater.Direction = ParameterDirection.Input; if (TenDDDL == null) { paramater.Value = ""; } else { paramater.Value = TenDDDL; } command.Parameters.Add(paramater); da.SelectCommand = command; da.Fill(dataset); DataTable dataTable = dataset.Tables[0]; int n = dataTable.Rows.Count; for (int i = 0; i < n; i++) { KhachSanDTO KhachSanDTO = new DTO.KhachSanDTO(); KhachSanDTO = (KhachSanDTO)GetDataFromDataRow(dataTable, i); ds.Add(KhachSanDTO); } disconnect(); return(ds); }
public List <KhachSanDTO> getDanhSachKhachSan(int iPage, int numberItem) { connect(); SqlDataAdapter da = new SqlDataAdapter(); DataSet dataset = new DataSet(); List <KhachSanDTO> ds = new List <KhachSanDTO>(); command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_DanhSachKhachSanPhanTrang"; paramater = new SqlParameter("Start", SqlDbType.Int, 4); paramater.Direction = ParameterDirection.Input; paramater.Value = (iPage - 1) * numberItem; command.Parameters.Add(paramater); paramater = new SqlParameter("End", SqlDbType.Int, 4); paramater.Direction = ParameterDirection.Input; paramater.Value = iPage * numberItem; command.Parameters.Add(paramater); da.SelectCommand = command; da.Fill(dataset); DataTable dataTable = dataset.Tables[0]; int n = dataTable.Rows.Count; for (int i = 0; i < n; i++) { KhachSanDTO KhachSanDTO = new DTO.KhachSanDTO(); KhachSanDTO = (KhachSanDTO)GetDataFromDataRow(dataTable, i); ds.Add(KhachSanDTO); } disconnect(); return(ds); }