コード例 #1
0
        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));
        }
コード例 #2
0
 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");
     }
 }
コード例 #3
0
 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");
     }
 }
コード例 #4
0
 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");
     }
 }