示例#1
0
        public List <StatEmplacement> GetStatEmplacements()
        {
            Connexion       connexion = new Connexion();
            string          query     = "select emplacement, count(*) as total from detail_commande join commande on commande.id_commande=detail_commande.id_commande where commande.client = '1' and commande.etat='111' group by emplacement";
            MySqlCommand    command   = new MySqlCommand(query, connexion.GetConnection());
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <StatEmplacement> reponse = new List <StatEmplacement>();

            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())
                    {
                        StatEmplacement stat = new StatEmplacement();
                        if (dataReader["emplacement"].ToString() == "0")
                        {
                            stat.Emplacement = new Emplacement("0", "Stock");
                        }
                        else
                        {
                            stat.Emplacement = GetEmplacementsByNumero(dataReader["emplacement"].ToString());
                        }
                        stat.Quantite = Int32.Parse(dataReader["total"].ToString());
                        reponse.Add(stat);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                if (command != null)
                {
                    command.Dispose();
                }
                if (connexion.GetConnection() != null)
                {
                    connexion.GetConnection().Close();
                }
            }
        }
示例#2
0
 public JsonResult GetStatistiques()
 {
     try
     {
         StatEmplacement        stat  = new StatEmplacement();
         List <StatEmplacement> liste = stat.GetStatEmplacements();
         return(Json(liste));
     }
     catch (Exception exception)
     {
         return(Json(exception.Message));
     }
 }
示例#3
0
 public JsonResult GetStatistiquesEntreDeuxDates(string dateDebut, string dateFin)
 {
     try
     {
         StatEmplacement        stat  = new StatEmplacement();
         List <StatEmplacement> liste = stat.GetStatEmplacementsEntreDeuxDates(dateDebut, dateFin);
         return(Json(liste));
     }
     catch (Exception exception)
     {
         return(Json(exception.Message));
     }
 }