-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetails.aspx.cs
59 lines (53 loc) · 1.77 KB
/
Details.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Details : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["articleId"] != null)
{
loadInfos();
}
else
{
Response.Redirect("ListCat.aspx");
}
}
protected void loadInfos()
{
try
{
string conString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection conn = new SqlConnection(conString);
conn.Open();
SqlCommand commande = new SqlCommand("SELECT * FROM article WHERE numArticle = @numArticle", conn);
SqlParameter param = new SqlParameter("@numArticle", Request.QueryString["articleId"]);
commande.Parameters.Add(param);
SqlDataReader reader = commande.ExecuteReader();
if (reader.Read())
{
lnumArticle.Text = Convert.ToString(reader[0]) + ".";
ldesignation.Text = Convert.ToString(reader[1]) + ".";
lprix.Text = Convert.ToString(reader[2]) + " DH.";
lstock.Text = Convert.ToString(reader[3]) + " unités.";
Image1.ImageUrl = Convert.ToString(reader[4]);
}
else
{
Response.Write("Une erreur est survenue lors de l'operation (Le produit demandé n'existe pas)");
}
reader.Close();
conn.Close();
}
catch (Exception exce)
{
Response.Write(exce.Message);
}
}
}