// GET: Contact public ActionResult ContactForm() { postjob p = new postjob(); List<postjob> Li = new List<postjob>(); Li = p.JobDisplay(); ViewData["JobDisplay"] = Li; //ViewBag.MyList = Li; return View(); }
public ActionResult DeleteJob(postjob f) { D.Open(); int i = D.DataDelete("DELETE FROM Job_table WHERE Name= '" + f.Name + "' "); D.Close(); if (i > 0) { ModelState.AddModelError("Success", "Save Success"); } else { ModelState.AddModelError("Error", "Save Error"); } return RedirectToAction("Index", "Dashboard"); }
public List<postjob> JobDisplay() { SqlConnection con = new SqlConnection(constr); con.Open(); using (con) { SqlCommand cmd = new SqlCommand("Select * from Job_table ", con); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { p = new postjob(); p.Name = Convert.ToString(rd.GetSqlValue(1)); p.Req = Convert.ToString(rd.GetSqlValue(2)); p.Des = Convert.ToString(rd.GetSqlValue(3)); Jobs.Add(p); } return Jobs; } }
public ActionResult SaveJob(postjob f) { if (ModelState.IsValid) { D.Open(); int i = D.DataInsert("INSERT INTO Job_table(Name,Req,Gen) VALUES ('" + f.Name + "','" + f.Req + "','" + f.Des + "')"); if (i > 0) { ModelState.AddModelError("Success", "Save Success"); } else { ModelState.AddModelError("Error", "Save Error"); } D.Close(); } return RedirectToAction("Index", "Dashboard"); }
// GET: Dashboard public ActionResult Index() { postjob p = new postjob(); List<postjob> Li = new List<postjob>(); Li = p.JobDisplay(); ViewData["JobDisplay"] = Li; return View(); }