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 wztj.page.product.model;
using wztj.page.product.code;
using wztj.page.category.code;
using System.Text;
namespace wztj.page.rfq
{
/// <summary>
/// Summary description for UpdateProduct.
/// </summary>
public class UpdateProduct : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox name;
protected System.Web.UI.WebControls.TextBox manufacture;
protected System.Web.UI.WebControls.TextBox quantity;
protected System.Web.UI.WebControls.TextBox unit;
protected System.Web.UI.WebControls.TextBox classType;
protected System.Web.UI.WebControls.TextBox status;
protected System.Web.UI.WebControls.TextBox description;
protected System.Web.UI.WebControls.TextBox quotedPrice;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected System.Web.UI.HtmlControls.HtmlInputText expirationDate;
protected string ProductID;
protected Product product;
protected string username;
protected string productType;
private void Page_Load(object sender, System.EventArgs e)
{
ProductID = this.Request.QueryString.Get("ProductID");
username = Session["username"].ToString();
ProductManager productManager = new ProductManager();
product = productManager.getProductByProductID(ProductID);
if(!this.IsPostBack)
{
this.name.Text = product.Name;
this.manufacture.Text = product.Manufacture;
this.quantity.Text = product.Quantity.ToString();
this.unit.Text = product.Unit;
this.classType.Text = product.ClassType;
this.status.Text = product.Status;
this.description.Text = product.Description;
this.quotedPrice.Text = product.QuotedPrice.ToString();
this.expirationDate.Value = product.ExpirationDate;
CategoryManager categoryManager = new CategoryManager();
DataTable dt = categoryManager.getRootCategories();
this.DropDownList1.DataSource=dt;
this.DropDownList1.DataTextField = "categoryName";
this.DropDownList1.DataBind();
}
this.productType = product.ProductType;
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e){
ProductManager productManager =new ProductManager();
Product product = productManager.getProduct(username,this.name.Text,
this.manufacture.Text,Double.Parse(this.quantity.Text),this.unit.Text,this.classType.Text,
this.status.Text,this.description.Text,Double.Parse(this.quotedPrice.Text),this.expirationDate.Value,
this.DropDownList1.SelectedItem.Text,productType);
product.Id=long.Parse(ProductID);
productManager.updateProduct(product);
}
}
}
此博客展示了ASP.NET更新产品信息的代码。包含多个命名空间引用,定义了UpdateProduct类,在Page_Load方法中获取产品信息并初始化页面,在Button1_Click方法中更新产品信息,涉及产品名称、数量、价格等内容。
869

被折叠的 条评论
为什么被折叠?



