/// <summary> /// 添加或编辑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static ResumeInfo Create(ResumeInfo model) { if (model.Id == 0) { int id = ResumeManage.Insert(model); model.Id = id; } else { //Update } return model; }
public ActionResult Apply(ResumeInfo model,FormCollection fc) { /* * 设置_CommmonLayout.cshtml中的变量 */ ViewBag.RootCategoryInfo = ViewBag.CurrentCategoryInfo = CategoryService.Get(GeneralConfig.JobRootId); int jobId = CECRequest.GetQueryInt("jobId",0); var jobInfo = JobService.Get(jobId); if(jobInfo.Id<=0){ return Redirect("/job"); } if(Request.HttpMethod.ToUpper() == "POST"){ //生日 model.Birthday = string.Format("{0}-{1}",fc["Year"],fc["Month"]); //籍贯 string birthplace = string.Empty; string province = fc["Province"],city = fc["City"],town = fc["Town"]; if(!string.IsNullOrEmpty(province)){ birthplace = province; if(!string.IsNullOrEmpty(city)){ birthplace += "-" + city; if(!string.IsNullOrEmpty(town)){ birthplace += "-" + town; } } } model.BirthPlace = birthplace; int id = ResumeService.Create(model).Id; bool status = false; if(id >0){ status = true; } //POST ViewBag.Status = status; } ViewBag.JobInfo = jobInfo; return View(model); }
/// <summary> /// 插入 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Insert(ResumeInfo model) { string strSQL = "INSERT INTO Resumes(Realname,Gender,Birthday,Email,[GUID],CreateDateTime,JobId,WorkExperience,Education,[Address],Phone,Family,Degree,Major,MaritalStatus,BirthPlace) VALUES(@RealName,@Gender,@Birthday,@Email,@GUID,GETDATE(),@JobId,@WorkExperience,@Education,@Address,@Phone,@Family,@Degree,@Major,@MaritalStatus,@BirthPlace);SELECT @@IDENTITY;"; SqlParameter[] param = { new SqlParameter("Realname",SqlDbType.NVarChar), new SqlParameter("Gender",SqlDbType.NVarChar), new SqlParameter("Birthday",SqlDbType.NVarChar), new SqlParameter("Email",SqlDbType.NVarChar), new SqlParameter("GUID",SqlDbType.NVarChar), new SqlParameter("JobId",SqlDbType.Int), new SqlParameter("WorkExperience",SqlDbType.NVarChar), new SqlParameter("Education",SqlDbType.NVarChar), new SqlParameter("Address",SqlDbType.NVarChar), new SqlParameter("Phone",SqlDbType.NVarChar), new SqlParameter("Family",SqlDbType.NVarChar), new SqlParameter("Degree",SqlDbType.NVarChar), new SqlParameter("Major",SqlDbType.NVarChar), new SqlParameter("MaritalStatus",SqlDbType.NVarChar), new SqlParameter("BirthPlace",SqlDbType.NVarChar), }; param[0].Value = model.Realname ?? string.Empty; param[1].Value = model.Gender ?? "男"; param[2].Value = model.Birthday ?? "1986-01-01"; param[3].Value = model.Email ?? string.Empty; param[4].Value = model.GUID ?? Guid.NewGuid().ToString(); param[5].Value = model.JobId; param[6].Value = model.WorkExperience ?? string.Empty; param[7].Value = model.Education ?? string.Empty; param[8].Value = model.Address ?? string.Empty; param[9].Value = model.Phone ?? string.Empty; param[10].Value = model.Family ?? string.Empty; param[11].Value = model.Degree ?? string.Empty; param[12].Value = model.Major ?? string.Empty; param[13].Value = model.MaritalStatus ?? string.Empty; param[14].Value = model.BirthPlace ?? string.Empty; return Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text,strSQL,param)); }