using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using WebApp.Components; using basic; using System.Text.RegularExpressions; public partial class ProDetail : System.Web.UI.Page { public int intID; public string strParentColumnName = ""; public string strColumnName = "Product display"; public string strColumnSubName = "Product"; public string strProName; public string strProBianhao; public string strProChandi; public string strKeywords; public string strPutdate; public int intHits; public string strProPath; public string strProDescription; public string[] ConImg = { "" }; public string strPhone; public BasicPage bp = new BasicPage(); public MyClass mc = new MyClass(); public int intPrevious; public int intNext; public string strPrevious = "No more"; public string strNext = "No more"; public string strPreviousUrl = "#"; public string strNextUrl = "#"; public string yangban; public string strQQ; protected void Page_Load(object sender, EventArgs e) { SystemTools systemtools = new SystemTools(); if (systemtools.IsNumberic(Request["ProId"])) { intID = Int32.Parse(Request["ProId"]); //上一个产品,下一个产品 showPreviousAndNext(intID); //调用类 Common common = new Common(); //读取整站SEO的设置信息 ClientSEO clientseo = common.showSEO(); this.Title = clientseo.WebTitle; description.Attributes["content"] = clientseo.WebDescription; keywords.Attributes["content"] = clientseo.WebKeywords; //联系方式 Contact contact = new Contact(); contact = common.showContact(); strPhone = contact.Phone; strQQ = contact.QQ; //根据ID显示内容 showContent(); showPro(); showpinglun(); Getshoucang(); showshuxingfenlei(); showjiage(); showShop(); } else { Response.Write("您的请求带有不合法的参数,谢谢合作!"); Response.End(); } } public string paths; public string content1; public string content2; public string strProKeyDescription; public string strProPrice; protected void showContent() { Products products = new Products(); SqlDataReader reader = products.GetSingleProduct(intID); if (reader.Read()) { strProName = reader["ProName"].ToString(); strProBianhao = reader["ProBianhao"].ToString(); strProChandi = reader["ProChandi"].ToString(); strKeywords = reader["Keywords"].ToString(); strPutdate = Convert.ToDateTime(reader["Putdate"].ToString()).ToString("yyyy-MM-dd"); strProPath = reader["ProPath"].ToString(); strProPrice = reader["ProPrice"].ToString(); strProDescription = reader["ProDescription"].ToString(); strProKeyDescription = reader["ProKeyDescription"].ToString(); content1 = reader["content1"].ToString(); content2 = reader["content2"].ToString(); paths = reader["paths"].ToString(); if (paths == "") { paths = strProPath; } else { paths = strProPath + "|" + paths; } ConImg = paths.Split('|'); } reader.Close(); this.Title = strProName + "-" + mc.ShowWebsiteKeyById(1, "CompanyName"); } //产品展示 public DataTable dtPro = new DataTable(); public int intPro; public void showPro() { dtPro = bp.SelectDataBase("product", "select top 8 * from product where Proid<>" + intID + " order by paixu desc,proid desc").Tables[0]; intPro = dtPro.Rows.Count; } public void showPreviousAndNext(int ID) { MyClass mc = new MyClass(); Products products = new Products(); SqlDataReader reader = products.GetAllProducts(); DataTable dtbl = SystemTools.ConvertDataReaderToDataTable(reader); DataSet dstProducts = new DataSet(); dstProducts.Tables.Add(dtbl); intPrevious = ID; intNext = ID; for (int i = 0; i < dstProducts.Tables[0].Rows.Count; i++) { if (intID == Int32.Parse(dstProducts.Tables[0].Rows[i]["ProId"].ToString())) { if (i >= 1) { intNext = Int32.Parse(dstProducts.Tables[0].Rows[i - 1]["ProId"].ToString()); //strNext = dstProducts.Tables[0].Rows[i - 1]["ProName"].ToString(); strNext = "Previous product"; strNextUrl = "ProDetail.aspx?ProId=" + intNext; } if (i < dstProducts.Tables[0].Rows.Count - 1) { intPrevious = Int32.Parse(dstProducts.Tables[0].Rows[i + 1]["ProId"].ToString()); //strPrevious = dstProducts.Tables[0].Rows[i + 1]["ProName"].ToString(); strPrevious = "Next product"; strPreviousUrl = "ProDetail.aspx?ProId=" + intPrevious; } } } } //产品展示 public DataTable dtpinglun = new DataTable(); public int intpinglun; public void showpinglun() { dtpinglun = bp.SelectDataBase("tbpinlun", "select * from tbpinlun where Proid=" + intID + " order by id desc").Tables[0]; intpinglun = dtpinglun.Rows.Count; } public bool IsNumberic(string oText)//判断是否是数字(包含小数) { try { Double var1 = System.Convert.ToDouble(oText); if (var1 > 0) { return true; } else { return false; } } catch { return false; } } public string isshoucang = "0"; public void Getshoucang() { string userphone = ""; try { userphone = Session["qzl_web_Name"].ToString(); } catch (Exception ex) { userphone = ""; } SqlDataReader myreader = bp.getRead("select * from tb_collect where userid='" + userphone + "' and Proid='" + intID + "'"); if (myreader.Read()) { isshoucang = "1"; } myreader.Close(); } //产品展示 public DataTable dtshuxingfenlei = new DataTable(); public int intshuxingfenlei; public void showshuxingfenlei() { dtshuxingfenlei = bp.SelectDataBase("tb_attribute", "select * from tb_attribute order by id asc").Tables[0]; intshuxingfenlei = dtshuxingfenlei.Rows.Count; } public DataTable dtshuxing = new DataTable(); public int intshuxing; public void showshuxing(string id) { dtshuxing = bp.SelectDataBase("tb_attribute_value", "select * from tb_attribute_value where classid='"+ id + "' and id in(select keyatt_id from tb_product_attribute_value where Proid = '"+intID+"') order by id asc").Tables[0]; intshuxing = dtshuxing.Rows.Count; } public string jiagejihe = ""; private void showjiage() { DataSet ds = bp.SelectDataBase("tb_product_attribute", "select * from tb_product_attribute where Proid = '" + intID + "' order by id asc"); int dv = ds.Tables[0].Rows.Count; jiagejihe = "{"; for (int i = 0; i < dv; i++) { string id = ds.Tables[0].Rows[i]["id"].ToString(); string jiage = ds.Tables[0].Rows[i]["jiage"].ToString(); string key = showattrvalue(id); jiagejihe += "\""+ key + "\":\"" + jiage + "\""; if (i != dv - 1) { jiagejihe += ","; } } jiagejihe += "}"; } public string showattrvalue(string id) { string content = ""; DataSet ds = bp.SelectDataBase("tb_product_attribute_value", "select * from tb_product_attribute_value where Proid = '" + intID + "' and attr_id='" + id + "' order by id asc"); DataView dv = ds.Tables[0].DefaultView; foreach (DataRowView drv in dv) { if (content == "") { content = drv["keyatt_id"].ToString(); } else { content += "-" + drv["keyatt_id"].ToString(); } } return content; } public string strShop = "0"; protected void showShop() { Time time = new Time(); int intID = 1; SqlDataReader reader = time.GetTimeLimit(intID); if (reader.Read()) { strShop = reader["SMSState"].ToString(); } reader.Close(); } }