📄 product.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using DataAccessLibrary;
using Common;
namespace FerrariSales.Page
{
/// <summary>
/// Product 的摘要说明。
/// </summary>
public class Product : BasePage
{
protected System.Web.UI.WebControls.DropDownList cbo_Product;
protected System.Web.UI.WebControls.Image img_ProductPic1;
protected System.Web.UI.WebControls.Label lbl_ModisCode;
protected System.Web.UI.WebControls.Label lbl_ProductName;
protected System.Web.UI.WebControls.Label lbl_PreFixChassis;
protected System.Web.UI.WebControls.Label lbl_PreFixEngine;
protected System.Web.UI.WebControls.Label lbl_NetWeight;
protected System.Web.UI.WebControls.Label lbl_GrossWeight;
protected System.Web.UI.WebControls.Label lbl_Measurement;
protected System.Web.UI.WebControls.Label lbl_Capacity;
protected System.Web.UI.WebControls.Label lbl_IsProduct;
protected System.Web.UI.HtmlControls.HtmlTable td_ProductInfo;
protected System.Web.UI.WebControls.Button btnModify;
protected System.Web.UI.WebControls.Button btnViewOption;
protected System.Web.UI.WebControls.Button btnNewOrder;
protected System.Web.UI.WebControls.Image img_ProductPic2;
protected System.Web.UI.WebControls.Label lbl_BasePriceDealer;
protected System.Web.UI.WebControls.Label lbl_BasePriceLow;
protected System.Web.UI.WebControls.Label lbl_BasePriceNormal;
public string IsProduct = "";
private void Page_Load(object sender, System.EventArgs e)
{
this.SecurityCheck();
if (!Page.IsPostBack)
{
this.InitProduct();
//点击图像进行切换
this.img_ProductPic1.Attributes.Add("OnClick","ChangePic(1);");
this.img_ProductPic2.Attributes.Add("OnClick","ChangePic(2);");
//产品信息列表不显示
this.td_ProductInfo.Visible = false;
//判断是否有URL参数
string productID = Request["id"];
if (productID != null && productID != "")
{
this.BaseOperation(productID);
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.cbo_Product.SelectedIndexChanged += new System.EventHandler(this.cbo_Product_SelectedIndexChanged);
this.btnModify.Click += new System.EventHandler(this.btnModify_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// 检索所有车型到下拉框
/// </summary>
private void InitProduct()
{
this.cbo_Product.Items.Clear();
this.cbo_Product.Items.Add(new ListItem("请选择",""));
BisProduct bisProduct = new BisProduct();
DataTable table = bisProduct.GetProductModel();
if (table == null)
{
return;
}
for (int i=0;i<table.Rows.Count;i++)
{
string productID = ConvertType.GetString(table.Rows[i]["ProductID"]);
this.cbo_Product.Items.Add(new ListItem(productID,productID));
}
}
/// <summary>
/// 车型下拉框值发生变化后触发
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cbo_Product_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selProductID = this.cbo_Product.SelectedValue;
this.BaseOperation(selProductID);
}
/// <summary>
/// 检索某一车型的信息
/// </summary>
/// <param name="selProductID"></param>
private void BaseOperation(string selProductID)
{
if (selProductID == "")
{
//图片不显示
this.img_ProductPic1.Visible = false;
this.img_ProductPic2.Visible = false;
//产品信息列表不显示
this.td_ProductInfo.Visible = false;
return;
}
//检索产品信息和价格
BisProduct bisProduct = new BisProduct();
DataTable table = bisProduct.GetProductInfoAndValue(selProductID);
if (table == null)
{
//图片不显示
this.img_ProductPic1.Visible = false;
this.img_ProductPic2.Visible = false;
//产品信息列表不显示
this.td_ProductInfo.Visible = false;
return;
}
//确定图片文件名
string pic1 = ConvertType.GetString(table.Rows[0]["PicPath1"]);
string pic2 = ConvertType.GetString(table.Rows[0]["PicPath2"]);
string picPath = ConfigurationSettings.AppSettings["ProductModelPicPath"];
if (pic1 == null)
{
this.img_ProductPic1.Visible = false;
}
else
{
this.img_ProductPic1.ImageUrl = picPath + "/" + pic1;
this.img_ProductPic1.Visible = true;
}
if (pic2 == null)
{
this.img_ProductPic2.Visible = false;
}
else
{
this.img_ProductPic2.ImageUrl = picPath + "/" + pic2;
this.img_ProductPic2.Visible = true;
}
//显示产品信息和价格
this.td_ProductInfo.Visible = true;
this.lbl_ModisCode.Text = ConvertType.GetString(table.Rows[0]["ModisCode"]);
this.lbl_ProductName.Text = ConvertType.GetString(table.Rows[0]["ProductName"]);
this.lbl_PreFixChassis.Text = ConvertType.GetString(table.Rows[0]["PreFixChassis"]);
this.lbl_PreFixEngine.Text = ConvertType.GetString(table.Rows[0]["PreFixEngine"]);
this.lbl_NetWeight.Text = CommonFunc.ConvertNumericToPageStyle(ConvertType.GetInt(table.Rows[0]["NetWeight"]));
this.lbl_GrossWeight.Text = CommonFunc.ConvertNumericToPageStyle(ConvertType.GetInt(table.Rows[0]["GrossWeight"]));
this.lbl_Measurement.Text = CommonFunc.ConvertNumericToPageStyle(ConvertType.GetDecimal(table.Rows[0]["Measurement"]));
this.lbl_Capacity.Text = Common.CommonFunc.ConvertNumericToPageStyle(ConvertType.GetDecimal(table.Rows[0]["Capacity"]));
this.IsProduct = ConvertType.GetString(table.Rows[0]["IsProduct"]);
if (this.IsProduct == "1")
{
this.lbl_IsProduct.Text = "可生产";
}
else
{
this.lbl_IsProduct.Text = "已停产";
}
this.lbl_BasePriceDealer.Text = CommonFunc.ConvertMoneyToPageStyle(ConvertType.GetInt(table.Rows[0]["BasePriceDealer"]));
this.lbl_BasePriceLow.Text = CommonFunc.ConvertMoneyToPageStyle(ConvertType.GetInt(table.Rows[0]["BasePriceLow"]));
this.lbl_BasePriceNormal.Text = CommonFunc.ConvertMoneyToPageStyle(ConvertType.GetInt(table.Rows[0]["BasePriceNormal"]));
//查看配置Button
string strViewOptionUrl = "javascript:window.location.href('ProductOption.aspx?id=" + selProductID + "');return false;";
this.btnViewOption.Attributes.Add("OnClick",strViewOptionUrl);
//信息修改Button
string strModifyUrl = "javascript:window.location.href('ProductModify.aspx?id=" + selProductID + "');return false;";
this.btnModify.Attributes.Add("OnClick",strModifyUrl);
}
private void btnModify_Click(object sender, System.EventArgs e)
{
this.Response.Redirect("ProductModify.aspx?opt=upd");
this.Response.End();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -