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 Products. /// public class Products : Common { protected int ptype; protected int parent; protected int sub; protected string name; protected string CategoryName=""; protected string SubTitles=""; protected string ParentName=""; protected string Manufacturer=""; protected string logo=""; protected int mnum; protected void GetType (int type) { string strSQL = "SELECT CategoryName FROM V_Category WHERE CategoryType ="+type.ToString(); SqlConnection Conn = new SqlConnection(connString); SqlCommand Command = new SqlCommand(strSQL,Conn); Conn.Open(); try { SqlDataReader Reader; Reader = Command.ExecuteReader(); if(Reader.Read()) { name = Reader.GetString(0); } Reader.Close(); } catch { Response.Redirect("error.aspx",true); } finally { Conn.Close(); } } protected void GetParentType (int type) { string strSQL = "SELECT parent FROM V_Category WHERE CategoryType ="+type.ToString(); SqlConnection Conn = new SqlConnection(connString); SqlCommand Command = new SqlCommand(strSQL,Conn); Conn.Open(); try { SqlDataReader Reader; Reader = Command.ExecuteReader(); if(Reader.Read()) { parent = Reader.GetInt32(0); } Reader.Close(); } catch { Response.Redirect("error.aspx",true); } finally { Conn.Close(); } } protected void GetManufacturer(int type) { string strSQL = "SELECT TOP 1 fullname, logo, mnum FROM V_ModelManufacturer WHERE CategoryType = "+type.ToString(); SqlConnection Conn = new SqlConnection(connString); SqlCommand Command = new SqlCommand(strSQL,Conn); Conn.Open(); try { SqlDataReader Reader; Reader = Command.ExecuteReader(); if(Reader.Read()) { Manufacturer = Reader.GetString(0); logo = Reader.GetString(1); mnum = Reader.GetInt32(2); } Reader.Close(); } catch { Response.Redirect("error.aspx",true); } finally { Conn.Close(); } } protected void PrintManufacturer() { try { XsltArgumentList xslArg = new XsltArgumentList(); xslArg.AddParam("mnum","",mnum.ToString()); xslArg.AddParam("ptype","",ptype.ToString()); if (sub == 0) { Transform("Manufacturer.xml?ptype="+ptype.ToString(),"Manufacturer.xsl",xslArg,this.Response,1); } else { Transform("Manufacturer.xml?ptype="+sub.ToString(),"Manufacturer.xsl",xslArg,this.Response,1); } } catch { Response.Redirect("error.aspx",true); } } protected void PrintSubTitle() { try { XsltArgumentList args = new XsltArgumentList(); args.AddParam("ptype","",ptype); Transform("SubTitle.xml?ptype="+ptype.ToString(),"SubTitle.xsl",args,this.Response,1); } catch { Response.Redirect("error.aspx",true); } } protected void PrintCategoryNotes() { try { XsltArgumentList args = new XsltArgumentList(); args.AddParam("sub","",sub); Transform("CategoryNotes.xml?sub="+sub.ToString(),"CategoryNotes.xsl",args,this.Response,1); } catch { Response.Redirect("error.aspx",true); } } protected void PrintProductsTitle() { try { if (sub == 0) { if (((ptype >= 40) & (ptype <= 45))||((ptype >= 58) & (ptype <= 73))||((ptype >= 81) & (ptype <= 83))) { Transform("ProductsTitle.xml?ptype="+ptype.ToString()+"&mnum="+mnum.ToString(),"ColorTitle.xsl",this.Response,1); } else { Transform("ProductsTitle.xml?ptype="+ptype.ToString()+"&mnum="+mnum.ToString(),"ProductsTitle.xsl",this.Response,1); } } else { if (((ptype >= 40) & (ptype <= 45))||((ptype >= 58) & (ptype <= 73))||((ptype >= 81) & (ptype <= 83))) { Transform("ProductsTitle.xml?ptype="+sub.ToString()+"&mnum="+mnum.ToString(),"ColorTitle.xsl",this.Response,1); } else { Transform("ProductsTitle.xml?ptype="+sub.ToString()+"&mnum="+mnum.ToString(),"ProductsTitle.xsl",this.Response,1); } } } catch { Response.Redirect("error.aspx",true); } } private void Page_Load(object sender, System.EventArgs e) { //Загрузить верхнее меню TopMenu(); try { //Получить ptype из строки запроса if (Request.QueryString["ptype"] == null) { Response.Redirect("Catalog.aspx",true); } else { ptype = Convert.ToInt32(Request.QueryString["ptype"]); GetType (ptype); //Выводим названием текущей категории CategoryName = name.ToString(); GetParentType (ptype); GetType (parent); //Выводим название корневой категории ParentName = name.ToString(); } //Получить sub (текущую подкатегорию) из строки запроса if (Request.QueryString["sub"] == null) { sub = 0; SubTitles = CategoryName; } else { sub = Convert.ToInt32(Request.QueryString["sub"]); GetType (sub); SubTitles = name.ToString(); } //Получить mnum из строки запроса if (Request.QueryString["mnum"] == null) { if (sub == 0) { GetManufacturer(ptype); } else { GetManufacturer(sub); } } else { mnum = Convert.ToInt32(Request.QueryString["mnum"]); string strSQL = "SELECT fullname, logo FROM V_ModelManufacturer WHERE mnum = "+mnum.ToString(); SqlConnection Conn = new SqlConnection(connString); SqlCommand Command = new SqlCommand(strSQL,Conn); Conn.Open(); try { SqlDataReader Reader; Reader = Command.ExecuteReader(); if(Reader.Read()) { Manufacturer = Reader.GetString(0); logo = Reader.GetString(1); } Reader.Close(); } catch { Response.Redirect("error.aspx",true); } finally { Conn.Close(); } } } catch { Response.Redirect("Catalog.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 } }