0% found this document useful (0 votes)
16 views5 pages

Correction EFM

CorrectionEFM informatique ofppt

Uploaded by

opcm2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Correction EFM

CorrectionEFM informatique ofppt

Uploaded by

opcm2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Correction :

Question 1 A
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Connection.aspx.cs" Inhe
rits="MvcApplication4.Connection" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<link href="Content/bootstrap.css" rel="stylesheet" />


<style>
#main {
width:60%;
margin:auto;
background:#faf6f6;
padding:6px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="cotainer" id="main">
<div class="form-group">
<label for="TextBoxMatricule">Matricule:</label>
<asp:TextBox ID="TextBoxMatricule" runat="server" CssClass="form-
control"></asp:TextBox>
</div>

<div class="form-group">
<label for="TextBoxPW">mot de passe:</label>
<asp:TextBox ID="TextBoxPW" runat="server" CssClass="form-
control" TextMode="Password"></asp:TextBox>
</div>
<asp:Button ID="Button1" runat="server" Text="connexion" CssClass="btn btn
-primary btn-block" OnClick="Button1_Click" />
<asp:Label ID="LabelInfo" runat="server" Text="Label" style="color:red" ></as
p:Label>
</div>

</form>
</body>
</html>

Question 1 B et c
protected void Button1_Click(object sender, EventArgs e)
{
string strcn = @"data source=localhost;initial catalog=EFM_ASP_Co
rrection;integrated security=true";

SqlConnection cn = new SqlConnection(strcn);


SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select nom from Employes where matricule=@matr
icule and pass=@pass and EtatCompte='Activé'";
cmd.Parameters.AddWithValue("@matricule", TextBoxMatricule.Text);
cmd.Parameters.AddWithValue("@pass", TextBoxPW.Text);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["matricule"] = TextBoxMatricule.Text;
Session["nom"] = dr["nom"].ToString();
Response.Redirect("~/mesTaches.aspx");
}
else
{

LabelInfo.Text = "verifiez vos données!!!!!";


} }

------------------------------------------------------------------------------
1) Mes Tâches :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mesTaches.aspx.cs" In
herits="MvcApplication4.mesTaches" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" >
<div>
<asp:Label ID="LabelInfo" runat="server" Text="Label"></asp:Label>
<h1>mes taches</h1>
<asp:HiddenField ID="HiddenFieldMatricule" runat="server" />
<asp:GridView ID="GridViewTaches" runat="server"></asp:GridView>

<label id="nbTaches"></label>

</div>
</form>

//question 3 A et B
<script>

window.addEventListener("DOMContentLoaded", getNbTaches);

function getNbTaches() {
let valMatricule = document.getElementById("HiddenFieldMatricule").value;
let matricule = { Data: valMatricule };
console.log(matricule);
let xhr = new XMLHttpRequest();

xhr.open("GET", "http:www.rhMaroc.net/Taches");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "*/*");
xhr.send(JSON.stringify(matricule))
xhr.onload = function () {

let response = xhr.responseText;


let nbTaches = JSON.parse(response);
console.log(nbTaches);
document.getElementById("nbTaches").innerHTML = "Nombre des tac
hes affectés est:" + nbTaches.nb;

}
}

</script>
</body>
</html>

Question 2 A et b

protected void Page_Load(object sender, EventArgs e)


{
if (Session["nom"] != null && Session["matricule"] != null)
{
HiddenFieldMatricule.Value = Session["matricule"].ToString();
LabelInfo.Text = "Session matricule:" + Session["matricule"].ToStr
ing() + " nom:" + Session["nom"].ToString();
string mat = Session["matricule"].ToString();
GetTaches(mat);
}
}

private void GetTaches(string matricule)


{
string strcn = @"data source=localhost;initial catalog=EFM_ASP_Correcti
on;integrated security=true";

SqlConnection cn = new SqlConnection(strcn);


SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
string query = "select t.intitule,t.dateDebut,t.dateFin , DATEDIFF(DAY,
t.dateDebut,t.dateFin) as [durée Tache]," +
" p.intitule from taches t,projets p where t.codeProjet=p.codePrj a
nd EmployeResponsable=@matricule";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@matricule", matricule);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
GridViewTaches.DataSource = dr;
GridViewTaches.DataBind();
}

You might also like