/// <summary> /// This function loads the vacancies according to the filters /// </summary> void LoadVacancies() { //create filters var filter = new JobFilter { Keyword = txtKeyword.Text.Replace("'", "''") }; if (ddlStatus.SelectedValue != "-1") filter.Archived = ddlStatus.SelectedValue != "1"; if (ddlPublished.SelectedValue != "-1") filter.Published = ddlPublished.SelectedValue == "1"; // filter.ConsultantIds = (ddlConsultant.SelectedValue == "" || ddlConsultant.SelectedValue == "0") ? "" : ddlConsultant.SelectedValue; filter.ClientId = Convert.ToInt32(txtSelectedClient.Text); filter.ManagerId = (ddlmanager.SelectedValue == "" || ddlmanager.SelectedValue == "0") ? 0 : int.Parse(ddlmanager.SelectedValue); //paging filter.RecordsPerPage = RecordsPerPage; filter.CurrentPage = (Request.QueryString["paged"] != null && int.TryParse(Request.QueryString["paged"], out _tempInt)) ? int.Parse(Request.QueryString["paged"]) : 1; filter.SortBy = Request.QueryString["sort"] ?? "createddate desc"; filter.Deleted = false; //bind repeater var jobList = new Jobs().GetJobs(filter).ToList(); rptVacancy.DataSource = jobList; rptVacancy.DataBind(); //show and hide items/actions and no items if (jobList.Count > 0) { noitems.Visible = false; items.Visible = true; actions.Visible = true; //set the pager pager1.totalRecords = jobList.First().RecordCount; pager1.recordsPerPage = RecordsPerPage; } else { noitems.Visible = true; items.Visible = false; actions.Visible = false; } }
/// <summary> /// This function returns the jobs for the given criteria /// </summary> /// <param name="filters"></param> /// <returns></returns> public IEnumerable<Job> GetJobs(JobFilter filters) { var jobs = new List<Job>(); // setup the parameters SqlParameter[] parameters = { new SqlParameter("@RecordsPerPage", filters.RecordsPerPage), new SqlParameter("@PageNo", filters.CurrentPage), new SqlParameter("@ClientId", filters.ClientId), new SqlParameter("@ManagerId", filters.ManagerId), new SqlParameter("@JobTitle", filters.JobTitle), new SqlParameter("@Sectors", filters.Sectors), new SqlParameter("@Locations", filters.Locations), new SqlParameter("@MinSalary", filters.MinSalary), new SqlParameter("@MaxSalary", filters.MaxSalary), new SqlParameter("@Keyword", filters.Keyword), new SqlParameter("@JobIdsIn", filters.JobIdsIn), new SqlParameter("@JobUsers", filters.JobUsers), new SqlParameter("@Published", filters.Published), new SqlParameter("@Archived", filters.Archived), new SqlParameter("@Deleted", filters.Deleted), new SqlParameter("@SortBy", filters.SortBy) }; // setup the connection var conn = new Sql_DataAccess(_connString); var ds = conn.GetDataSetFromSP("RetrieveJobs", parameters); // iterate and return jobs if (ds != null && ds.Tables.Count > 0) { jobs = (from DataRow dr in ds.Tables[0].Rows select new Job { RecordCount = (int)dr["RECORDCOUNT"], JobId = (int)dr["JobId"], ClientId = (int)dr["ClientId"], ClientName = (dr["Client"] ?? "").ToString(), JobTitle = (dr["JobTitle"] ?? "").ToString(), Ref = (dr["Ref"] ?? "").ToString(), JobLocation = (dr["JobLocation"] ?? "").ToString(), Published = (bool)dr["Published"], Archived = (bool)dr["Archived"], Deleted = (bool)dr["Deleted"], ExpiryDate = dr["ExpiryDate"] is DBNull ? null : (DateTime?)dr["ExpiryDate"], CreatedDate = (DateTime)dr["CreatedDate"], LastUpdatedDate = (DateTime?)dr["LastUpdatedDate"], RefId = (dr["RefId"] ?? "").ToString(), StartDate = dr["StartDate"] is DBNull ? null : (DateTime?)dr["StartDate"], ApplicationCount = (int)dr["ApplicationCount"] }).ToList(); } return jobs; }