public ActionResult Delete(Zone zones) { int id = Int32.Parse(RouteData.Values["id"].ToString()); if (!ModelState.IsValid) return View(); try { ZONE _zone = new ZONE(); _zone.SetId(id); _zone.Delete(); return RedirectToAction("../Zone/Index");//reafficher l liste } catch { return View(); } }
public static List<ZONE> GetList() { List<ZONE> _list= new List<ZONE>(); SqlDataReader dr = null; ZONE var = null; SqlParameter id_auto=new SqlParameter ("@ID_AUTO","0"); try { dr = SqlHelper.ExecuteReader(Connexion.Cnx, "SPGETLIST_ZONE" ,id_auto); while (dr.Read()) { var=new ZONE(); var.SetId(dr.GetInt32(dr.GetOrdinal("ID_AUTO"))); var.NOM = dr.GetString(dr.GetOrdinal("NOM")); if ( DBNull.Value!= dr["CONTROLLER"]) var.CONTROLEUR = dr.GetString(dr.GetOrdinal("CONTROLLER")); else var.CONTROLEUR=string.Empty; if (DBNull.Value != dr["ID_CONTROLER"]) var.ID_CONTROLER = dr.GetInt32(dr.GetOrdinal("ID_CONTROLER")); else var.ID_CONTROLER = 0; _list.Add(var); } return _list; } catch (SqlException ex) { throw ex; } finally { dr.Close(); } }
public ActionResult Edit(Zone zones) { int id = Int32.Parse(RouteData.Values["id"].ToString()); if (!ModelState.IsValid) return View(); try { ZONE _zone = new ZONE(); _zone.NOM = zones.NOM; _zone.CONTROLEUR = zones.CONTROLEUR; _zone.ID_CONTROLER = zones.ID_CONT; _zone.SetId(id); _zone.Save(); return RedirectToAction("../Zone/Index"); } catch { return View(); } }