public async Task <IActionResult> Edit(long id, [Bind("Id,NomAgence,Adresse,codeAgence,Pays,Region")] Agence agence)
        {
            if (id != agence.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgenceExists(agence.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(agence));
        }
Exemple #2
0
 public static bool CreateAgence(Agence agence, RegistryKey Nkey)
 {
     try
     {
         if (agence != null)
         {
             RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
             if (valKey == null)
             {
                 Nkey.CreateSubKey(@chemin);
                 valKey = Nkey.OpenSubKey(@chemin, true);
             }
             valKey.SetValue("id", agence.Id);
             valKey.SetValue("name", agence.Name);
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         Messages.Exception("AgenceDAO (CreateAgence) ", e);
         return(false);
     }
     finally
     {
         Nkey.Close();
     }
 }
Exemple #3
0
        public Agence AddAgence_(Agence a)
        {
            var result = mos_Communes_DbContext.Agences.Add(a);

            mos_Communes_DbContext.SaveChanges();
            return(result.Entity);
        }
        private List <Agence> RecupererlisteAgence()
        {
            // Création de la connecion
            var connectionString = Menu.GetConnexion();


            //Méthode condensée
            using (var connexion = Menu.GetConnexion())
            {
                // création d'une commande SQL
                var commande    = new SqlCommand("SELECT* FROM Agences ", connexion);
                var listeAgence = new List <Agence>();

                // Mode connecté
                connexion.Open();
                using (var dataReader = commande.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        var indexColonneVille   = dataReader.GetOrdinal("Ville");
                        var indexColonneAdresse = dataReader.GetOrdinal("Adresse");
                        var agence = new Agence
                        {
                            Ville   = dataReader.GetString(indexColonneVille),
                            Adresse = dataReader.GetString(indexColonneAdresse)
                        };
                        listeAgence.Add(agence);
                    }

                    connexion.Close();
                    return(listeAgence);
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Agent agent = unitOfWork.AgentRepository.ObtenirAgentParID(id);

            Agence age = unitOfWork.AgenceRepository.ObtenirAgenceParID(agent.AgenceId);

            if (age != null)
            {
                age.Agents.Remove(agent);
                unitOfWork.AgenceRepository.Update(age);
            }

            IEnumerable <Seance> seancesDagent = unitOfWork.SeanceRepository.ObtenirSeanceParAgent(agent.AgentId);

            foreach (Seance sea in seancesDagent)
            {
                sea.AgentId = null;
                sea.Agent   = null;

                unitOfWork.SeanceRepository.Update(sea);
            }

            unitOfWork.AgentRepository.DeleteAgent(agent);
            unitOfWork.Save();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public async Task <IActionResult> PutAgence(int id, Agence agence)
        {
            if (id != agence.AgenceId)
            {
                return(BadRequest());
            }

            _context.Entry(agence).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AgenceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #7
0
        // GET: Agence/Details/5
        public ActionResult Details(int?id)
        {
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Dictionary <String, String> data = new Dictionary <string, string>();

            data["NumeroAgence"] = "" + id;
            Agence ag = new Agence();

            ag = ag.find_by_id(data);


            if (ag == null)
            {
                return(HttpNotFound());
            }
            return(View(ag));
        }
Exemple #8
0
        public ActionResult Delete(int?id, FormCollection collection)
        {
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if ((Session["user"] as Utilisateur).EtatUser != "Superviseur")
            {
                return(RedirectToAction("InvalidAccess", "Home"));
            }

            try
            {
                Dictionary <String, String> data = new Dictionary <string, string>();
                data["NumeroAgence"] = "" + id;

                Agence ag = new Agence();
                ag = ag.find_by_id(data);
                ag.remove(data);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #9
0
        public static Agence getOneById(int id)
        {
            Agence           bean    = new Agence();
            NpgsqlConnection connect = new Connexion().Connection();

            try
            {
                string           query = "select * from yvs_agences where id =" + id + ";";
                NpgsqlCommand    Lcmd  = new NpgsqlCommand(query, connect);
                NpgsqlDataReader lect  = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        bean = Return(lect);
                    }
                }
                return(bean);
            }
            catch (Exception ex)
            {
                Messages.Exception("AgenceDao (getOneById) ", ex);
                return(bean);
            }
            finally
            {
                Connexion.Close(connect);
            }
        }
Exemple #10
0
 public static Agence ReturnAgence(RegistryKey Nkey)
 {
     try
     {
         Agence      agence = new Agence();
         RegistryKey valKey = Nkey.OpenSubKey(@chemin, true);
         if (valKey == null)
         {
             agence.Id   = 0;
             agence.Name = "DIRECTION";
             CreateAgence(agence);
         }
         else
         {
             agence.Id   = Convert.ToInt32(valKey.GetValue("id") != null ? valKey.GetValue("id") : 0);
             agence.Name = (string)(valKey.GetValue("name") != null ? valKey.GetValue("name") : "");
             valKey.Close();
         }
         return(agence);
     }
     catch (Exception e)
     {
         Messages.Exception("AgenceDAO (ReturnAgence) ", e);
         return(null);
     }
     finally
     {
         Nkey.Close();
     }
 }
Exemple #11
0
        public ActionResult Create(Agence agence, DRE dre)
        {
            //[Bind(Include = "idag,nomag,wilayaag,addressag,iddre")]
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if ((Session["user"] as Utilisateur).EtatUser != "Superviseur")
            {
                return(RedirectToAction("InvalidAccess", "Home"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    agence.Dre = dre;
                    agence.save();
                    return(RedirectToAction("index"));
                }
            }
            catch
            {
            }

            return(View());
        }
Exemple #12
0
        public ActionResult Create(EmployeAgence employeAgence, Agence agence)
        {
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if ((Session["user"] as Utilisateur).EtatUser != "Superviseur")
            {
                return(RedirectToAction("InvalidAccess", "Home"));
            }

            try
            {
                employeAgence.agence = agence;
                employeAgence.save();
            }
            catch
            {
            }
            if (ModelState.IsValid)
            {
                return(RedirectToAction("index"));
            }
            return(View());
        }
Exemple #13
0
        public async Task <ActionResult <Agence> > PostAgence(Agence agence)
        {
            _context.Agence.Add(agence);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAgence", new { id = agence.AgenceId }, agence));
        }
Exemple #14
0
        // GET: Agence/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["user"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if ((Session["user"] as Utilisateur).EtatUser != "Superviseur")
            {
                return(RedirectToAction("InvalidAccess", "Home"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dictionary <String, String> data = new Dictionary <string, string>();

            data["[NumeroAgence]"] = "" + id;
            Agence ag = new Agence();

            ag = ag.find_by_id(data);
            if (ag == null)
            {
                return(HttpNotFound());
            }
            return(View(ag));
        }
Exemple #15
0
        public IHttpActionResult PutAgence(int id, Agence agence)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != agence.ID)
            {
                return(BadRequest());
            }

            db.Entry(agence).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AgenceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #16
0
 public Agence SaveAgence(Agence a)
 {
     a.HeureOuverture = new DateTime();
     a.HeureFermeture = new DateTime();
     _context.Agences.Add(a);
     Save();
     return(a);
 }
Exemple #17
0
        public async Task <Agence> AddAgence(Agence a)
        {
            var result = await mos_Communes_DbContext.Agences.AddAsync(a);

            await mos_Communes_DbContext.SaveChangesAsync();

            return(result.Entity);
        }
        // GET: Compte/Details/5
        public ActionResult Details()
        {
            Agence a1 = ass.GetById(2);


            ViewBag.nbr = cs.ClientNumbers(a1);
            return(View());
        }
Exemple #19
0
 public static void Ajouter(this Agence agence)
 {
     using (var bd = Application.GetBaseDonnees())
     {
         bd.Agences.Add(agence);
         bd.SaveChanges();
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Agence agence = db.Agences.Find(id);

            db.Agences.Remove(agence);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #21
0
        protected void btnSupprimer_Click(object sender, EventArgs e)
        {
            int?   id = int.Parse(gvAgence.SelectedRow.Cells[1].Text);
            Agence a  = db.Agence.Find(id);

            db.Agence.Remove(a);
            db.SaveChanges();
            Server.Transfer("~/Adminstration/frmAgence.aspx");
        }
Exemple #22
0
        private static Agence Return(NpgsqlDataReader lect)
        {
            Agence bean = new Agence();

            bean.Id      = Convert.ToInt32(lect["id"].ToString());
            bean.Name    = lect["designation"].ToString();
            bean.Societe = new Societe(Convert.ToInt32(lect["societe"].ToString()));
            return(bean);
        }
Exemple #23
0
        public List <String> rechercher(DateTime arrivee, DateTime depart, int prixMin, int prixMax, int nbDePersonnes, string id, string mdp)
        {
            List <String> resu = new List <String>();
            Agence        a    = null;

            foreach (Agence b in agence)
            {
                if (b.getID() == id)
                {
                    if (b.getMDP() == mdp)
                    {
                        a = b;
                    }
                }
            }

            if (a != null)
            {
                if (this.getPrixSejourChambreDouble(nbDePersonnes, arrivee, depart, a) < prixMax &&
                    this.getPrixSejourChambreDouble(nbDePersonnes, arrivee, depart, a) > prixMin && (this.resrLibreDouble(nbDePersonnes, arrivee, depart) || this.resrLibreSimple(nbDePersonnes, arrivee, depart)))
                {
                    if (this.resrLibreDouble(nbDePersonnes, arrivee, depart))
                    {
                        Random aleatoire = new Random();
                        int    x         = aleatoire.Next(1111111, 9999999);
                        while (dico.ContainsKey(x))
                        {
                            x = aleatoire.Next(1111111, 9999999);
                        }

                        resu.Add(x + " :" + this.getNom() + " au prix Ttc : " + this.getPrixSejourChambreDouble(nbDePersonnes, arrivee, depart, a) + "Euros (" + nbDePersonnes / 2 + "chambre double et " + nbDePersonnes % 2 + "Chambre Simple)");

                        dico.Add(x, this.reserver(arrivee, depart, nbDePersonnes));
                    }
                    if (this.resrLibreSimple(nbDePersonnes, arrivee, depart))
                    {
                        Random aleatoire = new Random();
                        int    x         = aleatoire.Next(1111111, 9999999);
                        while (dico.ContainsKey(x))
                        {
                            x = aleatoire.Next(1111111, 9999999);
                        }
                        dico.Add(x, this.reserverSimple(arrivee, depart, nbDePersonnes));

                        resu.Add(x + " :" + this.getNom() + " au prix Ttc : " + this.getPrixSejourChambreSimple(nbDePersonnes, arrivee, depart, a) + "Euros (" + nbDePersonnes + "Chambre Simple)");
                    }
                }
            }
            else
            {
                resu.Add("Votre identifiant et/ou votre mot de passe n'est pas correct ! ");
            }


            return(resu);
        }
 public ActionResult Edit([Bind(Include = "IdAgence,Nom,AdresseAgence")] Agence agence)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agence).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(agence));
 }
        public ActionResult Create([Bind(Include = "IdAgence,Nom,AdresseAgence")] Agence agence)
        {
            if (ModelState.IsValid)
            {
                db.Agences.Add(agence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agence));
        }
Exemple #26
0
 public static bool CreateAgence(Agence uneConfig)
 {
     try
     {
         return(AgenceDAO.CreateAgence(uneConfig));
     }
     catch (Exception ex)
     {
         throw new Exception("Echec de Création de fichier", ex);
     }
 }
 public Agence AddAgence_(Agence a)
 {
     try
     {
         return(agenceRepository.AddAgence_(a));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #28
0
        public IHttpActionResult GetAgence(int id)
        {
            Agence agence = db.Agences.Find(id);

            if (agence == null)
            {
                return(NotFound());
            }

            return(Ok(agence));
        }
Exemple #29
0
        private void LoadCurrentAgence()
        {
            Agence s = AgenceBLL.ReturnAgence();

            if (s != null ? s.Id > 0 : false)
            {
                cbox_agence.SelectedText = s.Name;
                agence = s;
                txt_name_agence.Text = s.Name;
            }
        }
Exemple #30
0
        public Agence DeleteAgence_(Agence a)
        {
            var result = mos_Communes_DbContext.Agences.FirstOrDefault(e => e.AgenceId == a.AgenceId);

            if (result != null)
            {
                mos_Communes_DbContext.Remove(result);
                mos_Communes_DbContext.SaveChanges();
                return(result);
            }
            return(result);
        }