begin process at 2010 02 10 00:56:43
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Base de données

 > CREATION DE STATISTIQUE!

CREATION DE STATISTIQUE!


 Information sur la source

Note :
Aucune note
Catégorie :Base de données Niveau :Initié Date de création :07/08/2003 Date de mise à jour :08/08/2003 11:11:14 Vu / téléchargé :10 216 / 824

Auteur : psyjc

Ecrire un message privé
Site perso
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

ce script permet de faire des stats a partir dune base de donnee et envois les resultats sur excel pour generer des graphiques :)


bon, j'ai fais ca à l'arrache alors le code est un peut crasseux :D

Source

  • <%
  • Action = right(UCase(Request("type")),3)
  • If Action <> "" Then ' Arrivée du formulaire
  • ' 2. Tri de la Base de Données
  • dbPath = Server.MapPath("mdb/satisfaction.mdb")
  • ' Création de l'objet permettant la connexion
  • Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
  • ' Connexion
  • OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};" _
  • & " DBQ=" & dbPath
  • if ((Request("jd") <> 0) and (Request("md") <> 0) and (Request("ad") <> 0) and (Request("jf") <> 0) and (Request("mf") <> 0) and (Request("af") <> 0) and request("moy") = 0) then
  • SQLQuery = "SELECT * FROM stat WHERE date BETWEEN {d '"&Request("ad")&"-"&Request("md")&"-"&Request("jd")&"'} AND {d '"&Request("af")&"-"&Request("mf")&"-"&Request("jf")&"'} ORDER by date"
  • Set rs = Server.CreateObject("ADODB.Recordset")
  • rs.Open SQLQuery, OBJdbConnection, 1, 2
  • NbRecord = Rs.RecordCount - 1
  • redim tabdate(NbRecord)
  • redim tab1(NbRecord)
  • redim tab2(NbRecord)
  • redim tab3(NbRecord)
  • redim tab4(NbRecord)
  • i = 0
  • While Not rs.eof
  • tabdate(i) = rs("date")
  • tab1(i) = (int(rs("champ1")*100))/100
  • tab2(i) = (int(rs("champ2")*100))/100
  • tab3(i) = (int(rs("champ3")*100))/100
  • tab4(i) = (int(rs("champ4")*100))/100
  • i=i+1
  • Rs.MoveNext
  • wend
  • rs.close
  • elseif (Request("moy") <> 0 ) then
  • if(Request("moy") = 1) then valint = "ww"
  • if(Request("moy") = 2) then valint = "m"
  • if(Request("moy") = 3) then valint = "yyyy"
  • if(Request("moy") = 4) then valint = "d"
  • if ((Request("jd") <> 0) and (Request("md") <> 0) and (Request("ad") <> 0) and (Request("jf") <> 0) and (Request("mf") <> 0) and (Request("af") <> 0)) then
  • ad = Request("ad")
  • md = Request("md")
  • jd = Request("jd")
  • af = Request("af")
  • mf = Request("mf")
  • jf = Request("jf")
  • else
  • ad = 2003
  • md = 1
  • jd = 1
  • af = year(date)
  • mf = month(date)
  • jf = day(date)
  • end if
  • seriald = dateSerial(ad,md,jd)
  • serialf = dateSerial(af,mf,jf)
  • diffdate = dateDiff(valint , seriald, serialf)
  • redim tabdate(diffdate)
  • redim tab1(diffdate)
  • redim tab2(diffdate)
  • redim tab3(diffdate)
  • redim tab4(diffdate)
  • i = 0
  • for dx = 0 to diffdate
  • countdated = dateAdd(valint,dx,seriald)
  • ac = year(countdated)
  • mc = month(countdated)
  • jc = day(countdated)
  • countdatef = dateAdd(valint,dx+1,seriald)
  • countdatef = dateAdd("d",-1,countdatef)
  • acf = year(countdatef)
  • mcf = month(countdatef)
  • jcf = day(countdatef)
  • Set rs = Server.CreateObject("ADODB.Recordset")
  • SQLQuery = "SELECT AVG(Champ1) AS moyenne1, AVG(Champ2) AS moyenne2, AVG(Champ3) AS moyenne3, AVG(Champ4) AS moyenne4 FROM stat WHERE date BETWEEN #"&ac&"-"&mc&"-"&jc&"# AND #"&acf&"-"&mcf&"-"&jcf&"#"
  • rs.Open SQLQuery, OBJdbConnection, 1, 2
  • if (rs("moyenne1") <> "") then
  • tabdate(i) = jc&"/"&mc&"/"&ac
  • if (valint = "yyyy") then
  • tabdate(i) = "xx/xx/"&ac
  • end if
  • if (valint = "m") then
  • tabdate(i) = "xx/"&mc&"/"&ac
  • end if
  • tab1(i) = (int(rs("moyenne1")*100))/100
  • tab2(i) = (int(rs("moyenne2")*100))/100
  • tab3(i) = (int(rs("moyenne3")*100))/100
  • tab4(i) = (int(rs("moyenne4")*100))/100
  • i = i + 1
  • end if
  • rs.close
  • next
  • redim PRESERVE tabdate(i-1)
  • redim PRESERVE tab1(i-1)
  • redim PRESERVE tab2(i-1)
  • redim PRESERVE tab3(i-1)
  • redim PRESERVE tab4(i-1)
  • else
  • Set rs = Server.CreateObject("ADODB.Recordset")
  • SQLQuery = "SELECT * FROM stat ORDER by date"
  • rs.Open SQLQuery, OBJdbConnection, 1, 2
  • NbRecord = Rs.RecordCount - 1
  • redim tabdate(NbRecord)
  • redim tab1(NbRecord)
  • redim tab2(NbRecord)
  • redim tab3(NbRecord)
  • redim tab4(NbRecord)
  • i = 0
  • While Not rs.eof
  • tabdate(i) = rs("date")
  • tab1(i) = (int(rs("champ1")*100))/100
  • tab2(i) = (int(rs("champ2")*100))/100
  • tab3(i) = (int(rs("champ3")*100))/100
  • tab4(i) = (int(rs("champ4")*100))/100
  • i=i+1
  • Rs.MoveNext
  • wend
  • rs.close
  • end if
  • ' 3. Création du fichier
  • Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  • dim dir : dir = Server.MapPath("files")
  • set inF = FSO.CreateTextFile(dir&"/"&Request("type"))
  • ' Fichier au format Excel (.slk)
  • if right(Request("type"),3)="slk" then
  • inF.writeLine"ID;PWXL;N;E" ' Début du codage excel
  • ' chr (34) remplace les guillements à la suite de l'instruction
  • inF.writeLine"C;Y1;X1;K"&chr(34)&("Date")&chr(34)
  • inF.writeLine"C;Y1;X2;K"&chr(34)&("Qualité d'accueil et d'écoute")&chr(34)
  • inF.writeLine"C;Y1;X3;K"&chr(34)&("Qualité des réponses fournies")&chr(34)
  • inF.writeLine"C;Y1;X4;K"&chr(34)&("Délai de résolution satisfaisant")&chr(34)
  • inF.writeLine"C;Y1;X5;K"&chr(34)&("Facilité à joindre la hotline")&chr(34)
  • i=2 ' Affichage à partir de la ligne 2
  • for x = 0 to Ubound(tab1)
  • inF.writeLine"C;Y"&x+2&";X1;K"&chr(34)&(tabdate(x))&chr(34)
  • inF.writeLine"C;Y"&x+2&";X2;K"&chr(34)&(tab1(x))&chr(34)
  • inF.writeLine"C;Y"&x+2&";X3;K"&chr(34)&(tab2(x))&chr(34)
  • inF.writeLine"C;Y"&x+2&";X4;K"&(chr(34)&tab3(x))&chr(34)
  • inF.writeLine"C;Y"&x+2&";X5;K"&chr(34)&(tab4(x))&chr(34)
  • next
  • inF.writeLine"E" ' Fin du codage excel
  • ' ou fichier au format texte (.txt)
  • else
  • inF.writeLine("Notes :")
  • inF.writeLine("champ1 = Qualité d'accueil et d'écoute"&chr(09)&chr(09)&chr(09)&"1 = Mauvais")
  • inF.writeLine("champ2 = Qualité des réponses fournies"&chr(09)&chr(09)&chr(09)&"2 = Moyen")
  • inF.writeLine("champ3 = Délai de résolution satisfaisant"&chr(09)&chr(09)&"3 = Satisfaisant")
  • inF.writeLine("champ4 = Facilité à joindre la hotline"&chr(09)&chr(09)&chr(09)&"4 = Excellent")
  • inF.writeLine("--------------------------------------------------------------------------")
  • inF.writeLine("")
  • inF.writeLine("")
  • inF.writeLine ("+----------+--------+--------+--------+--------+")
  • inF.writeLine ("| Date | champ1 | champ2 | champ3 | champ4 |")
  • inF.writeLine ("+----------+--------+--------+--------+--------+")
  • for x = 0 to Ubound(tab1)
  • tabdatelong = Len(tabdate(x))
  • for xi = 1 to (10-tabdatelong)
  • espace = espace & chr(32)
  • next
  • tabdate(x) = tabdate(x) & espace
  • espace = ""
  • tabdatelong = Len(tab1(x))
  • for xi = 2 to (8-tabdatelong)
  • espace = espace & chr(32)
  • next
  • tab1(x) = tab1(x) & espace
  • espace = ""
  • tabdatelong = Len(tab2(x))
  • for xi = 2 to (8-tabdatelong)
  • espace = espace & chr(32)
  • next
  • tab2(x) = tab2(x) & espace
  • espace = ""
  • tabdatelong = Len(tab3(x))
  • for xi = 2 to (8-tabdatelong)
  • espace = espace & chr(32)
  • next
  • tab3(x) = tab3(x) & espace
  • espace = ""
  • tabdatelong = Len(tab4(x))
  • for xi = 2 to (8-tabdatelong)
  • espace = espace & chr(32)
  • next
  • tab4(x) = tab4(x) & espace
  • espace = ""
  • inF.writeLine("|"&tabdate(x)&"| "&tab1(x)&"| "&tab2(x)&"| "&tab3(x)&"| "&tab4(x)&"|")
  • next
  • inF.writeLine ("+----------+--------+--------+--------+--------+")
  • inF.writeLine("")
  • inF.writeLine("Fichier Généré automatiquement le "&date)
  • end if
  • inF.close
  • ' 4. Fermeture de la connexion à la BD
  • OBJdbConnection.close : set OBJdbConnection = nothing
  • Response.Redirect"files/"&Request("type")
  • end if
  • %>
