📄 manageproduct.aspx.cs
字号:
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.OleDb;
public partial class admin_manageProduct : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["adminAccount"] != null)
{
if (Session["adminAccount"] != "")
{
}
else
{
Response.Redirect("adminErr.aspx?errMsg=没有登陆或者登陆超时.<a href='adminlogin.aspx'>现在登陆</a>");
}
}
else
{
Response.Redirect("adminErr.aspx?errMsg=没有登陆或者登陆超时.<a href='adminlogin.aspx'>现在登陆</a>");
}
int classId = Convert.ToInt32(Request.QueryString["ClassId"]);
string sql = "Select A.*,B.* from [NcProducts] As A left Join [NcClass] As B on A.[ProductClassId]=B.[ClassId] Where A.[ProductClassId]=" + classId+" Order By A.[ProductId] DESC";
WebConfig.CreateCon();
OleDbDataAdapter da = new OleDbDataAdapter(sql, WebConfig.con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
this.Label1.Text = ds.Tables[0].Rows[0]["ClassName"].ToString();
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = Convert.ToInt32(Application["ProductListPageSize"]);
int curPage;
if (Request.QueryString["page"] != null)
{
curPage = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
curPage = 1;
}
string productCmd = "";
ds.Tables[0].Columns.Add("IsProductCmd");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i]["ProductPic"] != null)
{
if (ds.Tables[0].Rows[i]["ProductPic"].ToString() != "")
{
ds.Tables[0].Rows[i]["ProductPic"] = "../upload/" + ds.Tables[0].Rows[i]["ProductPic"].ToString();
}
else
{
ds.Tables[0].Rows[i]["ProductPic"] = "../images/no_pic.gif";
}
}
else
{
ds.Tables[0].Rows[i]["ProductPic"] = "../images/no_pic.gif";
}
if (Convert.ToInt32(ds.Tables[0].Rows[i]["ProductCmd"]) == 1)
{
ds.Tables[0].Rows[i]["IsProductCmd"] = "<a href='SetProductCmd.aspx?ProductId=" + ds.Tables[0].Rows[i]["ProductId"].ToString() + "&Cmd=0'>取消倾情推荐</a>";
}
else
{
ds.Tables[0].Rows[i]["IsProductCmd"] = "<a href='SetProductCmd.aspx?ProductId=" + ds.Tables[0].Rows[i]["ProductId"].ToString() + "&Cmd=1'>设为倾情推荐</a>";
}
}
pds.CurrentPageIndex = curPage - 1;
this.Repeater1.DataSource = pds;
this.Repeater1.DataBind();
this.Label2.Text += "<a>共有" + ds.Tables[0].Rows.Count.ToString() + "个产品</a> ";
this.Label2.Text += "<a>分" + pds.PageCount.ToString() + "页</a> ";
this.Label2.Text += "<a>第" + curPage.ToString() + "页</a> ";
//this.LbNewsCount.Text = ds.Tables[0].Rows.Count.ToString();
//this.LbPageCount.Text = pds.PageCount.ToString();
//this.LbCurPage.Text = curPage.ToString();
if (curPage == 1)
{
this.Label2.Text += "<a>上一页</a> ";
}
else
{
this.Label2.Text += "<a href='ManageProduct.aspx?ClassId=" + classId.ToString() + "&page=" + (curPage - 1).ToString() + "'>上一页</a> ";
}
if (curPage == pds.PageCount)
{
this.Label2.Text += "<a>下一页</a>";
}
else
{
this.Label2.Text += "<a href='ManageProduct.aspx?ClassId=" + classId.ToString() + "&page=" + (curPage + 1).ToString() + "'>下一页</a>";
}
}
else
{
this.Label1.Text = "当前分类没有产品";
}
ds.Dispose();
da.Dispose();
WebConfig.CloseCon();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -