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

📄 jieyue.aspx.cs

📁 数据库课程设计
💻 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;
namespace mybook
{
	/// <summary>
	/// yishi管理 的摘要说明。
	/// </summary>
	public class yishi管理 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Button Button4;
		protected System.Web.UI.WebControls.Label Label12;
		protected System.Web.UI.WebControls.Label Label11;
		protected System.Web.UI.WebControls.Label Label10;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.TextBox TextBox9;
		protected System.Web.UI.WebControls.TextBox TextBox8;
		protected System.Web.UI.WebControls.TextBox TextBox7;
		protected System.Web.UI.WebControls.TextBox TextBox6;
		protected System.Web.UI.WebControls.TextBox TextBox5;
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Button Button3;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			string strConn="server=.;uid=sa;pwd=sa;database=mybook";
			SqlConnection myConnection=new SqlConnection();
			myConnection.ConnectionString=strConn;

			string strCommand="select * from guanli";
			SqlDataAdapter  da=new SqlDataAdapter(strCommand,myConnection);
			DataSet ds=new DataSet();
			da.Fill(ds,"scores");
			DataGrid1.DataSource=ds.Tables["scores"].DefaultView;
			DataGrid1.DataBind();
			myConnection.Close();
		}

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

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			string strConn="server=.;uid=sa;pwd=sa;database=mybook";
			SqlConnection myConnection=new SqlConnection();
			myConnection.ConnectionString=strConn;
			string strCommand="insert into guanli(guanliid,jieshuno,tushuno,tushuname,jieshuriqi,fakuan,adminid,beizhu) values('"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"','"+TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+TextBox9.Text+"')";
			SqlCommand addScore=new SqlCommand(strCommand,myConnection);
			myConnection.Open();

			addScore.ExecuteNonQuery();
			myConnection.Close();
		}

		private void Button4_Click(object sender, System.EventArgs e)
		{
			string strConn="server=.;uid=sa;pwd=sa;database=mybook";
			SqlConnection myConnection=new SqlConnection();
			myConnection.ConnectionString=strConn;
			string strCommand="delete from guanli where guanliid='"+TextBox1.Text+"'";
			//Response.Write(strCommand);
			SqlCommand addScore=new SqlCommand(strCommand,myConnection);
			myConnection.Open();
			addScore.ExecuteNonQuery();
			myConnection.Close();
			//DataGrid1.DataBind();         
		}

	

		private void Button2_Click(object sender, System.EventArgs e)
		{
			string strConn="server=.;uid=sa;pwd=sa;database=mybook";
			SqlConnection myConnection=new SqlConnection();
			myConnection.ConnectionString=strConn;
			if(!IsPostBack)
			{
				DataGrid1.DataBind();
			}
		}

		private void Button3_Click(object sender, System.EventArgs e)
		{
		Response.Redirect("adminlist.aspx");
		}

		private void TextBox10_TextChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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