예제 #1
0
        public ActionResult AddEmployee(emp_table model)      //emptable will bring the data from the form
        {
            emp_table obj = new emp_table();                  // add that data to table obj

            if (ModelState.IsValid)
            {
                obj.ID           = model.ID;
                obj.empName      = model.empName;
                obj.empFname     = model.empFname;
                obj.Email        = model.Email;
                obj.Mobile_Phone = model.Mobile_Phone;
                obj.Description  = model.Description;

                if (model.ID == 0)
                {
                    dbObj.emp_table.Add(obj);                                 // add the whole data to the database
                    dbObj.SaveChanges();
                }
                else
                {
                    dbObj.Entry(obj).State = EntityState.Modified;
                    dbObj.SaveChanges();
                }
            }
            ModelState.Clear();
            return(View("Employee"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            emp_table emp_table = db.emp_table.Find(id);

            db.emp_table.Remove(emp_table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "empID,empName,empAddress,empPhoneNo")] emp_table emp_table)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp_table).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp_table));
 }
        public ActionResult Create([Bind(Include = "empID,empName,empAddress,empPhoneNo")] emp_table emp_table)
        {
            if (ModelState.IsValid)
            {
                db.emp_table.Add(emp_table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emp_table));
        }
        // GET: emp_table/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            emp_table emp_table = db.emp_table.Find(id);

            if (emp_table == null)
            {
                return(HttpNotFound());
            }
            return(View(emp_table));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                emp_table e = new emp_table();

                e.empName    = collection["empName"];
                e.empAddress = collection["empAddress"];
                e.empPhoneNo = collection["empPhoneNo"];
                EmployeeEntities userRegistrationEntities = new EmployeeEntities();
                userRegistrationEntities.emp_table.Add(e);
                userRegistrationEntities.SaveChanges();
                return(RedirectToAction("Create"));
            }
            catch
            {
                return(View());
            }
        }
예제 #7
0
 // GET: Employee
 public ActionResult Employee(emp_table obj)
 {
     return(View(obj));
 }