public ActionResult Create(componentClass Obj_component, string command) { using (componentCtl db = new componentCtl()){ if (ModelState.IsValid) { db.insert(Obj_component); if (command.ToLower().Trim() == "save") { string sesionval = Convert.ToString(Session["CreatePreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("CreatePreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } else { ModelState.Clear(); return(View()); } } return(View(Obj_component)); } }
public ActionResult Edit(Int32 Componentid) { using (componentCtl db = new componentCtl()){ componentClass obj_component = db.selectById(Componentid); Session["EditPreviousURL"] = Convert.ToString(ControllerContext.HttpContext.Request.UrlReferrer); return(View(obj_component)); } }
public ActionResult Edit(componentClass Obj_component) { using (componentCtl db = new componentCtl()){ if (ModelState.IsValid) { db.update(Obj_component); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_component)); } }
public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (componentCtl db = new componentCtl()){ var ComponentidArray = model.GetValues("item.Componentid"); var ComponentnameArray = model.GetValues("item.Componentname"); for (Int32 i = 0; i < ComponentidArray.Length; i++) { componentClass obj_update = db.selectById(Convert.ToInt32(ComponentidArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(ComponentidArray))) { obj_update.Componentid = Convert.ToInt32(ComponentidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(ComponentnameArray))) { obj_update.Componentname = Convert.ToString(ComponentnameArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }
public ActionResult Details(Int32 Componentid) { using (componentCtl db = new componentCtl()){ componentClass obj_component = db.selectById(Componentid); return(View(obj_component)); } }