/// <summary> /// 更新一条简历 /// </summary> /// <param name="r"></param> /// <returns></returns> public static int Update(Resume r) { DBAccess db = new DBAccess(); db.AddParameter("@iResumeID", r.ResumeID); db.AddParameter("@sJobTitle", r.JobTitle); db.AddParameter("@sTargetCity", r.City); db.AddParameter("@iTargateStateID", r.StateID); db.AddParameter("@iTargetCountryID", r.CountryID); db.AddParameter("@iRelocationCountryID", r.RelocationCountryID); db.AddParameter("@iTargetJobTypeID", r.JobTypeID); db.AddParameter("@iEducationLevelID", r.EducationLevelID); db.AddParameter("@iExperienceLevelID", r.ExperienceLevelID); db.AddParameter("@sResumeText", r.ResumeText); db.AddParameter("@sCoverLetterText", r.CoveringLetterText); db.AddParameter("@sUserName", r.UserName); db.AddParameter("@dtPostDate", r.PostedDate); return db.ExecuteNonQuery("JobsDb_Resumes_Update"); }
/// <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="r"></param> /// <returns></returns> public static int Insert(Resume r) { DBAccess db = new DBAccess(); db.AddParameter("@sJobTitle", r.JobTitle); db.AddParameter("@sTargetCity", r.City); db.AddParameter("@iTargateStateID", r.StateID); db.AddParameter("@iTargetCountryID", r.CountryID); db.AddParameter("@iRelocationCountryID", r.RelocationCountryID); db.AddParameter("@iTargetJobTypeID", r.JobTypeID); db.AddParameter("@iEducationLevelID", r.EducationLevelID); db.AddParameter("@iExperienceLevelID", r.ExperienceLevelID); db.AddParameter("@sResumeText", r.ResumeText); db.AddParameter("@sCoverLetterText", r.CoveringLetterText); db.AddParameter("@sUserName", r.UserName); db.AddParameter("@dtPostDate", r.PostedDate); SqlParameter p=new SqlParameter("@iResumeID",SqlDbType.Int); p.Direction=ParameterDirection.Output; db.AddParameter(p); int retval=db.ExecuteNonQuery("JobsDb_Resumes_Insert"); if (retval <= 0) { return -1; } else { return (int)p.Value; } }
/// <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; } }