Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [WebMethod]
- public string ListeArticles()
- {
- string requete = "SELECT code_article, designation, prix_unitaire FROM article d ";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- var linq =
- (
- from f in resultat
- select
- new
- {
- cdeArticle = int.Parse(f.Split(';')[0]),
- libelle = f.Split(';')[1],
- prix = float.Parse(f.Split(';')[2]),
- }
- );
- string résultat = "<articles>";
- foreach (var detail in linq)
- {
- résultat +=
- "<article><codeArticle> " + detail.cdeArticle + "</codeArticle>" +
- "<libelle> " + detail.libelle + "</libelle>" +
- "<prix> " + detail.prix + "</prix></article>";
- }
- résultat += "</articles>";
- return résultat;
- }
- [WebMethod]
- public string ListeClient()
- {
- string requete = "SELECT code_client, raison_sociale FROM client ";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- var linq =
- (
- from f in resultat
- select
- new
- {
- cdeClient = int.Parse(f.Split(';')[0]),
- raisonSociale = f.Split(';')[1],
- }
- );
- string résultat = "<clients>";
- foreach (var detail in linq)
- {
- résultat +=
- "<client><code> " + detail.cdeClient + "</code>" +
- "<RaisonSociale> " + detail.raisonSociale + "</RaisonSociale></client>";
- }
- résultat += "</clients>";
- return résultat;
- }
- [WebMethod]
- public string GetCodeFactures()
- {
- const string requete = "SELECT code_facture FROM facture order by code_facture";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- return String.Join(";", resultat);
- }
- // GetByIDClient()
- [WebMethod]
- public string AfficheFactureByIdClient(int IdClient)
- {
- string requete = "SELECT f.code_facture, f.date, f.total FROM Facture f where f.code_client = " + IdClient + " ";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- var linq =
- (
- from f in resultat
- select
- new
- {
- cdeFact = int.Parse(f.Split(';')[0]),
- date = DateTime.Parse(f.Split(';')[1]),
- total = double.Parse(f.Split(';')[2]),
- }
- );
- string résultat = "<factures>";
- foreach (var detail in linq)
- {
- résultat +=
- "<facture><codeFacture> " + detail.cdeFact + "</codeFacture>" +
- "<date> " + detail.date + "</date>" +
- "<total> " + detail.total + "</total></facture>";
- }
- résultat += "</factures>";
- return résultat;
- }
- // GetByIDFacture()
- [WebMethod]
- public string AfficheFactureByIdFacture(int Id)
- {
- 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 + " ";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- var linq =
- (
- from f in resultat
- select
- new
- {
- LibelleFacture = f.Split(';')[0],
- qte = int.Parse(f.Split(';')[1]),
- total = double.Parse(f.Split(';')[2]),
- taux = float.Parse(f.Split(';')[3]),
- totalFacture = float.Parse((f.Split(';')[4]))
- }
- );
- string résultat = "<details>";
- foreach (var detail in linq)
- {
- résultat +=
- "<detail><libelle> " + detail.LibelleFacture + "</libelle>" +
- "<qte> " + detail.qte + "</qte>" +
- "<total> " + detail.total + "</total>" +
- "<taux> " + detail.taux + "</taux>" +
- "<totalFacture> " + detail.totalFacture + "</totalFacture></detail>";
- }
- résultat += "</details>";
- return résultat;
- }
- // GetAll()
- [WebMethod]
- public string AfficheFactureGetAll()
- {
- 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";
- DonneeMYSQL d = new DonneeMYSQL("PAPETTERIE");
- List<string> resultat = d.ExecuterRequete(requete, false);
- var linq =
- (
- from f in resultat
- select
- new
- {
- LibelleFacture = f.Split(';')[0],
- qte = int.Parse(f.Split(';')[1]),
- total = double.Parse(f.Split(';')[2]),
- taux = float.Parse(f.Split(';')[3]),
- totalFacture = float.Parse((f.Split(';')[4]))
- }
- );
- string résultat = "<details>";
- foreach (var detail in linq)
- {
- résultat +=
- "<detail><libelle> " + detail.LibelleFacture + "</libelle>" +
- "<qte> " + detail.qte + "</qte>" +
- "<total> " + detail.total + "</total>" +
- "<taux> " + detail.taux + "</taux>" +
- "<totalFacture> " + detail.totalFacture + "</totalFacture></detail>";
- }
- résultat += "</details>";
- return résultat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement