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

📄 clientsmodify.aspx.cs

📁 本文件夹中的Model目录下包含了系统的数据库模型图和系统建模图
💻 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 System.Data .SqlClient ;



namespace TMS
{
	/// <summary>
	/// ClientsModify 的摘要说明。
	/// </summary>
	public class ClientsModify : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox tbx_cname;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_cname;
		protected System.Web.UI.WebControls.TextBox tbx_caddress;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_caddress;
		protected System.Web.UI.WebControls.TextBox tbx_ccontactperson;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_ccontactperson;
		protected System.Web.UI.WebControls.TextBox tbx_ctel;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_ctel;
		protected System.Web.UI.WebControls.TextBox tbx_cbank;
		protected System.Web.UI.WebControls.RequiredFieldValidator rvf_cbank;
		protected System.Web.UI.WebControls.TextBox tbx_caccount;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_caccount;
		protected System.Web.UI.WebControls.TextBox tbx_ctax;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_ctax;
		protected System.Web.UI.WebControls.TextBox tbx_cemail;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfv_cemail;
		protected System.Web.UI.WebControls.HyperLink hlk_clientsmanage;
		protected System.Web.UI.WebControls.Button btn_modify;
		protected System.Web.UI.WebControls.Button btn_delete;
		protected System.Web.UI.WebControls.Label lbl_cid;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{	//绑定各TextBox数据
				string strconn= ConfigurationSettings.AppSettings["dsn"];
				//连接本地计算机的TMS数据库
				SqlConnection cn= new SqlConnection (strconn);
				cn.Open ();
				SqlCommand cm=new SqlCommand  ("clientsdetail",cn);
				cm.CommandType =CommandType .StoredProcedure ;
				cm.Parameters .Add ("@CID",SqlDbType.VarChar );
				cm.Parameters ["@CID"].Value =Request.QueryString ["cid"].ToString ();
				SqlDataReader dr=cm.ExecuteReader ();
				if(dr.Read ())//存在对应项
				{	
					lbl_cid.Text =dr["cid"].ToString ();
					tbx_cname.Text =dr["cname"].ToString ();
					tbx_caddress.Text =dr["caddress"].ToString ();
					tbx_ctel.Text =dr["ctel"].ToString ();
					tbx_ccontactperson.Text=dr["ccontactperson"].ToString ();
					tbx_cbank.Text=dr["cbank"].ToString ();
					tbx_caccount.Text=dr["caccount"].ToString ();
					tbx_cemail.Text=dr["cemail"].ToString ();
					tbx_ctax.Text=dr["ctax"].ToString ();
				}
				else
				{
					Response.Write ("对不起,没有该客户信息");
					Response.End ();
				}
			}
		}

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

		}
		#endregion

		private void btn_modify_Click(object sender, System.EventArgs e)
		{
			if(Page.IsValid )
			{//从文件Web.config中读取连接字符串
				string strconn= ConfigurationSettings.AppSettings["dsn"];
				//连接本地计算机的TMS数据库
				SqlConnection cn= new SqlConnection (strconn);
				cn.Open ();
				//利用Command对象调用存储过程
				SqlCommand cm=new SqlCommand  ("clientsmodify",cn);
				//将命令类型转为存储类型
				cm.CommandType =CommandType.StoredProcedure ;
				//往存储过程中添加参数
				cm.Parameters .Add ("@CID",SqlDbType.VarChar);
				cm.Parameters .Add ("@CName",SqlDbType.VarChar);
				cm.Parameters .Add ("@CAddress",SqlDbType.VarChar);
				cm.Parameters .Add ("@CTel",SqlDbType.VarChar);
				cm.Parameters .Add ("@CContactPerson",SqlDbType.VarChar);
				cm.Parameters .Add ("@CBank",SqlDbType.VarChar );
				cm.Parameters .Add ("@CAccount",SqlDbType.VarChar);
				cm.Parameters .Add ("@CEmail",SqlDbType.VarChar );
				cm.Parameters .Add ("@CTax",SqlDbType.VarChar );
				//给存储过程的参数付值
				cm.Parameters ["@CID"].Value =lbl_cid.Text .ToString ();
				cm.Parameters ["@CName"].Value =tbx_cname.Text .ToString ();
				cm.Parameters ["@CAddress"].Value =tbx_caddress.Text .ToString ();
				cm.Parameters ["@CTel"].Value =tbx_ctel.Text .ToString ();
				cm.Parameters ["@CContactPerson"].Value =tbx_ccontactperson.Text .ToString ();
				cm.Parameters ["@CBank"].Value =tbx_cbank.Text .ToString ();
				cm.Parameters ["@CAccount"].Value =tbx_caccount.Text.ToString () ;
				cm.Parameters ["@CEmail"].Value =tbx_cemail.Text .ToString () ;
				cm.Parameters ["@CTax"].Value =tbx_ctax.Text .ToString () ;
				cm.ExecuteNonQuery ();
				//关闭连接
				cn.Close();
				Response.Redirect("clientsmanage.aspx");
			}
		
		}
		private void btn_delete_Click(object sender, System.EventArgs e)
		{	
			//从文件Web.config中读取连接字符串
			string strconn= ConfigurationSettings.AppSettings["dsn"];
			//连接本地计算机的TMS数据库
			SqlConnection cn= new SqlConnection (strconn);
			cn.Open ();
			SqlCommand cm=new SqlCommand ("clientsdelete",cn);
			cm.CommandType =CommandType.StoredProcedure ;
			cm.Parameters .Add ("@CID",SqlDbType.VarChar );
			//从lbl_cpid取得CID值
			cm.Parameters ["@CID"].Value =lbl_cid .Text .ToString ();
			cm.ExecuteNonQuery ();
			//关闭连接
			cn.Close();
			Response.Redirect("clientsmanage.aspx");	
		
		}
	}
}

⌨️ 快捷键说明

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