Example #1
0
        //
        // GET: /Zone/

        public ActionResult Index()
        {
            ZONE _zone = new ZONE();
            List<Zone> _list = new List<Zone>(); ;
            foreach (ZONE item in ZONE.GetList())
            {
                Zone zones = new Zone();
                zones.NOM = item.NOM;
                zones.CONTROLEUR = item.CONTROLEUR;
                zones.ID_CONT = item.ID_CONTROLER;
                zones.ID_AUTO = item.ID_AUTO;
                _list.Add(zones);
            }

            return View(_list);
        }
Example #2
0
        //
        // GET: /Zone/Edit/5
 
        public ActionResult Edit()
        {
            Zone zones = new Zone();
            ZONE _zone = new ZONE();

            int id = Int32.Parse(RouteData.Values["id"].ToString());

            _zone.LoadId(id);
            zones.NOM = _zone.NOM;
            zones.CONTROLEUR = _zone.CONTROLEUR;

            IEnumerable<SelectListItem> list = ToSelectListItems();
            list.ToList().Find(x => x.Text.Equals(zones.CONTROLEUR)).Selected = true;
           ViewData["ID_CONT"] = list;

            return View(zones);
        }
Example #3
0
        public ActionResult Create(Zone zonesToCreate)
        {
            if (!ModelState.IsValid)
                return View();

            try
            {
                ZONE _zone = new ZONE();
                _zone.NOM = zonesToCreate.NOM;
                _zone.ID_CONTROLER = zonesToCreate.ID_CONT;
                _zone.Save();
                return RedirectToAction("../Zone/Index");
            }
            catch
            {
                return View();
            }
        }
Example #4
0
		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();
			}
		}
Example #5
0
        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();
            }
        }
Example #6
0
        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();
            }
        }