<%
Action = right(UCase(Request("type")),3)
If Action <> "" Then ' Arrivée du formulaire
   ' 2. Tri de la Base de Données

     dbPath = Server.MapPath("mdb/satisfaction.mdb")
   ' Création de l'objet permettant la connexion
     Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
   ' Connexion
     OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};" _
   & " DBQ=" & dbPath

if ((Request("jd") <> 0) and (Request("md") <> 0) and (Request("ad") <> 0) and (Request("jf") <> 0) and (Request("mf") <> 0) and (Request("af") <> 0) and request("moy") = 0)  then

SQLQuery = "SELECT * FROM stat WHERE date BETWEEN {d '"&Request("ad")&"-"&Request("md")&"-"&Request("jd")&"'} AND {d '"&Request("af")&"-"&Request("mf")&"-"&Request("jf")&"'} ORDER by date"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQLQuery, OBJdbConnection, 1, 2
      
        NbRecord = Rs.RecordCount - 1
        redim tabdate(NbRecord)
        redim tab1(NbRecord)
        redim tab2(NbRecord)
        redim tab3(NbRecord)
        redim tab4(NbRecord)

            
      i = 0
      While Not rs.eof
         tabdate(i) = rs("date")
         tab1(i) = (int(rs("champ1")*100))/100
         tab2(i) = (int(rs("champ2")*100))/100
         tab3(i) = (int(rs("champ3")*100))/100
         tab4(i) = (int(rs("champ4")*100))/100
         i=i+1
         Rs.MoveNext
      wend
