62,269
社区成员
发帖
与我相关
我的任务
分享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;
public partial class ViewProduct : System.Web.UI.Page
{
public string keytitle, mytitle, keycontent, lbl_Author, lbl_AddTime, lbl_ReadCount,lbldz, lblyb, lbldh, lblEmail;
protected void Page_Load(object sender, EventArgs e)
{
pageload();
pageload1();
}
private void pageload()
{
string strqry;
if (!IsPostBack)
{
strqry = "Select * From Product where id =" + Request.QueryString["id"];
DataRow drw = DBFun.GetDataRow(strqry);
if (drw == null)
{
keycontent = "该作品已删除或不存在!";
return;
}
strqry = "Update Product Set ReadCount=ReadCount+1 where id =" + Request.QueryString["id"];
DBFun.ExecuteSql(strqry);
keytitle = drw["ProductName"].ToString();
lbl_AddTime = drw["AddTime"].ToString();
lbl_ReadCount = drw["ReadCount"].ToString();
keycontent = drw["Intro"].ToString();
mytitle = drw["ProductClass"].ToString();
// keypicurl = drw["ProductPic"].ToString();
}
}
private void pageload1()
{
if (Application["AppSet"] == null)
{
DataRow drw = DBFun.GetDataRow("Select * From lxwm");
Application["SiteUrl"] = drw["lxwz"].ToString();
Application["SiteKey"] = drw["lxyx"].ToString();
Application["SiteDes"] = drw["lsyb"].ToString();
Application["CopyRight"] = drw["CopyRight"].ToString();
Application["SiteName"] = drw["lxsj"].ToString();
Application["SiteDz"] = drw["lsdz"].ToString();
string[] contact = drw["lxdh"].ToString().Split(',');
Application["contact"] = contact;
Application["AppSet"] = "yes";
}
if (!IsPostBack)
{
if (Application["AppSet"] != null)
{
lbldz = Application["SiteDz"].ToString();
lblEmail = Application["SiteKey"].ToString();
lblyb = Application["SiteDes"].ToString();
lbldh = Application["SiteName"].ToString();
}
}
}
}
public static DataRow GetDataRow(string strSQL)
{
if (strSQL.Length==0 )
{ return null;
}
//查询数据,取得数据行
try
{
openConnection();
SqlDataAdapter sqlAdp = new SqlDataAdapter(strSQL, conn);
DataSet Rs = new DataSet();
sqlAdp.Fill(Rs);
if (Rs.Tables[0].Rows.Count != 0)
return Rs.Tables[0].Rows[0];
else
return null;
}
catch
{
return null;
}
}
public static DataView GetDataView(string strSQL)
{
if (strSQL.Length == 0)
{
return null;
}
//查询数据,取得数据视图
try
{
openConnection();
SqlDataAdapter OleAdp = new SqlDataAdapter(strSQL, conn);
DataSet Rs = new DataSet();
OleAdp.Fill(Rs);
return Rs.Tables[0].DefaultView;
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}strqry = "Select * From Product where id =" + Request.QueryString["id"];
DataRow drw = DBFun.GetDataRow(strqry);