Sei sulla pagina 1di 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;

namespace SOFTEC
{
/// <summary>
/// Description r�sum�e de NombreCommande
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// Pour autoriser l'appel de ce service Web depuis un script � l'aide d'ASP.NET
AJAX, supprimez les marques de commentaire de la ligne suivante.
// [System.Web.Script.Services.ScriptService]
public class NombreCommande : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]

public int NombrCommande(int id)


{
SqlConnection Con = new SqlConnection(@"Data
Source=hohi\sqlexpress;Initial Catalog=softec;Integrated Security=True");

string req1 = string.Format("select count(C.idcommande) from Commande


C inner join lignecommande L on L.idcommande=C.idcommande inner join Produit P on
L.idProduit=P.idProduit inner join Artisan A on A.idArtisan=P.idArtisan where
A.idArtisan='"+id+"'");
SqlCommand cmd1 = new SqlCommand(req1, Con);
Con.Open();
int i = (int)cmd1.ExecuteScalar();

Con.Close();
return i;
}
[WebMethod]
public Object chiffreaff(int id)
{
SqlConnection Con = new SqlConnection(@"Data
Source=hohi\sqlexpress;Initial Catalog=softec;Integrated Security=True");
Object x;
string req = string.Format("select sum(prixUnitaire) from Produit P
inner join Artisan A on A.idArtisan=P.idArtisan inner join lignecommande L on
L.idProduit=P.idProduit inner join Commande C on L.idcommande=C.idcommande where
A.idArtisan='" + id + "' and datepart(YEAR,datecommande)=2015");
SqlCommand cmd = new SqlCommand(req, Con);
Con.Open();
x = (Object)cmd.ExecuteScalar();
Con.Close();
return x;
}

}
}

Potrebbero piacerti anche