rs.close


elseif (Request("moy") <> 0 ) then

  if(Request("moy") = 1) then valint = "ww"
  if(Request("moy") = 2) then valint = "m"
  if(Request("moy") = 3) then valint = "yyyy"
  if(Request("moy") = 4) then valint = "d"

  if ((Request("jd") <> 0) and (Request("md") <> 0) and (Request("ad") <> 0) and (Request("jf") <> 0) and (Request("mf") <> 0) and (Request("af") <> 0))  then
  ad = Request("ad")
  md = Request("md")
  jd = Request("jd")
  af = Request("af")
  mf = Request("mf")
  jf = Request("jf")
  else
  ad = 2003
  md = 1
  jd = 1
  af = year(date)
  mf = month(date)
  jf = day(date)
  end if

    seriald = dateSerial(ad,md,jd)
    serialf = dateSerial(af,mf,jf)

    diffdate = dateDiff(valint , seriald, serialf)

        redim tabdate(diffdate)
        redim tab1(diffdate)
        redim tab2(diffdate)
        redim tab3(diffdate)
        redim tab4(diffdate)

        i = 0
    for dx = 0 to diffdate

    countdated = dateAdd(valint,dx,seriald)
      ac = year(countdated)
      mc = month(countdated)
      jc = day(countdated)

    countdatef = dateAdd(valint,dx+1,seriald)
    countdatef = dateAdd("d",-1,countdatef)
      acf = year(countdatef)
      mcf = month(countdatef)
      jcf = day(countdatef)


    Set rs = Server.CreateObject("ADODB.Recordset")
    SQLQuery = "SELECT AVG(Champ1) AS moyenne1, AVG(Champ2) AS moyenne2, AVG(Champ3) AS moyenne3, AVG(Champ4) AS moyenne4 FROM stat WHERE date BETWEEN #"&ac&"-"&mc&"-"&jc&"# AND #"&acf&"-"&mcf&"-"&jcf&"#"
    rs.Open SQLQuery, OBJdbConnection, 1, 2

    if (rs("moyenne1") <> "") then
         
         tabdate(i) = jc&"/"&mc&"/"&ac
         if (valint = "yyyy") then
         tabdate(i) = "xx/xx/"&ac
         end if
         if (valint = "m") then
         tabdate(i) = "xx/"&mc&"/"&ac
         end if

         tab1(i) = (int(rs("moyenne1")*100))/100
         tab2(i) = (int(rs("moyenne2")*100))/100
         tab3(i) = (int(rs("moyenne3")*100))/100
         tab4(i) = (int(rs("moyenne4")*100))/100
         i = i + 1
    end if

    rs.close

    next

        redim PRESERVE tabdate(i-1)
        redim PRESERVE tab1(i-1)
        redim PRESERVE tab2(i-1)
        redim PRESERVE tab3(i-1)
        redim PRESERVE tab4(i-1)

 else
    Set rs = Server.CreateObject("ADODB.Recordset")
