using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CitySunlight.Product;
namespace CitySunlight
{
public partial class Admin : System.Web.UI.Page
{
int pages = HttpUtils.getQueryString("pages").ToInt();
public String user;
const decimal peritems = 5;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["username"] == null)
{
Response.Redirect("/Account/Login.aspx");
}
user = Session["username"].ToString();
}
public String GetProductInfo()
{
String html = "";
DataTable items = ProductManager.SearchProduct(user, "", "", "", "", pages, peritems.ToString().ToInt());
if (items.Rows.Count == 0)
return "
数据库中未找到产品 |
";
else
html += html += HttpUtils.addThs("商品名称", "商品图片", "商品价格", "商品数量", "商品分类", "编辑", "删除");
html += "";
foreach (DataRow item in items.Rows)
{
int id = int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.ID));
String name = ProductManager.GetProductInfo(item, ProductManager.Info.ItemName);
String url = ProductManager.GetProductInfo(item, ProductManager.Info.PicUrl);
String picurl = String.Format("", url);
String price = ProductManager.GetProductInfo(item, ProductManager.Info.Price);
String amount = ProductManager.GetProductInfo(item, ProductManager.Info.Amount);
String edit = "编辑";
String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class)));
String delete = "删除";
html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, edit, delete);
}
decimal allproduct = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count;
decimal totalpages = Math.Ceiling(allproduct / peritems);
String allpage = "";
html += String.Format(" | {0} |
", allpage);
html += "";
return html;
}
}
}