예제 #1
0
 public JsonResult GetStatCommandesAnnule(string dateDebut, string dateFin)
 {
     try
     {
         StatCommande statDuree = new StatCommande();
         StatCommande reponse   = statDuree.GetStatCommandesAnnule(dateDebut, dateFin);
         return(Json(reponse));
     }
     catch (Exception exception)
     {
         return(Json(exception.Message));
     }
 }
예제 #2
0
        public StatCommande GetStatCommandesAnnule(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateDebut == "" && dateFin == "")
            {
                query = "SELECT count(*) as total FROM commande where ETAT='000' and client='1'";
            }
            else
            {
                query = "SELECT count(*) as total FROM commande where ETAT='000' and date_commande<='" + dateFin + "' and date_commande>='" + dateDebut + "' and client='1'";
            }
            MySqlCommand    command      = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO = new AccesSageDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            StatCommande reponse = new StatCommande();

            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())
                    {
                        StatCommande stat = new StatCommande();
                        stat.Nombre = Int32.Parse(dataReader["total"].ToString());
                        reponse     = stat;
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }