rendered paste bodyusing 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.OleDb;
public partial class Publish_Product : System.Web.UI.Page
{
protected OleDbDataAdapter da;
protected OleDbConnection cn;
protected DataTable dt;
protected string _mTitleProduct = "";
protected string _mTitleType = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Params["id"] != null)
{
loadData(Request.Params["id"].ToString());
_mTitleProduct = loadTitleProduct(Request.Params["id"].ToString());
}
if (Request.Params["type"] != null)
{
loadDataType(Request.Params["type"].ToString());
_mTitleType = loadTitleType(Request.Params["type"].ToString());
}
}
}
protected void Connection()
{
string strCn = "Provider=Microsoft.Jet.OLEDB.4.0;";
strCn += "Data Source=" + Server.MapPath("~/App_Data/hdshop.mdb");
cn = new OleDbConnection(strCn);
if (cn.State != ConnectionState.Open)
cn.Open();
}
protected void loadData(string id)
{
Connection();
string strSql = "Select top 15 * from ProductDetail where Hide=0 and ProductID='" + id.ToString() + "'";
da = new OleDbDataAdapter(strSql, cn);
dt = new DataTable();
da.Fill(dt);
cn.Close();
if (dt.Rows.Count > 0 && dt != null)
{
DataList1.DataSource = dt;
DataList1.DataBind();
}
}
protected string loadTitleProduct(string id)
{
string data = "";
Connection();
string strSql = "Select Title from Product where IDProduct='" + id.ToString() + "'";
da = new OleDbDataAdapter(strSql, cn);
dt = new DataTable();
da.Fill(dt);
cn.Close();
if (dt.Rows.Count > 0 && dt != null)
{
foreach (DataRow dr in dt.Rows)
{
data += dr["Title"].ToString();
}
}
return data;
}
protected void loadDataType(string type)
{
Connection();
string strSql = "Select top 15 * from ProductDetail,Product where idproduct=productid and ProducttypeID='" + type.ToString() + "'";
da = new OleDbDataAdapter(strSql, cn);
dt = new DataTable();
da.Fill(dt);
cn.Close();
if (dt.Rows.Count > 0 && dt != null)
{
DataList1.DataSource = dt;
DataList1.DataBind();
}
}
protected string loadTitleType(string type)
{
string data = "";
Connection();
string strSql = "Select Title from producttype where idtype='" + type.ToString() + "'";
da = new OleDbDataAdapter(strSql, cn);
dt = new DataTable();
da.Fill(dt);
cn.Close();
if (dt.Rows.Count > 0 && dt != null)
{
foreach (DataRow dr in dt.Rows)
{
data += dr["Title"].ToString();
}
}
return data;
}
}