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

📄 managedatabases.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;

namespace SkyShark.NA
{
	/// <summary>
	/// Summary description for _default.
	/// </summary>
	public class WebManageDatabases : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.HyperLink HyperLink4;
		protected System.Web.UI.WebControls.HyperLink HyperLink5;
		protected System.Web.UI.WebControls.HyperLink HyperLink2;
		protected System.Web.UI.WebControls.Button btnArchive;
		protected System.Web.UI.WebControls.Button btnUpdate;
		protected System.Data.SqlClient.SqlConnection sqlConnection1;
		protected System.Data.SqlClient.SqlCommand sqlCommand1;
		protected System.Web.UI.WebControls.Label lblMessage;
		protected System.Data.SqlClient.SqlCommand sqlCommand2;
		protected System.Web.UI.WebControls.Label txtUser;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (Session["usrRole"]==null)
			{
				Response.Redirect("..\\default.aspx");
			}
										  
			if (!(Session["usrRole"].ToString()=="Admin"))
			{
				Response.Redirect("..\\default.aspx");
			}
			else
			{
				txtUser.Text="User: "+ Session["usrName"].ToString();
			}
		}

		#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.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlCommand2 = new System.Data.SqlClient.SqlCommand();
			this.btnArchive.Click += new System.EventHandler(this.Button1_Click);
			this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source=NPANDEY-D185;initial catalog=Skyshark;integrated security=SSPI;persis" +
				"t security info=True;workstation id=NPANDEY-D185;packet size=4096";
			// 
			// sqlCommand1
			// 
			this.sqlCommand1.CommandText = "dbo.[UpdateReservations]";
			this.sqlCommand1.CommandType = System.Data.CommandType.StoredProcedure;
			this.sqlCommand1.Connection = this.sqlConnection1;
			this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
			this.sqlCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@date", System.Data.SqlDbType.DateTime, 8));
			// 
			// sqlCommand2
			// 
			this.sqlCommand2.CommandText = "dbo.[FrequentFlier]";
			this.sqlCommand2.CommandType = System.Data.CommandType.StoredProcedure;
			this.sqlCommand2.Connection = this.sqlConnection1;
			this.sqlCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			lblMessage.Text="";
			sqlConnection1.Open();
			sqlCommand1.Parameters[1].Value=DateTime.Today.Date.ToShortDateString();
			sqlCommand1.ExecuteNonQuery();
			sqlConnection1.Close();
			lblMessage.Text="Done.";

		}

		private void btnUpdate_Click(object sender, System.EventArgs e)
		{
			lblMessage.Text="";
			sqlConnection1.Open();
			sqlCommand2.ExecuteNonQuery();
			sqlConnection1.Close();
			lblMessage.Text="Done.";
		}


	}
}

⌨️ 快捷键说明

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