⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemdetails.aspx.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 CS
字号:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

// PetShop specific imports
using BookShop.Model;
using BookShop.BLL;

namespace BookShop.Web {
	public class ItemDetails : Page {
		
		private const string MSG_BACK_ORDERED = "目前缺货";
		private const string CSS_ALERT = "alert";

		protected ItemInfo itemInfo;
		protected BookShop.Web.Controls.NavBar header;
		protected Label lblQty;
		protected Label lblDescription;
		protected Label lblName;
		protected Label lblProductName;
		protected Label lblPrice;
		protected Label lblSearchResults;

		private void InitializeComponent() {}

		override protected void OnLoad(EventArgs e) {

			// Fetch the key field from the query stirng
			string itemId = WebComponents.CleanString.InputText(Request["itemId"], 50);

			// Create an instance of the item business components
			Item item = new Item();

			// Get the item info from the item component
			itemInfo = item.GetItem(itemId);

			// If an item is found then display the results
			if(itemInfo != null){

				lblDescription.Text = itemInfo.ProductDesc;
				lblName.Text = itemInfo.Name;
				lblProductName.Text = itemInfo.ProductName;
				lblPrice.Text = itemInfo.Price.ToString("c");
			
				// Modify the message if an item is out of stock
				if (itemInfo.Quantity > 0)
					lblQty.Text = itemInfo.Quantity.ToString();
				else {
					lblQty.Text = MSG_BACK_ORDERED;
					lblQty.CssClass = CSS_ALERT;
				}
			}else{
				lblSearchResults.Text = "Item not found";
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -