using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml.Xsl;
namespace AeroNet
{
///
/// Summary description for ProductDetail.
///
public class ProductDetail : Common
{
protected int pnum;
protected int mnum;
protected string Manufacturer="";
protected string logo="";
protected string Articul="";
protected string ModelName="";
protected decimal UnitCost=0;
protected void PrintProductNotes()
{
try
{
Transform("ProductNotes.xml?pnum="+pnum.ToString(),"ProductNotes.xsl",this.Response,1);
}
catch
{
Response.Redirect("error.aspx",true);
}
}
protected void PrintArticles()
{
try
{
Transform("Articles.xml?pnum="+pnum.ToString(),"Articles.xsl",this.Response,1);
}
catch
{
Response.Redirect("error.aspx",true);
}
}
private void Page_Load(object sender, System.EventArgs e)
{
try
{
//Получить pnum из строки запроса
if (Request.QueryString["pnum"] == null)
{
Response.Redirect("error.aspx",true);
}
else
{
pnum = Convert.ToInt32(Request.QueryString["pnum"]);
}
//Получить mnum, Articul, ModelName
string strSQL = "SELECT mnum, articul, name, UnitCost FROM V_ProductsTitle WHERE pnum = "+pnum.ToString();
SqlConnection Conn = new SqlConnection(connString);
SqlCommand Command = new SqlCommand(strSQL,Conn);
Conn.Open();
try
{
SqlDataReader Reader;
Reader = Command.ExecuteReader();
if(Reader.Read())
{
mnum = Reader.GetInt32(0);
Articul = Reader.GetString(1);
ModelName = Reader.GetString(2);
UnitCost = Reader.GetDecimal(3);
}
Reader.Close();
}
catch
{
Response.Redirect("error.aspx",true);
}
finally
{
Conn.Close();
}
//Получить Manufacturer, logo
string strSQL2 = "SELECT fullname, logo FROM V_ModelManufacturer WHERE mnum = "+mnum.ToString();
SqlConnection Conn2 = new SqlConnection(connString);
SqlCommand Command2 = new SqlCommand(strSQL2,Conn2);
Conn2.Open();
try
{
SqlDataReader Reader2;
Reader2 = Command2.ExecuteReader();
if(Reader2.Read())
{
Manufacturer = Reader2.GetString(0);
logo = Reader2.GetString(1);
}
Reader2.Close();
}
catch
{
Response.Redirect("error.aspx",true);
}
finally
{
Conn2.Close();
}
}
catch
{
Response.Redirect("error.aspx",true);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}