Академический Документы
Профессиональный Документы
Культура Документы
T P ASP
Objectifs :
1- Créer des users pour l’utilisation des forms (sécurité de l’application)
2- Créer un page Master avec ses différents pages de contenus .
3- Créer un Web Service
4- Utilisation des états.(CrystalReport)
5- Exporter les données dans un fichier XML .
Solution
Etape 1 :
Créer la base de données avec ses différentes tables .
----------------Création de la base et les 3 tables ----------------------
------
create database gestion_Notes
24/05/2017
Ensuite créer des users sur Web config (double clique sur
Webconfig)
<authentication mode="Forms">
<forms name=".namesuffix" loginUrl="WebForm1.aspx">
<credentials passwordFormat="Clear">
<user name="ali" password="password1"/>
<user name="ahmed" password="password2"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?"/>
<allow users="toto"/>
</authorization>
<httpHandlers><add verb="GET" path="CrystalImageHandler.aspx"
type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web,
24/05/2017
Version=13.0.2000.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304"/></httpHandlers></system.web>
{
if (!IsPostBack)
{
DropDownList1.AutoPostBack = true;
sc.Open();
cmd.CommandText = "select idstg from stagiaire ";
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataValueField = "idstg";
DropDownList1.DataTextField = "idstg";
DropDownList1.DataBind();
sc.Close();
}
24/05/2017
}
//Code DropDownList
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
sc.Open();
cmd.CommandText="select AVG(note) from stagiaire stg , note n where
stg.idstg=n.idstg and stg.idstg="+DropDownList1.SelectedValue+" ";
Label1.Text = cmd.ExecuteScalar().ToString();
sc.Close();
}
[WebMethod]
public int afficherstg()
{
SqlConnection sc = new SqlConnection(@"Data Source=.;Initial
Catalog=gestion_Notes;Integrated Security=True");
sc.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select COUNT(idstg) from stagiaire where idstg
in(select note.idstg from note group by idstg having AVG(note)>=10 );";
cmd.Connection = sc;
return (int)cmd.ExecuteScalar();
}
b/ appeler Web Service
pour appeler web service :
créer un webform et ajouter un textbox et un bouton
// exporter
SqlDataAdapter sda = new SqlDataAdapter("select nom , prenom, AVG(note) as
'Moyenne des notes ' from stagiaire stg , note n where stg.idstg=n.idstg group by nom
,prenom ",sc);
DataSet ds = new DataSet();
sda.Fill(ds, "ddd");
ds.WriteXml(MapPath("test2.xml"));