Advertisement
OlivierArgentieri

Method Webservice maquette WP

Mar 3rd, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.76 KB | None | 0 0
  1.         [WebMethod]
  2.         public string ListeArticles()
  3.         {
  4.             string requete = "SELECT code_article, designation, prix_unitaire FROM article d ";
  5.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  6.             List<string> resultat = d.ExecuterRequete(requete, false);
  7.  
  8.             var linq =
  9.                 (
  10.                     from f in resultat
  11.                     select
  12.                         new
  13.                         {
  14.                             cdeArticle = int.Parse(f.Split(';')[0]),
  15.                             libelle = f.Split(';')[1],
  16.                             prix = float.Parse(f.Split(';')[2]),
  17.                         }
  18.                     );
  19.             string résultat = "<articles>";
  20.             foreach (var detail in linq)
  21.             {
  22.                 résultat +=
  23.                     "<article><codeArticle> " + detail.cdeArticle + "</codeArticle>" +
  24.                     "<libelle> " + detail.libelle + "</libelle>" +
  25.                     "<prix> " + detail.prix + "</prix></article>";
  26.             }
  27.  
  28.             résultat += "</articles>";
  29.  
  30.             return résultat;
  31.         }
  32.  
  33.         [WebMethod]
  34.         public string ListeClient()
  35.         {
  36.             string requete = "SELECT code_client, raison_sociale FROM client ";
  37.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  38.             List<string> resultat = d.ExecuterRequete(requete, false);
  39.  
  40.             var linq =
  41.                 (
  42.                     from f in resultat
  43.                     select
  44.                         new
  45.                         {
  46.                             cdeClient = int.Parse(f.Split(';')[0]),
  47.                             raisonSociale = f.Split(';')[1],
  48.                         }
  49.                     );
  50.  
  51.  
  52.             string résultat = "<clients>";
  53.             foreach (var detail in linq)
  54.             {
  55.                 résultat +=
  56.                     "<client><code> " + detail.cdeClient + "</code>" +
  57.                     "<RaisonSociale> " + detail.raisonSociale + "</RaisonSociale></client>";
  58.             }
  59.             résultat += "</clients>";
  60.             return résultat;
  61.         }
  62.        
  63.         [WebMethod]
  64.         public string GetCodeFactures()
  65.         {
  66.             const string requete = "SELECT code_facture FROM facture order by code_facture";
  67.  
  68.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  69.             List<string> resultat = d.ExecuterRequete(requete, false);
  70.  
  71.             return String.Join(";", resultat);
  72.         }
  73.  
  74.         // GetByIDClient()
  75.         [WebMethod]
  76.         public string AfficheFactureByIdClient(int IdClient)
  77.         {
  78.             string requete = "SELECT f.code_facture, f.date, f.total  FROM Facture f where f.code_client = " + IdClient + " ";
  79.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  80.             List<string> resultat = d.ExecuterRequete(requete, false);
  81.  
  82.             var linq =
  83.                 (
  84.                     from f in resultat
  85.                     select
  86.                         new
  87.                         {
  88.                             cdeFact = int.Parse(f.Split(';')[0]),
  89.                             date = DateTime.Parse(f.Split(';')[1]),
  90.                             total = double.Parse(f.Split(';')[2]),
  91.                         }
  92.                     );
  93.  
  94.             string résultat = "<factures>";
  95.             foreach (var detail in linq)
  96.             {
  97.                 résultat +=
  98.                     "<facture><codeFacture> " + detail.cdeFact + "</codeFacture>" +
  99.                     "<date> " + detail.date + "</date>" +
  100.                     "<total> " + detail.total + "</total></facture>";
  101.             }
  102.  
  103.             résultat += "</factures>";
  104.  
  105.             return résultat;
  106.         }
  107.  
  108.         // GetByIDFacture()
  109.         [WebMethod]
  110.         public string AfficheFactureByIdFacture(int Id)
  111.         {
  112.             string requete = "SELECT d.Libelle, d.qte, d.total, d.taux, f.total  FROM detail d, Facture f where  d.code_facture = f.code_facture AND f.code_facture = " + Id + " ";
  113.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  114.             List<string> resultat = d.ExecuterRequete(requete, false);
  115.  
  116.             var linq =
  117.                 (
  118.                     from f in resultat
  119.                     select
  120.                         new
  121.                         {
  122.                             LibelleFacture = f.Split(';')[0],
  123.                             qte = int.Parse(f.Split(';')[1]),
  124.                             total = double.Parse(f.Split(';')[2]),
  125.                             taux = float.Parse(f.Split(';')[3]),
  126.                             totalFacture = float.Parse((f.Split(';')[4]))
  127.                         }
  128.                     );
  129.  
  130.             string résultat = "<details>";
  131.             foreach (var detail in linq)
  132.             {
  133.                 résultat +=
  134.                     "<detail><libelle> " + detail.LibelleFacture + "</libelle>" +
  135.                     "<qte> " + detail.qte + "</qte>" +
  136.                     "<total> " + detail.total + "</total>" +
  137.                     "<taux> " + detail.taux + "</taux>" +
  138.                     "<totalFacture> " + detail.totalFacture + "</totalFacture></detail>";
  139.             }
  140.             résultat += "</details>";
  141.  
  142.             return résultat;
  143.         }
  144.  
  145.         // GetAll()
  146.         [WebMethod]
  147.         public string AfficheFactureGetAll()
  148.         {
  149.             string requete = "SELECT d.Libelle, d.qte, d.total, d.taux, f.total  FROM detail d, Facture f where  d.code_facture = f.code_facture";
  150.             DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
  151.             List<string> resultat = d.ExecuterRequete(requete, false);
  152.  
  153.             var linq =
  154.                 (
  155.                     from f in resultat
  156.                     select
  157.                         new
  158.                         {
  159.                             LibelleFacture = f.Split(';')[0],
  160.                             qte = int.Parse(f.Split(';')[1]),
  161.                             total = double.Parse(f.Split(';')[2]),
  162.                             taux = float.Parse(f.Split(';')[3]),
  163.                             totalFacture = float.Parse((f.Split(';')[4]))
  164.                         }
  165.                     );
  166.             string résultat = "<details>";
  167.             foreach (var detail in linq)
  168.             {
  169.                 résultat +=
  170.                     "<detail><libelle> " + detail.LibelleFacture + "</libelle>" +
  171.                     "<qte> " + detail.qte + "</qte>" +
  172.                     "<total> " + detail.total + "</total>" +
  173.                     "<taux> " + detail.taux + "</taux>" +
  174.                     "<totalFacture> " + detail.totalFacture + "</totalFacture></detail>";
  175.             }
  176.             résultat += "</details>";
  177.  
  178.             return résultat;
  179.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement