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

📄 staddproduct.aspx.cs

📁 数据库:Microsoft SQL Server 2000。 技术平台:Microsoft .NET Framework 2.0.0.0版本。 IIS:Internet Informati
💻 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.Data.SqlClient;
using System.Configuration;

namespace STcontract.STUser
{
	/// <summary>
	/// STAddProduct 的摘要说明。
	/// </summary>
	public class STAddProduct : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button btnOK;
		protected System.Web.UI.WebControls.TextBox STProdID;
		protected System.Web.UI.WebControls.TextBox STProdName;
		protected System.Web.UI.WebControls.TextBox STProdPrice;
		protected System.Web.UI.WebControls.TextBox STProdBZ;
		protected System.Web.UI.WebControls.TextBox STProdSH;
		protected System.Web.UI.WebControls.TextBox STProdInfo;
		protected System.Web.UI.WebControls.TextBox STProdNum;
		SqlConnection STconn;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(Session["STNickName"] != null)
			{
				string STconnection = ConfigurationSettings.AppSettings["strconnection"];
				STconn = new SqlConnection(STconnection);
				if(!IsPostBack)
				{
					STconn.Open();
			
					string STNickName = Session["STNickName"].ToString();
					string STmysql = "select STProDe.ID,STProDe.STProdID,STProDe.STDepID,STProDe.STProdName,STProDe.STProdPrice,STProDe.STProdNum,STProDe.STProdBZ,STProDe.STProdSH,STProDe.STProdInfo from STProDe,STUser where STProDe.STDepID = STUser.STDepID and STUser.STNickName = '" + STNickName + "'";
					SqlCommand STcmd = new SqlCommand(STmysql,STconn);
					SqlDataReader STsdr = STcmd.ExecuteReader();
					if(STsdr.Read())
					{
						Session["STProdID"] = STsdr["STProdID"];
						STProdID.Text = Session["STProdID"].ToString();
						Session["STProdName"] = STsdr["STProdName"];
						STProdName.Text = Session["STProdName"].ToString();
						Session["STProdPrice"] = STsdr["STProdPrice"];
						STProdPrice.Text = Session["STProdPrice"].ToString();
						Session["STProdBZ"] = STsdr["STProdBZ"];
						STProdBZ.Text = Session["STProdBZ"].ToString();
						Session["STProdSH"] = STsdr["STProdSH"];
						STProdSH.Text = Session["STProdSH"].ToString();
						Session["STProdInfo"] = STsdr["STProdInfo"];
						STProdInfo.Text = Session["STProdInfo"].ToString();
						Session["STProdNum"] = STsdr["STProdNum"];
						STProdNum.Text = Session["STProdNum"].ToString();
						Session["STDepID"] = STsdr["STDepID"];



					}
					STconn.Close();
				}
			}
			else
			{
				Response.Redirect("../Index.aspx");
			}
			
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		public void btnOK_Click(object sender, System.EventArgs e)
		{
			string STDepID = Session["STDepID"].ToString();
		

			SqlCommand STcmd=new SqlCommand("update_STProDe_1",STconn);
			STcmd.CommandType=CommandType.StoredProcedure;
			try
			{
				STcmd.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int,4));
				STcmd.Parameters.Add(new SqlParameter("@STProdID",SqlDbType.Int,4));
				STcmd.Parameters.Add(new SqlParameter("@STDepID",SqlDbType.Int,4));
				STcmd.Parameters.Add(new SqlParameter("@STProdName",SqlDbType.VarChar,50));
				STcmd.Parameters.Add(new SqlParameter("@STProdInfo",SqlDbType.VarChar,200));
				STcmd.Parameters.Add(new SqlParameter("@STProdPrice",SqlDbType.Decimal,9));
				STcmd.Parameters.Add(new SqlParameter("@STProdNum",SqlDbType.Decimal,9));
				STcmd.Parameters.Add(new SqlParameter("@STProdBZ",SqlDbType.Decimal,9));
				STcmd.Parameters.Add(new SqlParameter("@STProdSH",SqlDbType.DateTime,8));
				STcmd.Parameters["@ID"].Value = Request.QueryString["ID"];
				STcmd.Parameters["@STProdID"].Value = STProdID.Text;
				STcmd.Parameters["@STDepID"].Value = STDepID;
				STcmd.Parameters["@STProdName"].Value = STProdName.Text;
				STcmd.Parameters["@STProdInfo"].Value = STProdInfo.Text;
				STcmd.Parameters["@STProdPrice"].Value = STProdPrice.Text;
				STcmd.Parameters["@STProdNum"].Value = STProdNum.Text;
				STcmd.Parameters["@STProdBZ"].Value = STProdBZ.Text; 
				STcmd.Parameters["@STProdSH"].Value = STProdSH.Text;
				

				STcmd.Connection.Open();			
				STcmd.ExecuteNonQuery();
				
			}
			catch(SqlException ex)
			{
				throw ex;
			}
			STcmd.Connection.Close();	
			
			string str = "<script language=javascript>window.dialogArguments.document.location.href='STUserProduct.aspx';window.close();</script>"; 
			Response.Write(str);
		}
	}
}

⌨️ 快捷键说明

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