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

📄 editproduct.aspx.cs

📁 购物系统 完整源码 包括完整的数据库
💻 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.SqlClient;

public partial class Admin_Product_EditProduct : System.Web.UI.Page
{
	private int nProductID = -1;
	private int nCategoryID = -1;
	protected void Page_Load(object sender,EventArgs e)
	{
		///获取参数的值		
		if(Request.Params["CategoryID"] != null)
		{
			if(Int32.TryParse(Request.Params["CategoryID"].ToString(),out nCategoryID) == false)
			{
				return;
			}
		}
		///获取参数的值		
		if(Request.Params["ProductID"] != null)
		{
			if(Int32.TryParse(Request.Params["ProductID"].ToString(),out nProductID) == false)
			{
				return;
			}
		}
		if(!Page.IsPostBack)
		{   ///绑定控件的数据
			if(nProductID > -1)
			{
				BindProductData(nProductID);
			}
		}

		///设置更新按钮的可用性
		SureBtn.Enabled = nProductID <= -1 ? false : true;
	}

	private void BindProductData(int nProductID)
	{	///获取数据
		Product product = new Product();
		SqlDataReader dr = product.GetSingleProduct(nProductID);

		///读取数据
		if(dr.Read())
		{
			///显示数据
			Name.Text = dr["Name"].ToString();
			Desn.Text = dr["Desn"].ToString();
			Sell.Text = dr["Sell"].ToString();
			CreateDate.Text = dr["CreateDate"].ToString();
			SellInDate.Text = dr["SellInDate"].ToString();
			Unit.Text = dr["Unit"].ToString();
			Quantity.Text = dr["Quantity"].ToString();
			InPrice.Text = dr["InPrice"].ToString();
			OutPrice.Text = dr["OutPrice"].ToString();
			Upper.Text = dr["Upper"].ToString();
			Lower.Text = dr["Lower"].ToString();
			Remark.Text = dr["Remark"].ToString();
		}
		dr.Close();          ///关闭数据源
	}

	protected void SureBtn_Click(object sender,EventArgs e)
	{
		int nPictureID = 1;
		Product product = new Product();
		product.UpdateProduct(nProductID,Name.Text,Desn.Text,Sell.Text,
			DateTime.Parse(CreateDate.Text),DateTime.Parse(SellInDate.Text),
			Unit.Text,Int32.Parse(Quantity.Text),Int32.Parse(Upper.Text),
			Int32.Parse(Lower.Text),Decimal.Parse(InPrice.Text),
			Decimal.Parse(OutPrice.Text),nPictureID,Remark.Text);
		Response.Write("<script>window.alert('修改数据项成功。')</script>");
	}
	protected void ReturnBtn_Click(object sender,EventArgs e)
	{	///返回管理页面
		Response.Redirect("~/Admin/Product/ProductManage.aspx?CategoryID=" + nCategoryID.ToString());
	}
}

⌨️ 快捷键说明

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