public ActionResult Create([Bind(Include = "Eid,Ename,ESalary,Edepartment,Eorganisation")] tbl_Employee tbl_Employee) { if (ModelState.IsValid) { db.tbl_Employee.Add(tbl_Employee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Employee)); }
public string AddEmp(tbl_Employee tbl) { if (tbl != null) { using (var db = new RathnaEntities()) { db.tbl_Employee.Add(tbl); db.SaveChanges(); return("Employee Add Sucessfully"); } } else { return("Invalid Emp Details"); } }
public string DeleteEmp(tbl_Employee tbl) { if (tbl != null) { using (var db = new RathnaEntities()) { int no = Convert.ToInt32(tbl.Eid); var employeeList = db.tbl_Employee.Where(x => x.Eid == no).FirstOrDefault(); db.tbl_Employee.Remove(employeeList); db.SaveChanges(); return("Employee Deleted"); } } else { return("records not available"); } }
public string UpdateEmp(tbl_Employee tbl) { if (tbl != null) { using (var db = new RathnaEntities()) { int id = Convert.ToInt32(tbl.Eid); var q = (from s in db.tbl_Employee where s.Eid.Equals(id) select s).ToList(); q[0].Ename = tbl.Ename; q[0].Eorganisation = tbl.Eorganisation; q[0].Edepartment = tbl.Edepartment; q[0].ESalary = tbl.ESalary; db.SaveChanges(); return("Employee Updated"); } } else { return("Employee not Updated"); } }