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
| protected void Page_Load(object sender, EventArgs e)
{
dplintitule = Request.QueryString["Intitule"];
dplid = Convert.ToInt32(Request.QueryString["Id"]);
Label1.Text = "Bienvenue à toi, " + dplintitule + ".";
Label4.Text = BL.ArticleBL.SommePrixArticleparPers(dplid).ToString();
if (Request.QueryString["Id"] != null)
{
string strQuery = "select A.Intitule, A.Description, A.Prix, A.Photo FROM Articles as A inner join Listes as L on A.Id_Liste = L.Id_Liste inner join Personnes as P on L.Id_Personne = P.Id_Personne where P.Id_Personne = @Id_Personne ";
String strConnString = "Data Source=" + System.Environment.MachineName + "\\SQLEXPRESS; Database=Listenoel;UID=Michael;PWD=****";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@Id_Personne", SqlDbType.Int).Value = Convert.ToInt32(Request.QueryString["Id"]);
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
DataTable dt = new DataTable();
try
{
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
GridView2.DataSource = dt;
GridView2.DataBind();
}
catch
{
dt = null;
}
finally
{
con.Close();
sda.Dispose();
con.Dispose();
}
if (dt != null)
{
Byte[] bytes = (Byte[])dt.Rows[0]["Photo"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.ContentType = dt.Rows[0]["Photo"].ToString();
Response.AppendHeader("content-disposition", "attachment;filename=" + dt.Rows[0]["Intitule"].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
} |
Partager