/// <summary> /// 删除公司 /// </summary> /// <param name="CId"></param> /// <returns></returns> public IActionResult DeleteCompany(string CId) { string cid = System.Web.HttpUtility.UrlDecode(CId); using (var dbContext = new parttimejobContext()) { var company = dbContext.Company.FirstOrDefault(m => m.CId == cid); List <Recruit> recruits = dbContext.Recruit.ToList(); recruits = (from a in recruits where a.CId == company.CId select a).ToList(); foreach (Recruit i in recruits) { dbContext.Recruit.Remove(i); } dbContext.SaveChanges(); var info = dbContext.Companyinfo.FirstOrDefault(e => e.CId == company.CId); if (info != null) { dbContext.Companyinfo.Remove(info); dbContext.SaveChanges(); } dbContext.Company.Remove(company); dbContext.SaveChanges(); return(View("CompanyInfo", CompanyList())); } }
/// <summary> /// 删除个人 /// </summary> /// <param name="PId"></param> /// <returns></returns> public IActionResult DeletePerson(string PId) { string pid = System.Web.HttpUtility.UrlDecode(PId); using (var dbContext = new parttimejobContext()) { var person = dbContext.Person.FirstOrDefault(m => m.PId == pid); List <Recruit> recruits = dbContext.Recruit.ToList(); recruits = (from a in recruits where a.PId == person.PId select a).ToList(); foreach (Recruit i in recruits) { dbContext.Recruit.Remove(i); } dbContext.SaveChanges(); var info = dbContext.Personinfo.FirstOrDefault(e => e.PId == person.PId); if (info != null) { dbContext.Personinfo.Remove(info); dbContext.SaveChanges(); } dbContext.Person.Remove(person); dbContext.SaveChanges(); var script = String.Format("<script>alert('success');location.href = '{0}'</script>", Url.Action("PersonInfo")); return(Content(script, "text/html")); //return View("PersonInfo", PersonList()); } }
/// <summary> /// 删除应聘者 /// </summary> /// <param name="AId"></param> /// <returns></returns> public IActionResult DeleteApplicant(string AId) { string aid = System.Web.HttpUtility.UrlDecode(AId); using (var dbContext = new parttimejobContext()) { var applicant = dbContext.Applicant.FirstOrDefault(m => m.AId == aid); List <Intention> intentions = dbContext.Intention.ToList(); intentions = (from a in intentions where a.AId == applicant.AId select a).ToList(); foreach (Intention i in intentions) { dbContext.Intention.Remove(i); } dbContext.SaveChanges(); var info = dbContext.Applicantinfo.FirstOrDefault(e => e.AId == applicant.AId); if (info != null) { dbContext.Applicantinfo.Remove(info); dbContext.SaveChanges(); } dbContext.Applicant.Remove(applicant); dbContext.SaveChanges(); return(View("ApplicantInfo", ApplicantList())); } }
/// <summary> /// 编辑应聘方信息 /// </summary> /// <returns></returns> public IActionResult Applicanti(string aname, string asex, string anumber, string acollege, string amajor, string askill, string ahobby, string atel, string aaddress, string aemail, string aexper, string aremark, string alanguage) { using (parttimejobContext db = new parttimejobContext()) { Applicantinfo ainfo = db.Applicantinfo.FirstOrDefault(x => x.AId == common.key); if (ainfo == null) { Applicantinfo ainfo1 = new Applicantinfo(); ainfo1.AId = common.key; ainfo1.AName = aname; ainfo1.ASex = asex; ainfo1.ANumber = anumber; ainfo1.ACollege = acollege; ainfo1.AMajor = amajor; ainfo1.ATel = atel; ainfo1.AAddress = aaddress; ainfo1.AEmail = aemail; ainfo1.AHobby = ahobby; ainfo1.ASkill = askill; ainfo1.ARemark = aremark; ainfo1.AExper = aexper; ainfo1.ALanguage = alanguage; if (ainfo1.AName == null) { var script = String.Format("<script>alert('Save failed,fill in blanks!!!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script, "text/html")); } db.Add(ainfo1); db.SaveChanges(); var script1 = String.Format("<script>alert('Save successfully!!!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script1, "text/html")); //ViewData["error"] = "提示:修改成功"; } else { ainfo.AName = aname; ainfo.ASex = asex; ainfo.ANumber = anumber; ainfo.ACollege = acollege; ainfo.AMajor = amajor; ainfo.ATel = atel; ainfo.AAddress = aaddress; ainfo.AEmail = aemail; ainfo.AHobby = ahobby; ainfo.ASkill = askill; ainfo.ARemark = aremark; ainfo.AExper = aexper; ainfo.ALanguage = alanguage; db.SaveChanges(); var script = String.Format("<script>alert('Change successfully!!!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script, "text/html")); //ViewData["error"] = "提示:修改成功"; } } }
/// <summary> /// 修改密码 /// </summary> /// <returns></returns> public IActionResult ChangePwd(string old, string new1, string new2) { using (var db = new parttimejobContext()) { var cp = db.Person.Single(b => b.PId == common.key); if (old == cp.PPassword) { if (new1 == new2 && new1 != null) { cp.PPassword = new1; db.SaveChanges(); var script = String.Format("<script>alert('Successfully!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script, "text/html")); } else { var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script, "text/html")); } } else { var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script, "text/html")); } } }
public IActionResult ViewApplicantSend(IFormCollection collection) { using (var db = new parttimejobContext()) { var appinfo = db.Applicantinfo.FirstOrDefault(a => a.AId == common.key); if (appinfo == null) { var script = String.Format("<script>alert('Your information is not found!');location.href = '{0}'</script>", Url.Action("ViewApplicant")); return(Content(script, "text/html")); //return RedirectToAction("ViewApplicant"); } else { string id = collection["RId"]; var Res = db.Recruit.FirstOrDefault(b => b.RId == id); var ApplicantId = db.Applicant.FirstOrDefault(b => b.AId == common.key); var TempIntention = new Intention(); TempIntention.AId = ApplicantId.AId; TempIntention.RId = Res.RId; TempIntention.IStatus = "确认中"; string date = DateTime.Now.ToLocalTime().ToString(); DateTime date1 = Convert.ToDateTime(date); TempIntention.ICreateTime = date1; db.Intention.Add(TempIntention); db.SaveChanges(); var script = String.Format("<script>alert('Your application has been sent!');location.href = '{0}'</script>", Url.Action("ViewApplicant")); return(Content(script, "text/html")); } } }
/// <summary> /// 解封/封禁个人 /// </summary> /// <param name="PId"></param> /// <returns></returns> public IActionResult UpdatePStatus(string PId) { string pid = System.Web.HttpUtility.UrlDecode(PId); using (var dbContext = new parttimejobContext()) { var person = dbContext.Person.FirstOrDefault(m => m.PId == pid); if (person != null) { if (person.PStatus == 0) { person.PStatus = 1; } else if (person.PStatus == 1) { person.PStatus = 0; } dbContext.Person.Update(person); dbContext.SaveChanges(); var script = String.Format("<script>alert('success');location.href = '{0}'</script>", Url.Action("PersonInfo")); return(Content(script, "text/html")); //return View("PersonInfo", PersonList()); } else { var script = String.Format("<script>alert('fail');location.href = '{0}'</script>", Url.Action("PersonInfo")); return(Content(script, "text/html")); } } }
/// <summary> /// 封禁/解封公司 /// </summary> /// <param name="CId"></param> /// <returns></returns> public IActionResult UpdateCStatus(string CId) { string cid = System.Web.HttpUtility.UrlDecode(CId); using (var dbContext = new parttimejobContext()) { var company = dbContext.Company.FirstOrDefault(m => m.CId == cid); if (company != null) { if (company.CStatus == 0) { company.CStatus = 1; } else if (company.CStatus == 1) { company.CStatus = 0; } dbContext.Company.Update(company); dbContext.SaveChanges(); var script = String.Format("<script>alert('success');location.href = '{0}'</script>", Url.Action("CompanyInfo")); return(Content(script, "text/html")); //return View("CompanyInfo", CompanyList()); } else { var script = String.Format("<script>alert('fail');location.href = '{0}'</script>", Url.Action("CompanyInfo")); return(Content(script, "text/html")); } } }
/// <summary> /// 封禁/解封应聘者 /// </summary> /// <param name="AId"></param> /// <returns></returns> public IActionResult UpdateAStatus(string AId) { string aid = System.Web.HttpUtility.UrlDecode(AId); using (var dbContext = new parttimejobContext()) { var applicant = dbContext.Applicant.FirstOrDefault(m => m.AId == aid); if (applicant != null) { if (applicant.AStatus == 0) { applicant.AStatus = 1; } else if (applicant.AStatus == 1) { applicant.AStatus = 0; } dbContext.Applicant.Update(applicant); dbContext.SaveChanges(); var script = String.Format("<script>alert('success');location.href = '{0}'</script>", Url.Action("ApplicantInfo")); return(Content(script, "text/html")); //return View("ApplicantInfo", ApplicantList()); } else { var script = String.Format("<script>alert('fail');location.href = '{0}'</script>", Url.Action("ApplicantInfo")); return(Content(script, "text/html")); } } }
public IActionResult changePwd(String DPassword, String NewDPassword, String NewDPassword1) { if (NewDPassword != NewDPassword1) { ViewData["error"] = "两次密码不相同"; return(View("ChangePassword")); } using (var context = new parttimejobContext()) { Admin ad = context.Admin.FirstOrDefault(m => m.DId == common.key); if (ad == null) { ViewData["error"] = "用户名不存在"; return(View("ChangePassword")); } if (ad.DPassword == DPassword && NewDPassword != null && NewDPassword != "") { ad.DPassword = NewDPassword; context.Admin.Update(ad); context.SaveChanges(); ViewData["error"] = "修改成功"; return(View("ChangePassword")); } else { ViewData["error"] = "密码不对"; return(View("ChangePassword")); } } }
public IActionResult Applicantpwf(string old, string new1, string new2) { using (var db = new parttimejobContext()) { var App = db.Applicant.FirstOrDefault(b => b.AId == common.key); if (old == App.APassword) { if (new1 == new2 && new1 != null) { App.APassword = new1; db.SaveChanges(); var script = String.Format("<script>alert('Successfully!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script, "text/html")); } else { //ViewData["error1"] = "警告:两次密码输入不一致或为空,请重新输入"; var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script, "text/html")); } } else { //ViewData["error1"] = "警告:旧密码不正确,请重新输入"; var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Applicants")); return(Content(script, "text/html")); } } }
/// <summary> /// 修改密码 /// </summary> /// <returns></returns> public IActionResult ChangePwd(string old, string new1, string new2) { using (var db = new parttimejobContext()) { var cp = db.Company.Single(b => b.CId == common.key); if (old == cp.CPassword) { if (new1 == new2 && new1 != null) { cp.CPassword = new1; db.SaveChanges(); var script = String.Format("<script>alert('Successfully!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } else { //ViewData["error"] = "警告:两次密码输入不一致,请重新输入"; var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } } else { //ViewData["error"] = "警告:旧密码不正确,请重新输入"; //return View("Companypw", "Company"); var script = String.Format("<script>alert('Failed!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } } }
/// <summary> /// 发布招聘信息 /// </summary> /// <returns></returns> public IActionResult Recruit(DateTime rstartdate, DateTime renddate, string raddress, string rtype, string rsalary, string rpeople, string rtel, string rrequire, string rdescribe) { using (parttimejobContext db = new parttimejobContext()) { int randomnumber = new Random().Next(); string b = randomnumber.ToString(); Recruit rinfo = new Recruit(); rinfo.RId = b; rinfo.CId = common.key; rinfo.PId = ""; rinfo.RStartDate = rstartdate; rinfo.REndDate = renddate; rinfo.RAddress = raddress; rinfo.RType = rtype; rinfo.RSalary = rsalary; rinfo.RPeople = rpeople; rinfo.RTel = rtel; rinfo.RDescribe = rdescribe; rinfo.RRequire = rrequire; System.DateTime dt = new System.DateTime(); dt = System.DateTime.Now; rinfo.RCreatTime = dt; if (rinfo.RAddress == null) { var script = String.Format("<script>alert('Publish failed,fill in blanks');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } db.Add(rinfo); db.SaveChanges(); var script1 = String.Format("<script>alert('Publish successfully!!!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script1, "text/html")); } }
// GET: /<controller>/ /// <summary> /// 显示公司信息管理 /// </summary> /// <returns></returns> public IActionResult Personinfo(string pname, string psex, string paddress, string premark, string pnumber, string ptel) { using (parttimejobContext db = new parttimejobContext()) { Personinfo cinfo = db.Personinfo.FirstOrDefault(x => x.PId == common.key); if (cinfo == null) { Personinfo cinfor = new Personinfo(); cinfor.PId = common.key; cinfor.PSex = psex; cinfor.PName = pname; cinfor.PAddress = paddress; cinfor.CRemark = premark; cinfor.PNumber = pnumber; cinfor.PTel = ptel; if (cinfor.PName == null) { var script = String.Format("<script>alert('Save failed,fill in blanks');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script, "text/html")); } db.Add(cinfor); db.SaveChanges(); var script1 = String.Format("<script>alert('Save successfully!!!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script1, "text/html")); } else { cinfo.PSex = psex; cinfo.PName = pname; cinfo.PAddress = paddress; cinfo.CRemark = premark; cinfo.PNumber = pnumber; cinfo.PTel = ptel; db.SaveChanges(); var script1 = String.Format("<script>alert('Change successfully!!!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script1, "text/html")); } } }
// GET: /<controller>/ /// <summary> /// 显示公司信息管理 /// </summary> /// <returns></returns> public IActionResult Companyinfo(string cname, string cindustry, string caddress, string cremark, string csize, string ctel) { using (parttimejobContext db = new parttimejobContext()) { Companyinfo cinfo = db.Companyinfo.FirstOrDefault(x => x.CId == common.key); if (cinfo == null) { Companyinfo cinfor = new Companyinfo(); cinfor.CId = common.key; cinfor.CIndustry = cindustry; cinfor.CName = cname; cinfor.CAddress = caddress; cinfor.CRemark = cremark; cinfor.CSize = csize; cinfor.CTel = ctel; if (cinfor.CName == null) { var script = String.Format("<script>alert('Save failed,fill in blanks');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } db.Add(cinfor); db.SaveChanges(); var script1 = String.Format("<script>alert('Save successfully!!!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script1, "text/html")); } else { cinfo.CIndustry = cindustry; cinfo.CName = cname; cinfo.CAddress = caddress; cinfo.CRemark = cremark; cinfo.CSize = csize; cinfo.CTel = ctel; db.SaveChanges(); var script1 = String.Format("<script>alert('Change successfully!!!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script1, "text/html")); } } }
public IActionResult ViewAdminDelete(IFormCollection collection) { using (var db = new parttimejobContext()) { //var id = System.Web.HttpUtility.UrlDecode(RId); //var id = Request.Form["RId"].ToString(); //var id = request["id"]; string id = collection["RId"]; var Res = db.Recruit.FirstOrDefault(b => b.RId == id); db.Remove(Res); db.SaveChanges(); var script = String.Format("<script>alert('Delete Successful!');location.href = '{0}'</script>", Url.Action("ViewAdmin")); return(Content(script, "text/html")); } }
/// <summary> /// 个人删除招聘信息 /// </summary> /// <param name="collection"></param> /// <returns></returns> public IActionResult PDelete(string RId) { using (var db = new parttimejobContext()) { //var id = System.Web.HttpUtility.UrlDecode(RId); //var id = Request.Form["RId"].ToString(); //var id = request["id"]; string id = System.Web.HttpUtility.UrlDecode(RId); List <Intention> intentions = db.Intention.ToList(); intentions = (from a in intentions where a.RId == id select a).ToList(); foreach (var i in intentions) { db.Intention.Remove(i); } var Res = db.Recruit.FirstOrDefault(b => b.RId == id); db.Remove(Res); db.SaveChanges(); var script = String.Format("<script>alert('success');location.href = '{0}'</script>", Url.Action("PRecruitList") + "?PId=" + System.Web.HttpUtility.UrlEncode(Res.PId)); return(Content(script, "text/html")); //return RedirectToAction("PRecruit"); } }
public IActionResult Persons(string flag, IFormCollection coll) { using (parttimejobContext db = new parttimejobContext()) { var x = db.Recruit.Where(b => b.PId == common.key).ToList(); ViewBag.a = x; string id = coll["RId"]; if (flag == "no") { var rinfo = db.Recruit.FirstOrDefault(b => b.RId == id); db.Remove(rinfo); db.SaveChanges(); var script = String.Format("<script>alert('Successfully!');location.href = '{0}'</script>", Url.Action("Persons")); return(Content(script, "text/html")); } else { } var cinfo = db.Personinfo.FirstOrDefault(b => b.PId == common.key); if (cinfo == null) { ViewData["error"] = "提示:您还没有完善信息,请点击个人信息编辑完善"; return(View()); } else { ViewData["pname"] = cinfo.PName; ViewData["psex"] = cinfo.PSex; ViewData["paddress"] = cinfo.PAddress; ViewData["pnumber"] = cinfo.PNumber; ViewData["premark"] = cinfo.CRemark; ViewData["ptel"] = cinfo.PTel; return(View()); } } }
public IActionResult Companys(string flag, IFormCollection coll) { using (parttimejobContext db = new parttimejobContext()) { var x = db.Recruit.Where(b => b.CId == common.key).ToList(); ViewBag.a = x; string id = coll["RId"]; if (flag == "no") { var rinfo = db.Recruit.FirstOrDefault(b => b.RId == id); db.Remove(rinfo); db.SaveChanges(); var script = String.Format("<script>alert('Successfully!');location.href = '{0}'</script>", Url.Action("Companys")); return(Content(script, "text/html")); } else { } var cinfo = db.Companyinfo.FirstOrDefault(b => b.CId == common.key); if (cinfo == null) { ViewData["error"] = "提示:您还没有完善信息,请点击公司信息编辑完善"; return(View("Companys")); } else { ViewData["cname"] = cinfo.CName; ViewData["cindustry"] = cinfo.CIndustry; ViewData["caddress"] = cinfo.CAddress; ViewData["csize"] = cinfo.CSize; ViewData["cremark"] = cinfo.CRemark; ViewData["ctel"] = cinfo.CTel; return(View("Companys")); } } }
public IActionResult Register1(string username, string password1, string password2, string status) { if (password1 == password2) { if (status == "student") { using (var db = new parttimejobContext()) { var applicant = db.Applicant.FirstOrDefault(b => b.AId == username); if (applicant == null) { using (parttimejobContext app = new parttimejobContext()) { Applicant ainfo = new Applicant(); ainfo.AId = username; ainfo.APassword = password1; ainfo.AStatus = 0; db.Add(ainfo); db.SaveChanges(); } return(View("Login", "Home")); } else { ViewData["error"] = "提示:此用户名已存在,请重新输入"; return(View("register", "Home")); } } } else if (status == "company") { using (var db = new parttimejobContext()) { var company = db.Company.FirstOrDefault(b => b.CId == username); if (company == null) { using (parttimejobContext app = new parttimejobContext()) { Company ainfo = new Company(); ainfo.CId = username; ainfo.CPassword = password1; ainfo.CStatus = 0; db.Add(ainfo); db.SaveChanges(); } return(View("Login", "home")); } else { ViewData["error"] = "提示:此用户名已存在,请重新输入"; return(View("register", "home")); } } } else if (status == "person") { using (var db = new parttimejobContext()) { var person = db.Person.FirstOrDefault(b => b.PId == username); if (person == null) { using (parttimejobContext app = new parttimejobContext()) { Person ainfo = new Person(); ainfo.PId = username; ainfo.PPassword = password1; ainfo.PStatus = 0; db.Add(ainfo); db.SaveChanges(); } return(View("Login", "home")); } else { ViewData["error"] = "提示:此用户名已存在,请重新输入"; return(View("register", "home")); } } } else { ViewData["error"] = "提示:请选择注册人员类别"; return(View("register", "home")); } } else { ViewData["error"] = "提示:两次密码输入不一致"; return(View("register", "home")); } }