SQLQuery = "SELECT * FROM stat ORDER by date"
rs.Open SQLQuery, OBJdbConnection, 1, 2
NbRecord = Rs.RecordCount - 1
        redim tabdate(NbRecord)
        redim tab1(NbRecord)
        redim tab2(NbRecord)
        redim tab3(NbRecord)
        redim tab4(NbRecord)

       i = 0
      While Not rs.eof
         tabdate(i) = rs("date")
         tab1(i) = (int(rs("champ1")*100))/100
         tab2(i) = (int(rs("champ2")*100))/100
         tab3(i) = (int(rs("champ3")*100))/100
         tab4(i) = (int(rs("champ4")*100))/100
         i=i+1
         Rs.MoveNext
      wend
rs.close

end if

   ' 3. Création du fichier

   Set FSO = Server.CreateObject("Scripting.FileSystemObject")
   dim dir : dir = Server.MapPath("files")
   set inF = FSO.CreateTextFile(dir&"/"&Request("type"))

   ' Fichier au format Excel (.slk)
   if right(Request("type"),3)="slk" then
      inF.writeLine"ID;PWXL;N;E" ' Début du codage excel
      ' chr (34) remplace les guillements à la suite de l'instruction
      inF.writeLine"C;Y1;X1;K"&chr(34)&("Date")&chr(34)
      inF.writeLine"C;Y1;X2;K"&chr(34)&("Qualité d'accueil et d'écoute")&chr(34)
      inF.writeLine"C;Y1;X3;K"&chr(34)&("Qualité des réponses fournies")&chr(34)
      inF.writeLine"C;Y1;X4;K"&chr(34)&("Délai de résolution satisfaisant")&chr(34)
      inF.writeLine"C;Y1;X5;K"&chr(34)&("Facilité à joindre la hotline")&chr(34)
      i=2 ' Affichage à partir de la ligne 2
      
       for x = 0 to Ubound(tab1)
         inF.writeLine"C;Y"&x+2&";X1;K"&chr(34)&(tabdate(x))&chr(34)
         inF.writeLine"C;Y"&x+2&";X2;K"&chr(34)&(tab1(x))&chr(34)
         inF.writeLine"C;Y"&x+2&";X3;K"&chr(34)&(tab2(x))&chr(34)
         inF.writeLine"C;Y"&x+2&";X4;K"&(chr(34)&tab3(x))&chr(34)
         inF.writeLine"C;Y"&x+2&";X5;K"&chr(34)&(tab4(x))&chr(34)
       next
      inF.writeLine"E" ' Fin du codage excel

   ' ou fichier au format texte (.txt)
   else
   inF.writeLine("Notes :")
   inF.writeLine("champ1 = Qualité d'accueil et d'écoute"&chr(09)&chr(09)&chr(09)&"1 = Mauvais")
   inF.writeLine("champ2 = Qualité des réponses fournies"&chr(09)&chr(09)&chr(09)&"2 = Moyen")
   inF.writeLine("champ3 = Délai de résolution satisfaisant"&chr(09)&chr(09)&"3 = Satisfaisant")
   inF.writeLine("champ4 = Facilité à joindre la hotline"&chr(09)&chr(09)&chr(09)&"4 = Excellent")
   inF.writeLine("--------------------------------------------------------------------------")
   inF.writeLine("")
   inF.writeLine("")
   inF.writeLine     ("+----------+--------+--------+--------+--------+")
      inF.writeLine  ("|   Date   | champ1 | champ2 | champ3 | champ4 |")
   inF.writeLine     ("+----------+--------+--------+--------+--------+")
      for x = 0 to Ubound(tab1)

         tabdatelong = Len(tabdate(x))
         for xi = 1 to (10-tabdatelong)
           espace = espace & chr(32)
         next
        tabdate(x) = tabdate(x) & espace
        espace = ""
        
         tabdatelong = Len(tab1(x))
         for xi = 2 to (8-tabdatelong)
           espace = espace & chr(32)
         next
        tab1(x) = tab1(x) & espace
        espace = ""
        
         tabdatelong = Len(tab2(x))
         for xi = 2 to (8-tabdatelong)
           espace = espace & chr(32)
         next
        tab2(x) = tab2(x) & espace
        espace = ""
        
         tabdatelong = Len(tab3(x))
         for xi = 2 to (8-tabdatelong)
           espace = espace & chr(32)
         next
        tab3(x) = tab3(x) & espace
        espace = ""
        
         tabdatelong = Len(tab4(x))
         for xi = 2 to (8-tabdatelong)
           espace = espace & chr(32)
         next
        tab4(x) = tab4(x) & espace
        espace = ""
        

         inF.writeLine("|"&tabdate(x)&"| "&tab1(x)&"| "&tab2(x)&"| "&tab3(x)&"| "&tab4(x)&"|")
       next
      inF.writeLine     ("+----------+--------+--------+--------+--------+")
    inF.writeLine("")
    inF.writeLine("Fichier Généré automatiquement le "&date)
   end if
   inF.close

   ' 4. Fermeture de la connexion à la BD

   OBJdbConnection.close : set OBJdbConnection = nothing

   Response.Redirect"files/"&Request("type")
   end if
