示例#1
0
 public void updatesoc(societe soc)
 {
     db.societe.Attach(db.societe.Single(x => x.id == soc.id));
     db.Entry(db.societe.Single(x => x.id == soc.id)).CurrentValues.SetValues(soc);
     //db.piece.ApplyCurrentValues(Cab);
     db.SaveChanges();
 }
示例#2
0
        public ActionResult listTrajet()
        {
            if (Session["Societe"] != null)
            {
                societe so = (societe)Session["Societe"];
                //var trajets = db.trajets.ToList();
                ViewBag.trajets = db.trajets.Where(t => t.car.id_societe == so.id).ToList();
            }


            return(View());
        }
示例#3
0
        public ActionResult listcar()
        {
            if (Session["Societe"] != null)
            {
                societe so   = (societe)Session["Societe"];
                var     cars = db.cars.Where(c => c.id_societe == so.id).ToList();
                ViewBag.cars = cars;
            }


            return(View());
        }
示例#4
0
 public ActionResult AddTrajet(int j = 0)
 {
     if (Session["Societe"] != null)
     {
         ViewBag.idCar          = new SelectList(db.cars.ToList(), "id", "type");
         ViewBag.id_Nbr_place   = new SelectList(db.villes.ToList(), "id", "nom");
         ViewBag.id_type        = new SelectList(db.villes.ToList(), "id", "nom");
         ViewBag.id_description = new SelectList(db.reservations.ToList(), "id");
         ViewBag.listeville     = db.villes.ToList();
         societe so = (societe)Session["Societe"];
         if (db.cars.Where(c => c.id_societe == so.id).FirstOrDefault() != null)
         {
             Session["haveCar"] = true;
         }
     }
     return(View());
 }
示例#5
0
        public ActionResult AddTrajet()
        {
            ViewBag.idCar           = new SelectList(db.cars.ToList(), "id", "type");
            ViewBag.id_ville_depart = new SelectList(db.villes.ToList(), "id", "nomVille");
            ViewBag.id_ville_arrive = new SelectList(db.villes.ToList(), "id", "nomVille");
            ViewBag.listeville      = db.villes.ToList();
            trajet trajet1 = new trajet();

            if (Session["Societe"] != null)
            {
                societe so = (societe)Session["Societe"];
                trajet1.idCar = so.id;
                try
                {
                    UpdateModel(trajet1);
                }
                catch
                {
                    ViewBag.erreur = "Verifier les champs !!!";
                    return(View());
                }


                // return View();
                db.trajets.Add(trajet1);
                db.SaveChanges();
            }



            //trajet1.idCar= ViewBag.trajetsso.

            //trajet trajet1 = new trajet();
            // trajet1.idCar=id;



            return(RedirectToAction("listTrajet"));
        }
示例#6
0
        public ActionResult Index(client client, societe societe, String login, String password, string hwoIam)
        {
            if (Session["isconnect"] != null && (bool)Session["isconnect"] == true)
            {
                ViewBag.Client = Session["Client"];
            }
            // verification des valeur de connection
            if (login != null)
            {
                // verification du type de compte avec la variable hwoIam
                if (hwoIam != null && hwoIam.Equals("Client"))
                {
                    client cli = new client();
                    // Recherche dans la table client
                    cli = db.clients.Where(c => c.login_client == login).FirstOrDefault();
                    if (cli != null)
                    {
                        Session["isconnect"] = true;
                        Session["Client"]    = cli;
                        ViewBag.Client       = cli;
                        Session["whoIam"]    = 1;
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Erreur ! indentifiant");
                    }
                }
                else
                {
                    Session["whoIam"] = 2;
                    societe soc = new societe();
                    // Recherche dans la table client
                    soc = db.societes.Where(s => s.login_societe == login).FirstOrDefault();
                    if (soc != null)
                    {
                        Session["isconnect"] = true;
                        Session["Societe"]   = soc;
                        ViewBag.Societe      = soc;
                        Session["whoIam"]    = 2;
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Erreur ! indentifiant");
                    }
                }
            }

            if (societe.login_societe != null)
            {
                societe s = new societe();
                try
                {
                    //insertion des donne recus dans notre variable
                    UpdateModel(s);
                    db.societes.Add(s);
                    db.SaveChanges();
                    System.Diagnostics.Debug.WriteLine("daz1");
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
            else if (client.login_client != null)
            {
                client c = new client();
                try
                {
                    //insertion des donne recus dans notre variable
                    UpdateModel(c);
                    db.clients.Add(c);
                    db.SaveChanges();
                    System.Diagnostics.Debug.WriteLine("daz2");
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
            List <ville> listeVille = db.villes.ToList();

            @ViewBag.SlectedView = "Home";
            return(View(listeVille));
        }
示例#7
0
 public void addsociete(societe soc)
 {
     db.societe.Add(soc);
     db.SaveChanges();
 }