コード例 #1
0
ファイル: DureeDAO.cs プロジェクト: rindratiana/stock
        public List <StatDuree> GetStatDurees(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateFin == "" && dateDebut == "")
            {
                query = "select commande.id_commande,TIMESTAMPDIFF(SECOND,heure_commande,heure_livraison) as duree from duree join commande on commande.id_commande=duree.id_commande where ETAT='111' and client='1'";
            }
            else
            {
                query = "select commande.id_commande as id_commande,TIMESTAMPDIFF(SECOND,heure_commande,heure_livraison) as duree from duree join commande on commande.id_commande=duree.id_commande where date_commande<='" + dateFin + "' and date_commande>='" + dateDebut + "' and ETAT='111' and client='1'";
            }
            MySqlCommand    command = new MySqlCommand(query, connexion.GetConnection());
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <StatDuree> reponse = new List <StatDuree>();

            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())
                    {
                        StatDuree stat     = new StatDuree();
                        Commande  commande = new Commande();
                        commande.IdCommande = Int32.Parse(dataReader["id_commande"].ToString());
                        stat.Commande       = commande;
                        stat.Minutes        = Int32.Parse(dataReader["duree"].ToString());
                        reponse.Add(stat);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
コード例 #2
0
ファイル: StockController.cs プロジェクト: rindratiana/stock
 public JsonResult GetStatDuree(string dateDebut, string dateFin)
 {
     try
     {
         StatDuree statDuree = new StatDuree();
         double    reponse   = statDuree.GetStatDuree(dateDebut, dateFin);
         //conversion en milliseconde
         reponse = reponse * 1000;
         return(Json(reponse));
     }
     catch (Exception exception)
     {
         return(Json(exception.Message));
     }
 }