Exemplo n.º 1
0
        /// <summary>
        /// Charger les informations sur le client sélectionné dans la liste déroulante
        /// </summary>
        private void ActualiserListe()
        {
            Clientel monclient = new Clientel();
            int      index     = cb_listecli.SelectedIndex;

            if (index != -1)
            {
                monclient.RechercheUnClient(cb_listecli.Items[index].ToString());

                lbl_nom.Text     = monclient.NomCl;
                lbl_prenom.Text  = monclient.PrenomCl;
                lbl_scte.Text    = monclient.Societe;
                lbl_adresse.Text = monclient.AdresseCl;
                lbl_ville.Text   = monclient.VilleCl;
                lbl_cp.Text      = monclient.CodePostCl;

                lbl_noclient.Text = "Client n°" + cb_listecli.Items[index].ToString();
            }
            else
            {
                lbl_nom.Text     = "";
                lbl_prenom.Text  = "";
                lbl_scte.Text    = "";
                lbl_adresse.Text = "";
                lbl_ville.Text   = "";
                lbl_cp.Text      = "";

                lbl_noclient.Text = "Veuillez choisir un client";
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// mise à jour d'un client sur son ID
        /// </summary>
        /// <param name="numCli">N° de l'utilisateur à lire</param>
        public static void UpdateClient(Clientel unCli)
        {
            Serreurs er      = new Serreurs("Erreur sur l'écriture d'un client.", "Client.update()");
            String   requete = "UPDATE Clientel SET " +
                               "SOCIETE = '" + unCli.Societe + "'" +
                               ", NOM_CL = '" + unCli.NomCl + "'" +
                               ", PRENOM_CL = '" + unCli.PrenomCl + "'" +
                               ", ADRESSE_CL = '" + unCli.AdresseCl + "'" +
                               ", VILLE_CL = '" + unCli.VilleCl + "'" +
                               ", CODE_POST_CL = '" + unCli.CodePostCl + "'" +
                               " WHERE NO_CLIENT LIKE '" + unCli.NuClient + "'";

            try
            {
                DBInterface.Insertion_Donnees(requete);
            }
            catch (MonException erreur)
            {
                throw erreur;
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialisation
        /// </summary>
        public Fclient()
        {
            InitializeComponent();

            lbl_nom.Text        = "";
            lbl_prenom.Text     = "";
            lbl_scte.Text       = "";
            lbl_adresse.Text    = "";
            lbl_ville.Text      = "";
            lbl_cp.Text         = "";
            btn_details.Visible = false;

            List <String> mesNumeros;

            try
            {
                Clientel unClient = new Clientel();
                mesNumeros = unClient.LectureNoClient();
                foreach (String item in mesNumeros)
                {
                    cb_listecli.Items.Add(item);
                }
            }
            catch (MonException exception)
            {
                MessageBox.Show(exception.MessageApplication(), exception.Message);
            }
        }
Exemplo n.º 4
0
        public ActionResult Ajouter()
        {
            try
            {
                //dropdown list de client
                List <String> noClientList = new List <String>();
                noClientList           = (Clientel.LectureNoClient());
                ViewBag.ListOfNoClient = noClientList;

                //dropdown list de Vendeur
                List <String> noVendeurList = new List <String>();
                noVendeurList           = (Vendeur.LectureNoVendeur());
                ViewBag.ListOfNoVendeur = noVendeurList;

                //dropdown list des articles
                List <String> noArticleList = new List <String>();
                noArticleList           = (Commandes.LectureNoArticle());
                ViewBag.ListOfNoArticle = noArticleList;

                return(View(""));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Charger les données pour les listes déroulantes de clients et vendeurs
        /// </summary>
        private void ChargerDonnees()
        {
            List <String> mesNumeros;

            try
            {
                Clientel unClient = new Clientel();
                mesNumeros = unClient.LectureNoClient();
                foreach (String item in mesNumeros)
                {
                    cb_noclient.Items.Add(item);
                }

                Vendeur unVendeur = new Vendeur();
                mesNumeros = unVendeur.LectureNoVendeur();
                foreach (String item in mesNumeros)
                {
                    cb_novendeur.Items.Add(item);
                }
            }
            catch (MonException exception)
            {
                MessageBox.Show(exception.MessageApplication(), exception.Message);
            }
        }
Exemplo n.º 6
0
        public ActionResult Ajouter(Commande uneCom)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (String no in Vendeur.LectureNoVendeurs())
            {
                if (int.Parse(no) == uneCom.NoVendeur)
                {
                    items.Add(new SelectListItem {
                        Text = "Vendeur N°" + no, Value = no, Selected = true
                    });
                }
                else
                {
                    items.Add(new SelectListItem {
                        Text = "Vendeur N°" + no, Value = no
                    });
                }
            }
            ViewBag.NoVendeurs = items;

            items = new List <SelectListItem>();
            foreach (String no in Clientel.LectureNoClients())
            {
                if (int.Parse(no) == uneCom.NoClient)
                {
                    items.Add(new SelectListItem {
                        Text = "Client N°" + no, Value = no, Selected = true
                    });
                }
                else
                {
                    items.Add(new SelectListItem {
                        Text = "Client N°" + no, Value = no
                    });
                }
            }
            ViewBag.NoClients = items;

            items = new List <SelectListItem>();
            foreach (Article art in Article.getArticles())
            {
                items.Add(new SelectListItem {
                    Text = art.NoArticle + "/;/" + art.Libelle + "/;/" + art.Prix, Value = art.NoArticle.ToString()
                });
            }
            ViewBag.Articles = items;

            try
            {
                int id = Commande.insertCommande(uneCom);

                return(RedirectToAction("Modifier", new { id = id }));
            }
            catch (MonException e)
            {
                ViewBag.Title = "Ajouter une commande";
                return(View());
            }
        }
        public ActionResult Ajouter(Clientel unC)
        {
            /*List<String> mesNumeros;
             * int num;
             *
             * // Test pour savoir quel ID on peut donner au client créé
             * try
             * {
             *  mesNumeros = Clientel.LectureNoClient();
             *  if(int.TryParse(mesNumeros.Last(), out num))
             *  {
             *      num++;
             *  }
             * }*/

            try
            {
                // utilisation possible de Request
                //  String s= Request["Societe"];

                Clientel.insertClient(unC);
                ViewBag.Title = "Ajouter un client";

                return(RedirectToAction("Index"));
            }
            catch (MonException e)
            {
                return(View(unC));
            }
        }
        public ActionResult Modifier(ComVendCli cvc)
        {
            IEnumerable <Commandes> commandes = null;
            Commandes com = new Commandes();

            try
            {
                // utilisation possible de Request
                //  String s= Request["Societe"];

                com.NoCommande = Request["NoCommande"];
                com.NoClient   = Clientel.getClientById(Request["NoClient"]);
                com.NoVendeur  = Vendeur.getVendeurById(Request["NoVendeur"]);
                com.DateCde    = Request["DateCde"];
                com.Facture    = Request["Facture"];
                Commandes.updateCommande(com);

                commandes = Commandes.getCommandes();

                return(View("Index", commandes));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 9
0
        public ActionResult Modifier(int id)
        {
            try
            {
                Commande uneCom = Commande.getCommande(id);
                ViewBag.Title = "Modifier commande N°" + id;

                List <SelectListItem> items = new List <SelectListItem>();
                foreach (String no in Vendeur.LectureNoVendeurs())
                {
                    if (int.Parse(no) == uneCom.NoVendeur)
                    {
                        items.Add(new SelectListItem {
                            Text = "Vendeur N°" + no, Value = no, Selected = true
                        });
                    }
                    else
                    {
                        items.Add(new SelectListItem {
                            Text = "Vendeur N°" + no, Value = no
                        });
                    }
                }
                ViewBag.NoVendeurs = items;

                items = new List <SelectListItem>();
                foreach (String no in Clientel.LectureNoClients())
                {
                    if (int.Parse(no) == uneCom.NoClient)
                    {
                        items.Add(new SelectListItem {
                            Text = "Client N°" + no, Value = no, Selected = true
                        });
                    }
                    else
                    {
                        items.Add(new SelectListItem {
                            Text = "Client N°" + no, Value = no
                        });
                    }
                }
                ViewBag.NoClients = items;

                items = new List <SelectListItem>();
                foreach (Article art in Article.getArticles())
                {
                    items.Add(new SelectListItem {
                        Text = art.NoArticle + "/;/" + art.Libelle + "/;/" + art.Prix, Value = art.NoArticle.ToString()
                    });
                }
                ViewBag.Articles = items;

                return(View(uneCom));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 10
0
        public CommandeViewModel(int noCommande, Vendeur vendeur, Clientel clientel, string date, bool facture)
        {
            NoCommande = noCommande;
            Vendeur    = vendeur;
            Clientel   = new ClientelViewModel(clientel);
            Date       = date;
            Facture    = facture;

            Vendeurs = new List <SelectListItem>();
            Clients  = new List <SelectListItem>();
        }
Exemplo n.º 11
0
 // GET: Commande/Edit/5
 public ActionResult Modifier(string id)
 {
     try
     {
         Clientel unCl = Clientel.getClient(id);
         return(View(unCl));
     }
     catch (MonException e)
     {
         return(HttpNotFound());
     }
 }
Exemplo n.º 12
0
 public ActionResult Ajouter(Clientel unClient)
 {
     try
     {
         Clientel.addClient(unClient);
         return(RedirectToAction("Index", "Client"));
     }
     catch (MonException e)
     {
         return(HttpNotFound());
     }
 }
Exemplo n.º 13
0
 public ClientelViewModel(Clientel client) :
     this(
         int.Parse(client.NoClient),
         client.NomCl,
         client.PrenomCl,
         client.Societe,
         client.VilleCl,
         client.CodePostCl,
         client.AdresseCl
         )
 {
 }
 // GET: Commande/Edit/5
 public ActionResult Modifier(int id)
 {
     try
     {
         Clientel unCl = Clientel.getClient(id);
         ViewBag.Title = "Modifier";
         return(View(unCl));
     }
     catch (MonException e)
     {
         return(HttpNotFound());
     }
 }
Exemplo n.º 15
0
        public ActionResult Modifier(Clientel unC)
        {
            try
            {
                // utilisation possible de Request
                //  String s= Request["Societe"];

                Clientel.updateClient(unC);
                return(View());
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 16
0
        // GET: Client
        public ActionResult Index()
        {
            IEnumerable <Clientel> clients = null;

            try
            {
                clients = Clientel.getClients();
            }
            catch (MonException e)
            {
                ModelState.AddModelError("Erreur", "Erreur lors de la récupération des clients : " + e.Message);
                return(View("Error"));
            }

            return(View(clients));
        }
Exemplo n.º 17
0
        public ActionResult Modifier(Clientel unC)
        {
            IEnumerable <Clientel> clients = null;

            try
            {
                // utilisation possible de Request
                //  String s= Request["Societe"];

                Clientel.updateClient(unC);
                clients = Clientel.getClients();
                return(View("Index", clients));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 18
0
 // GET: Commande/Edit/5
 public ActionResult Modifier(string id)
 {
     if (Session["id"] != null)
     {
         try
         {
             Clientel unCl = ClientDao.GetClient(id);
             return(View(unCl));
         }
         catch (MonException e)
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(View("~/Views/Home/Connexion.cshtml"));
     }
 }
Exemplo n.º 19
0
        public ActionResult Ajouter()
        {
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (String no in Vendeur.LectureNoVendeurs())
            {
                items.Add(new SelectListItem {
                    Text = "Vendeur N°" + no, Value = no
                });
            }
            ViewBag.NoVendeurs = items;

            items = new List <SelectListItem>();
            foreach (String no in Clientel.LectureNoClients())
            {
                items.Add(new SelectListItem {
                    Text = "Client N°" + no, Value = no
                });
            }
            ViewBag.NoClients = items;

            items = new List <SelectListItem>();
            foreach (Article art in Article.getArticles())
            {
                items.Add(new SelectListItem {
                    Text = art.NoArticle + "/;/" + art.Libelle + "/;/" + art.Prix, Value = art.NoArticle.ToString()
                });
            }
            ViewBag.Articles = items;

            try
            {
                ViewBag.Title = "Ajouter une commande";

                return(View());
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 20
0
        public ActionResult AjouterDetail()
        {
            try
            {
                //gerer la dropdown list de client
                List <String> noClientList = new List <String>();
                noClientList           = (Clientel.LectureNoClient());
                ViewBag.ListOfNoClient = noClientList;

                //gerer la dropdown list de Vendeur
                List <String> noVendeurList = new List <String>();
                noVendeurList           = (Vendeur.LectureNoVendeur());
                ViewBag.ListOfNoVendeur = noVendeurList;

                return(View(""));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 21
0
        public ActionResult Modifier(Clientel unC)
        {
            if (Session["id"] != null)
            {
                try
                {
                    // utilisation possible de Request
                    //  String s= Request["Societe"];

                    ClientDao.UpdateClient(unC);
                    return(View());
                }
                catch (MonException e)
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                return(View("~/Views/Home/Connexion.cshtml"));
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// récupération de la liste des clients
        /// </summary>
        /// <returns>Liste des clients</returns>
        public static IEnumerable <Clientel> GetClients()
        {
            IEnumerable <Clientel> clients = new List <Clientel>();
            DataTable dt;
            Clientel  client;
            Serreurs  er = new Serreurs("Erreur sur lecture des clients.", "ClientsList.getClients()");

            try
            {
                String mysql = "SELECT SOCIETE, NOM_CL, PRENOM_CL, ADRESSE_CL, VILLE_CL, CODE_POST_CL, " +
                               "NO_CLIENT FROM clientel ORDER BY NO_CLIENT";

                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    client            = new Clientel();
                    client.NuClient   = dataRow[6].ToString();
                    client.NomCl      = dataRow[1].ToString();
                    client.Societe    = dataRow[0].ToString();
                    client.PrenomCl   = dataRow[2].ToString();
                    client.AdresseCl  = dataRow[3].ToString();
                    client.VilleCl    = dataRow[4].ToString();
                    client.CodePostCl = dataRow[5].ToString();

                    ((List <Clientel>)clients).Add(client);
                }

                return(clients);
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
        public ActionResult Modifier(Clientel unC)
        {
            if (!ModelState.IsValid)
            {
                // Si le client modifié n'est pas valide, on affiche un message d'erreur à l'utilisateur
                return(View(unC));
            }

            try
            {
                // utilisation possible de Request
                //  String s= Request["Societe"];

                Clientel.updateClient(unC);
                ViewBag.Title = "Modifier";

                return(RedirectToAction("Index"));
            }
            catch (MonException e)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Lire un utilisateur sur son ID
        /// </summary>
        /// <param name="numCli">N° de l'utilisateur à lire</param>
        public static Clientel GetClient(String numCli)
        {
            String    mysql;
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'un client.", "Client.RechercheUnClient()");

            try
            {
                mysql  = "SELECT SOCIETE, NOM_CL, PRENOM_CL,";
                mysql += "ADRESSE_CL, VILLE_CL, CODE_POST_CL ";
                mysql += "FROM clientel WHERE NO_CLIENT='" + numCli + "'";
                dt     = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Clientel client  = new Clientel();
                    DataRow  dataRow = dt.Rows[0];
                    client.NuClient   = numCli;
                    client.NomCl      = dataRow[1].ToString();
                    client.Societe    = dataRow[0].ToString();
                    client.PrenomCl   = dataRow[2].ToString();
                    client.AdresseCl  = dataRow[3].ToString();
                    client.VilleCl    = dataRow[4].ToString();
                    client.CodePostCl = dataRow[5].ToString();

                    return(client);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 25
0
        private IEnumerable <SelectListItem> GetClients(IEnumerable <Clientel> clients, Clientel client)
        {
            var lClients = new List <SelectListItem>();

            foreach (Clientel clientel in clients)
            {
                lClients.Add(new SelectListItem()
                {
                    Text = clientel.NomCl, Value = clientel.NoClient
                });
            }
            if (lClients.Exists(a => a.Value == client.NoClient))
            {
                lClients.First(a => a.Value == client.NoClient).Selected = true;
            }

            return(new SelectList(lClients, "Value", "Text"));
        }
Exemplo n.º 26
0
        public ActionResult Supprimer(string id)
        {
            Clientel client = Clientel.getClient(id);

            return(View(client));
        }
Exemplo n.º 27
0
 public ActionResult Supprimer(Clientel unCli)
 {
     Clientel.Supprimer(unCli);
     return(RedirectToAction("Index"));
 }