Exemple #1
0
        public List <string> GetNumeroPiece(string piece, Utilisateur utilisateur)
        {
            Comptoir      comptoir  = GetComptoirByNomCaisse(utilisateur.Identifiants);
            List <string> reponse   = new List <string>();
            ConnexionSage connexion = new ConnexionSage();
            SqlCommand    command;
            SqlDataReader dataReader;

            connexion.Open();
            string sql = "SELECT DISTINCT F_DOCLIGNE.DO_Piece FROM F_DOCLIGNE WHERE F_DOCLIGNE.DO_Piece like '" + piece + "%' and F_DOCLIGNE.CO_No='" + comptoir.IdComptoir + "'";

            command    = new SqlCommand(sql, connexion.Connection);
            dataReader = command.ExecuteReader();
            try
            {
                while (dataReader.Read())
                {
                    reponse.Add(dataReader["DO_Piece"].ToString());
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseRest(dataReader, command, connexion.Connection);
            }
        }
Exemple #2
0
        public void ComptoirTest()
        {
            Comptoir comptoir = new Comptoir();
            string   assiette = "couverts";

            Assert.AreEqual(comptoir.DonnePlat(1), assiette);
        }
Exemple #3
0
        // GET: Login
        public ActionResult Connecter()
        {
            try
            {
                string      identifiant = Request.Form["identifiant"];
                string      mdp         = Request.Form["mdp"];
                LoginUsers  loginUsers  = new LoginUsers(identifiant, mdp);
                Utilisateur utilisateur = Utilisateur.Connecter(loginUsers);
                HttpContext.Session["utilisateur"] = utilisateur;
                Utilisateur userSession = HttpContext.Session["utilisateur"] as Utilisateur;
                string      idposte     = userSession.Poste.IdPoste;
                Commande    commande    = new Commande();
                switch (idposte)
                {
                case "1":
                    AccesSageDAO    accesSageDAO         = new AccesSageDAO();
                    Comptoir        comptoir             = accesSageDAO.GetComptoirByNomCaisse(utilisateur.Identifiants);
                    List <Commande> listeCommandeEnCours = commande.GetListeCommandeEnCours(comptoir);
                    ViewData["listeCommandeEnCours"] = listeCommandeEnCours;
                    ViewBag.date        = DateTime.Now.ToString("yyyy-MM-dd");
                    ViewBag.titre       = "Commande";
                    ViewBag.espaceVente = "ok";
                    ViewBag.userName    = utilisateur.Prenoms;
                    return(View("Accueil_vente"));

                case "2":
                    ViewBag.date = DateTime.Now.ToString("yyyy-MM-dd");
                    List <Commande> commandeEncours = commande.GetListeToutCommandeEnCours();
                    string          titre           = "";
                    if (commandeEncours.Count == 0)
                    {
                        titre = "Attente commande";
                    }
                    else
                    {
                        titre = "Commande en cours";
                    }
                    ViewBag.titre = titre;
                    ViewData["commandeEnCours"] = commandeEncours;
                    ViewBag.espaceStock         = "ok";
                    ViewBag.userName            = utilisateur.Prenoms;
                    return(View("Accueil_stock"));

                case "4":
                    ViewData["utilisateursValide"]    = utilisateur.GetUtilisateurValidation("1");
                    ViewData["utilisateursNonValide"] = utilisateur.GetUtilisateurValidation("0");
                    ViewBag.titre    = "Gestion des utilisateurs";
                    ViewBag.userName = utilisateur.Prenoms;
                    return(View("Admin"));

                default:
                    return(View("login"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.erreur = ex.Message;
                return(View("Login"));
            }
        }
Exemple #4
0
        public List <Commande> GetListeCommandeAnnule(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateDebut == "" && dateFin == "")
            {
                query = "select * from commande where ETAT = '000' and CLIENT='1'";
            }
            else
            {
                query = "select * from commande where ETAT = '000' and CLIENT='1' and date_commande<='" + dateFin + "' and date_commande>='" + dateDebut + "'";
            }
            MySqlCommand    command      = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO = new AccesSageDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Comptoir comptoir = accesSageDAO.GetComptoirById(dataReader["ID_COMPTOIR"].ToString());
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        List <DetailCommande> detailCommandes = GetArticlesCommandes(commande.Numero);
                        for (int i = 0; i < detailCommandes.Count; i++)
                        {
                            int quantite = detailCommandes[i].Quantite;
                            detailCommandes[i].Article  = accesSageDAO.GetArticleByReferences(detailCommandes[i].Article.References);
                            detailCommandes[i].Quantite = quantite;
                        }
                        commande.ListeDetailCommande = detailCommandes;
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemple #5
0
        public List <Commande> GetListeCommandeEnCours(Comptoir comptoir, string etat)
        {
            Connexion       connexion = new Connexion();
            string          query     = "SELECT * FROM commande where ID_COMPTOIR='" + comptoir.IdComptoir + "' and ETAT='" + etat + "'";
            MySqlCommand    command   = new MySqlCommand(query, connexion.GetConnection());
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                if (command != null)
                {
                    command.Dispose();
                }
                if (connexion.GetConnection() != null)
                {
                    connexion.GetConnection().Close();
                }
            }
        }
Exemple #6
0
        public void sendCMD(Comptoir comptoir)
        {
            bool testc = true;

            while (testc)
            {
                //string message = Console.ReadLine();

                string test2 = "zeubi";
                //string test = test2.ToString();
                //List<int> commande = new List<int> { 0, 1, 2, 3, 4, 5, 6 };
                //convertit int en string
                //string test = CommandeEnvoie.ToString();
                byte[] msg;
                byte[] lenght;

                bool      voo       = true;
                UdpClient udpClient = new UdpClient();

                Thread.Sleep(100);
                while (voo)
                {
                    lenght = Encoding.Default.GetBytes(comptoir.CommandeEnvoie1.Count().ToString());
                    //UdpClient udpClient = new UdpClient();
                    udpClient.Send(lenght, lenght.Length, "127.0.0.1", 5035);
                    voo = false;
                }

                udpClient.Close();

                Thread.Sleep(2000);

                UdpClient udpClientCMD = new UdpClient();
                foreach (int item in comptoir.CommandeEnvoie1[0])
                {
                    test2 = item.ToString();
                    msg   = Encoding.Default.GetBytes(test2);
                    udpClientCMD.Send(msg, msg.Length, "127.0.0.1", 5035);
                }
                udpClient.Close();
                Console.WriteLine("La commande à été envoyée");
            }
        }
Exemple #7
0
        public List <Commande> GetListeToutCommandeEnCours(string etat)
        {
            Connexion       connexion    = new Connexion();
            string          query        = "SELECT * FROM commande where ETAT='" + etat + "'";
            MySqlCommand    command      = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO = new AccesSageDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Comptoir comptoir = accesSageDAO.GetComptoirByNumTicket(dataReader["NUMERO"].ToString());
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemple #8
0
        public Comptoir GetComptoirByNumTicket(string numero_ticket)
        {
            ConnexionSage connexion = new ConnexionSage();
            SqlCommand    command;
            SqlDataReader dataReader;
            Comptoir      comptoirTemp = new Comptoir();

            connexion.Open();
            string sql = "SELECT DISTINCT F_DOCLIGNE.CO_No, F_CAISSE.CA_Intitule FROM F_DOCLIGNE join F_CAISSE on F_CAISSE.CO_No = F_DOCLIGNE.CO_No join F_ARTICLE on F_ARTICLE.AR_Ref = F_DOCLIGNE.AR_Ref WHERE F_DOCLIGNE.DO_Piece='" + numero_ticket + "'";

            command    = new SqlCommand(sql, connexion.Connection);
            dataReader = command.ExecuteReader();
            try
            {
                if (dataReader.Read().ToString() == "True")
                {
                    comptoirTemp.IdComptoir  = dataReader["CO_No"].ToString();
                    comptoirTemp.NomComptoir = dataReader["CA_Intitule"].ToString();
                }
                else
                {
                    comptoirTemp.IdComptoir  = "0";
                    comptoirTemp.NomComptoir = "Autres";
                }

                return(comptoirTemp);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            finally
            {
                connexion.CloseRest(dataReader, command, connexion.Connection);
            }
        }
Exemple #9
0
        public Comptoir GetComptoirByNomCaisse(string nom)
        {
            ConnexionSage connexion = new ConnexionSage();
            SqlCommand    command;
            SqlDataReader dataReader;
            Comptoir      comptoirTemp = new Comptoir();

            connexion.Open();
            string sql = "SELECT * FROM F_CAISSE where CA_Intitule='" + nom + "'";

            command    = new SqlCommand(sql, connexion.Connection);
            dataReader = command.ExecuteReader();
            try
            {
                if (dataReader.Read().ToString() == "True")
                {
                    comptoirTemp.IdComptoir  = dataReader["CO_No"].ToString();
                    comptoirTemp.NomComptoir = dataReader["CA_Intitule"].ToString();
                }
                else
                {
                    comptoirTemp.IdComptoir  = "";
                    comptoirTemp.NomComptoir = "";
                }

                return(comptoirTemp);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseRest(dataReader, command, connexion.Connection);
            }
        }
Exemple #10
0
 // GET: Vente
 public ActionResult Index()
 {
     try {
         if (HttpContext.Session["utilisateur"] == null)
         {
             ViewBag.erreur = "Veuillez vous connecter d'abord";
             return(View("Login"));
         }
         else
         {
             Utilisateur utilisateur = HttpContext.Session["utilisateur"] as Utilisateur;
             if (utilisateur.Poste.IdPoste == "1")
             {
                 AccesSageDAO    accesSageDAO         = new AccesSageDAO();
                 Commande        commande             = new Commande();
                 Comptoir        comptoir             = accesSageDAO.GetComptoirByNomCaisse(utilisateur.Identifiants);
                 List <Commande> listeCommandeEnCours = commande.GetListeCommandeEnCours(comptoir);
                 ViewData["listeCommandeEnCours"] = listeCommandeEnCours;
                 ViewBag.date        = DateTime.Now.ToString("yyyy-MM-dd");
                 ViewBag.espaceVente = "ok";
                 ViewBag.titre       = "Commande";
                 ViewBag.userName    = utilisateur.Prenoms;
                 return(View("Accueil_vente"));
             }
             else
             {
                 ViewBag.erreur = "Veuillez vous connecter en tant qu'utilisateur Auxiliaire de vente";
                 return(View("Login"));
             }
         }
     }
     catch (Exception exception)
     {
         return(View("Login"));
     }
 }
Exemple #11
0
        public List <Commande> GetListeCommande(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateDebut == "" && dateFin == "")
            {
                query = "select * from commande join duree on duree.id_commande =commande.id_commande join sortie on sortie.id_commande=commande.id_commande where commande.ETAT = '111' and commande.CLIENT='1' group by sortie.id_commande";
            }
            else
            {
                query = "select * from commande join duree on duree.id_commande =commande.id_commande join sortie on sortie.id_commande=commande.id_commande where commande.ETAT = '111' and commande.CLIENT='1' and commande.date_commande<='" + dateFin + "' and commande.date_commande>='" + dateDebut + "' group by sortie.id_commande";
            }
            MySqlCommand    command        = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO   = new AccesSageDAO();
            UtilisateurDAO  utilisateurDAO = new UtilisateurDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Comptoir comptoir = accesSageDAO.GetComptoirById(dataReader["ID_COMPTOIR"].ToString());
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        List <DetailCommande> detailCommandes = GetArticlesCommandes(commande.Numero);
                        for (int i = 0; i < detailCommandes.Count; i++)
                        {
                            int quantite = detailCommandes[i].Quantite;
                            detailCommandes[i].Article  = accesSageDAO.GetArticleByReferences(detailCommandes[i].Article.References);
                            detailCommandes[i].Quantite = quantite;
                        }
                        commande.ListeDetailCommande = detailCommandes;
                        Duree duree = new Duree();
                        duree.HeureCommandeString = dataReader["HEURE_COMMANDE"].ToString();
                        duree.HeureSortieString   = dataReader["HEURE_LIVRAISON"].ToString();
                        commande.Duree            = duree;
                        Utilisateur binome     = utilisateurDAO.GetUtilisateurById(dataReader["ID_BINOME"].ToString());
                        Utilisateur magasinier = utilisateurDAO.GetUtilisateurById(dataReader["ID_MAGASINIER"].ToString());
                        Commande    test       = new Commande();
                        test.IdCommande = Int32.Parse(dataReader["id_commande"].ToString());
                        SortieCommande sortie = new SortieCommande(dataReader["ID_SORTIE"].ToString(), test, binome, magasinier);
                        commande.SortieCommande = sortie;
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
Exemple #12
0
        public ActionResult Commande()
        {
            try
            {
                if (HttpContext.Session["utilisateur"] == null)
                {
                    ViewBag.erreur = "Veuillez vous connecter d'abord";
                    return(View("Login"));
                }
                else
                {
                    Utilisateur utilisateur = HttpContext.Session["utilisateur"] as Utilisateur;
                    if (utilisateur.Poste.IdPoste == "1")
                    {
                        int    taille        = Int32.Parse(Request.Form["taille"]);
                        string numero_ticket = Request.Form["numero_ticket"];
                        string client        = Request.Form["client"];
                        List <DetailCommande> listeCommande = new List <DetailCommande>();

                        for (int i = 0; i < taille; i++)
                        {
                            if (Request.Form["article_checked" + i + ""] == "on")
                            {
                                DetailCommande commandeTemp = new DetailCommande();
                                Article        articleTemp  = new Article();
                                articleTemp.References   = Request.Form["ref_article" + i + ""];
                                commandeTemp.Article     = articleTemp;
                                commandeTemp.Quantite    = Int32.Parse(Request.Form["quantite" + i + ""]);
                                commandeTemp.Emplacement = Int32.Parse(Request.Form["emplacement" + i + ""]);
                                listeCommande.Add(commandeTemp);
                            }
                        }

                        Commande commande = new Commande();
                        commande.Client = commande.ParseInt(client, "Veuillez choisir un client");
                        commande.CreateCommande(listeCommande, numero_ticket);

                        AccesSageDAO    accesSageDAO         = new AccesSageDAO();
                        Comptoir        comptoir             = accesSageDAO.GetComptoirByNomCaisse(utilisateur.Identifiants);
                        List <Commande> listeCommandeEnCours = commande.GetListeCommandeEnCours(comptoir);
                        ViewBag.espaceVente = "ok";
                        ViewData["listeCommandeEnCours"] = listeCommandeEnCours;
                        ViewBag.message  = "Commande envoyé";
                        ViewBag.userName = utilisateur.Prenoms;
                        return(View("Accueil_vente"));
                    }
                    else
                    {
                        ViewBag.erreur = "Veuillez vous connecter en tant qu'utilisateur Auxiliaire de vente";
                        return(View("Login"));
                    }
                }
            }
            catch (Exception exception)
            {
                Utilisateur utilisateur = HttpContext.Session["utilisateur"] as Utilisateur;
                if (utilisateur.Poste.IdPoste == "1")
                {
                    Commande        commande             = new Commande();
                    AccesSageDAO    accesSageDAO         = new AccesSageDAO();
                    Comptoir        comptoir             = accesSageDAO.GetComptoirByNomCaisse(utilisateur.Identifiants);
                    List <Commande> listeCommandeEnCours = commande.GetListeCommandeEnCours(comptoir);
                    ViewBag.espaceVente = "ok";
                    ViewData["listeCommandeEnCours"] = listeCommandeEnCours;
                    ViewBag.erreur = exception.Message;
                    return(View("Accueil_vente"));
                }
                else
                {
                    ViewBag.erreur = "Veuillez vous connecter en tant qu'utilisateur Auxiliaire de vente";
                    return(View("Login"));
                }
            }
        }