%>

 Conclusion

&lt;%="voir le fichier zip pour la base de donnee (access)" %&gt;

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  • export.aspTélécharger ce fichier [Réservé aux membres club]Voir ce fichier19 653 octets
  •   files
  •   mdb
    • satisfaction.mdbTélécharger ce fichier [Réservé aux membres club]167 936 octets

Télécharger le zip


 Sources de la même categorie

Source avec Zip GESTION_ENSEIGNANTS par Elmarzougui
Source avec Zip ZONE MEMBRE EN ASP "E-MEMBRES1.0" par cmaelc
Source avec Zip Source avec une capture Source .NET (Dotnet) ADMINISTRATION BASE DE DONNÉES ORACLE par chbayah
Source avec Zip Source avec une capture Source .NET (Dotnet) UTILISATION D'UN DATASET par ManuAntibes
Source avec Zip Source .NET (Dotnet) INSERTION / RECUPERATION D'IMAGE STOCKEE DANS UNE DB MS SQL ... par jimmy69

Commentaires et avis

Commentaire de fabrice69 le 03/09/2003 01:03:23 administrateur CS

A utiliser pour s'inspirer de la manipulation du fichier SLK (Xls) via ASP.
En revanche, toute la génération de stat est propre à ta base et devra être adaptée en cas d'utilisation par quelqu'un d'autre.

F___

Commentaire de hamet le 03/01/2004 19:49:36

Je cherche un bon moyen de faire des statistique via ASP.NEt (hmbaye@frequenceplus.fr

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,468 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales