public static JobPosting GetPosting(int id) { DBAccess db = new DBAccess(); db.Parameters.Add(new SqlParameter("@iPostingID", id)); SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_JobPostings_SelectOne"); if (dr.HasRows) { JobPosting objJobPosting = new JobPosting(); while (dr.Read()) { objJobPosting.JobPostingID = dr.GetInt32(dr.GetOrdinal("PostingID")); objJobPosting.CompanyID = dr.GetInt32(dr.GetOrdinal("CompanyID")); objJobPosting.Title = dr.GetString(dr.GetOrdinal("Title")); objJobPosting.ContactPerson = dr.GetString(dr.GetOrdinal("ContactPerson")); objJobPosting.Department = dr.GetString(dr.GetOrdinal("Department")); objJobPosting.Description = dr.GetString(dr.GetOrdinal("JobDescription")); objJobPosting.City = dr.GetString(dr.GetOrdinal("City")); objJobPosting.StateID = dr.GetInt32(dr.GetOrdinal("StateID")); objJobPosting.CountryID = dr.GetInt32(dr.GetOrdinal("CountryID")); objJobPosting.EducationLevelID = dr.GetInt32(dr.GetOrdinal("EducationLevelID")); objJobPosting.JobTypeID = dr.GetInt32(dr.GetOrdinal("JobTypeID")); objJobPosting.JobCode = dr.GetString(dr.GetOrdinal("JobCode")); objJobPosting.MinSalary = dr.GetDecimal(dr.GetOrdinal("MinSalary")); objJobPosting.MaxSalary = dr.GetDecimal(dr.GetOrdinal("MaxSalary")); objJobPosting.PostingDate = dr.GetDateTime(dr.GetOrdinal("PostingDate")); objJobPosting.PostedBy = dr.GetString(dr.GetOrdinal("PostedBy")); } dr.Close(); return objJobPosting; } else { dr.Close(); return new JobPosting(); } }
/// <summary> /// 根据指定的用户名获取简历的编号 /// </summary> /// <param name="username"></param> /// <returns></returns> public static int GetResumeID(string username) { DBAccess db = new DBAccess(); db.AddParameter("@sUserName", username); SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_Resumes_SelectForUser"); int resumeid=-1; if (dr.HasRows) { while (dr.Read()) { resumeid = dr.GetInt32(dr.GetOrdinal("ResumeID")); } dr.Close(); } return resumeid; }
/// <summary> /// 根据指定的用户简历编号获取简历信息 /// </summary> /// <param name="resumeid">简历编号</param> /// <returns></returns> public static Resume GetResume(int resumeid) { DBAccess db = new DBAccess(); db.AddParameter("@iResumeID", resumeid); SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_Resumes_SelectOne"); if (dr.HasRows) { Resume r = new Resume(); while (dr.Read()) { r.ResumeID = dr.GetInt32(dr.GetOrdinal("ResumeID")); r.City = dr.GetString(dr.GetOrdinal("TargetCity")); r.CountryID = dr.GetInt32(dr.GetOrdinal("TargetCountryID")); r.CoveringLetterText = dr.GetString(dr.GetOrdinal("CoverLetterText")); r.EducationLevelID = dr.GetInt32(dr.GetOrdinal("EducationLevelID")); r.ExperienceLevelID = dr.GetInt32(dr.GetOrdinal("ExperienceLevelID")); r.JobTitle = dr.GetString(dr.GetOrdinal("JobTitle")); r.JobTypeID = dr.GetInt32(dr.GetOrdinal("TargetJobTypeID")); r.RelocationCountryID = dr.GetInt32(dr.GetOrdinal("RelocationCountryID")); r.ResumeText = dr.GetString(dr.GetOrdinal("ResumeText")); r.StateID = dr.GetInt32(dr.GetOrdinal("TargetStateID")); r.UserName = dr.GetString(dr.GetOrdinal("UserName")); r.PostedDate = dr.GetDateTime(dr.GetOrdinal("PostDate")); } dr.Close(); return r; } else { dr.Close(); return new Resume(); } }
/// <summary> /// 根据指定的用户名获取单个简历 /// </summary> /// <param name="username">用户名</param> /// <returns></returns> public static Resume GetResume(string username) { //实例化DBAccess对象 DBAccess db = new DBAccess(); //添加指定的输入参数 db.AddParameter("@sUserName", username); //执行存储过程JobsDb_Resumes_SelectForUser获取简历信息 SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_Resumes_SelectForUser"); if (dr.HasRows) { //实例化一个新的Resume对象 Resume r = new Resume(); //从DbDataReader中获取Resume信息 while (dr.Read()) { r.ResumeID = dr.GetInt32(dr.GetOrdinal("ResumeID")); r.City = dr.GetString(dr.GetOrdinal("TargetCity")); r.CountryID = dr.GetInt32(dr.GetOrdinal("TargetCountryID")); r.CoveringLetterText = dr.GetString(dr.GetOrdinal("CoverLetterText")); r.EducationLevelID = dr.GetInt32(dr.GetOrdinal("EducationLevelID")); r.ExperienceLevelID = dr.GetInt32(dr.GetOrdinal("ExperienceLevelID")); r.JobTitle = dr.GetString(dr.GetOrdinal("JobTitle")); r.JobTypeID = dr.GetInt32(dr.GetOrdinal("TargetJobTypeID")); r.RelocationCountryID = dr.GetInt32(dr.GetOrdinal("RelocationCountryID")); r.ResumeText = dr.GetString(dr.GetOrdinal("ResumeText")); r.StateID = dr.GetInt32(dr.GetOrdinal("TargetStateID")); r.UserName = dr.GetString(dr.GetOrdinal("UserName")); r.PostedDate = dr.GetDateTime(dr.GetOrdinal("PostDate")); } //关闭DbDataReader对象并返回Resume对象。 dr.Close(); return r; } else { //如果没有记录,则将ResumeID值赋为-1。 dr.Close(); Resume r = new Resume(); r.ResumeID = -1; return r; } }
public static Company GetCompany(int companyid) { DBAccess db = new DBAccess(); db.Parameters.Add(new SqlParameter("@iCompanyID", companyid)); SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_Companies_SelectOne"); if (dr.HasRows) { Company c = new Company(); while (dr.Read()) { c.CompanyID = dr.GetInt32(dr.GetOrdinal("companyid")); c.CompanyName = dr.GetString(dr.GetOrdinal("CompanyName")); c.BriefProfile = dr.GetString(dr.GetOrdinal("CompanyProfile")); c.WebSiteUrl = dr.GetString(dr.GetOrdinal("WebSiteUrl")); c.Address1 = dr.GetString(dr.GetOrdinal("Address1")); c.Address2 = dr.GetString(dr.GetOrdinal("Address2")); c.City = dr.GetString(dr.GetOrdinal("City")); c.StateID = dr.GetInt32(dr.GetOrdinal("StateID")); c.CountryID = dr.GetInt32(dr.GetOrdinal("CountryID")); c.ZIP = dr.GetString(dr.GetOrdinal("ZIP")); c.Phone = dr.GetString(dr.GetOrdinal("Phone")); c.Fax = dr.GetString(dr.GetOrdinal("Fax")); c.Email = dr.GetString(dr.GetOrdinal("CompanyEmail")); c.UserName = dr.GetString(dr.GetOrdinal("UserName")); } dr.Close(); return c; } else { dr.Close(); return null; } }
public static MySearch GetMySearch(int mysearchid) { DBAccess db = new DBAccess(); db.AddParameter("@iMySearchID", mysearchid); SqlDataReader dr = (SqlDataReader)db.ExecuteReader("JobsDb_MySearches_SelectOne"); if (dr.HasRows) { MySearch s = new MySearch(); while (dr.Read()) { s.MySearchID = dr.GetInt32(dr.GetOrdinal("mysearchid")); s.Criteria = dr.GetString(dr.GetOrdinal("SearchCriteria")); s.CountryID = dr.GetInt32(dr.GetOrdinal("CountryID")); s.StateID = dr.GetInt32(dr.GetOrdinal("StateID")); s.City = dr.GetString(dr.GetOrdinal("City")); s.UserName = dr.GetString(dr.GetOrdinal("UserName")); } dr.Close(); return s; } else { return null; } }