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

📄 planeprojectdao.cs

📁 民航订票管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			SqlParameter parameterphone = new SqlParameter("@phone", SqlDbType.NVarChar, 50);
			parameterphone.Value = Phone;
			myCommand.Parameters.Add(parameterphone);

			SqlParameter parameteremail = new SqlParameter("@email", SqlDbType.NVarChar, 50);
			parameteremail.Value = Email;
			myCommand.Parameters.Add(parameteremail);

			SqlParameter parameteraddress = new SqlParameter("@address", SqlDbType.NVarChar, 50);
			parameteraddress.Value = Address;
			myCommand.Parameters.Add(parameteraddress);

			SqlParameter parametermail = new SqlParameter("@mail", SqlDbType.NVarChar, 50);
			parametermail.Value = Mail;
			myCommand.Parameters.Add(parametermail);

			SqlParameter parameterclientno = new SqlParameter("@clientno", SqlDbType.Int, 4);
			//指出该参数是存储过程的OUTPUT参数
			parameterclientno.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parameterclientno);

			try 
			{
				//打开数据库连接
				myConnection.Open();
				//进行数据库操作
				myCommand.ExecuteNonQuery();
				//关闭数据库连接
				myConnection.Close();
				int userId = (int)(parameterclientno.Value);
				userID = userId;

				//使用存储过程的输出参数返回UserID
				int clientno = (int)parameterclientno.Value;

				return clientno.ToString();
			}
			catch 
			{
				return String.Empty;
			}
		}

	
			//UserLogin() 方法用于判断用户的登录是否合法
			public String UserLogin(string username, string password) 
			{

				//创建数据库连接和命令的对象

				string sConnString = " data source =(local); initial catalog = plane project;"+ "user id=sa;password=sa;";
				SqlConnection myConnection = new SqlConnection(sConnString);

				//SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
				SqlCommand myCommand = new SqlCommand("UserLogin", myConnection);

				//指明Sql命令的操作类型是使用存储过程
				myCommand.CommandType = CommandType.StoredProcedure;

				//给存储过程添加参数
				SqlParameter parameterclientname = new SqlParameter("@clientname", SqlDbType.NVarChar, 50);
				parameterclientname.Value = username;
				myCommand.Parameters.Add(parameterclientname);

				SqlParameter parameterclientcode = new SqlParameter("@clientcode", SqlDbType.NVarChar, 50);
				parameterclientcode.Value = password;
				myCommand.Parameters.Add(parameterclientcode);

				SqlParameter parameterclientno = new SqlParameter("@clientno", SqlDbType.Int, 4);
				//指出该参数是存储过程的OUTPUT参数
				parameterclientno.Direction = ParameterDirection.Output;
				myCommand.Parameters.Add(parameterclientno);

				//打开数据库连接
				myConnection.Open();
				//进行数据库操作
				myCommand.ExecuteNonQuery();
				//关闭数据库连接
				myConnection.Close();

				//使用存储过程的输出参数返回UserID并赋值给userId
				int userId = (int)(parameterclientno.Value);
				userID = userId;
				//userid = (int)(parameterclientno.Value);
				//Session["gonguserid"] = userId;
			
				//判断userId的值,如果为零则说明登录失败,函数返回空字符串,
				//反之把userId转换为字符串返回。
				if (userId == 0) 
				{
					return null;
				}
				else 
				{
					return userId.ToString();
				}
			}
		

		public String EmpLogin(string username, string password,string status) 
		{

			//创建数据库连接和命令的对象

			string sConnString = " data source =(local); initial catalog = plane project;"+ "user id=sa;password=sa;";
			SqlConnection myConnection = new SqlConnection(sConnString);

			//SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("EmpLogin", myConnection);

			//指明Sql命令的操作类型是使用存储过程
			myCommand.CommandType = CommandType.StoredProcedure;

			//给存储过程添加参数
			SqlParameter parameterusername = new SqlParameter("@username", SqlDbType.NVarChar, 50);
			parameterusername.Value = username;
			myCommand.Parameters.Add(parameterusername);

			SqlParameter parameterpassword = new SqlParameter("@password", SqlDbType.NVarChar, 50);
			parameterpassword.Value = password;
			myCommand.Parameters.Add(parameterpassword);


			SqlParameter parameterstatus = new SqlParameter("@status", SqlDbType.NVarChar, 50);
			parameterstatus.Value = status;
			myCommand.Parameters.Add(parameterstatus);

			SqlParameter parameteruserno = new SqlParameter("@userno", SqlDbType.Int, 4);
			//指出该参数是存储过程的OUTPUT参数
			parameteruserno.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parameteruserno);

			//打开数据库连接
			myConnection.Open();
			//进行数据库操作
			myCommand.ExecuteNonQuery();
			//关闭数据库连接
			myConnection.Close();

			//使用存储过程的输出参数返回UserID并赋值给userId
			int userId = (int)(parameteruserno.Value);
			//判断userId的值,如果为零则说明登录失败,函数返回空字符串,
			//反之把userId转换为字符串返回。
			if (userId == 0) 
			{
				return null;
			}
			else 
			{
				return userId.ToString();
			}
		}

		public String registerpan(string username) 
		{

			//创建数据库连接和命令的对象

			string sConnString = " data source =(local); initial catalog = plane project;"+ "user id=sa;password=sa;";
			SqlConnection myConnection = new SqlConnection(sConnString);

			//SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("registerpan", myConnection);

			//指明Sql命令的操作类型是使用存储过程
			myCommand.CommandType = CommandType.StoredProcedure;

			//给存储过程添加参数
			SqlParameter parameterclientname = new SqlParameter("@clientname", SqlDbType.NVarChar, 50);
			parameterclientname.Value = username;
			myCommand.Parameters.Add(parameterclientname);

			

			SqlParameter parameterclientno = new SqlParameter("@clientno", SqlDbType.Int, 4);
			//指出该参数是存储过程的OUTPUT参数
			parameterclientno.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parameterclientno);

			//打开数据库连接
			myConnection.Open();
			//进行数据库操作
			myCommand.ExecuteNonQuery();
			//关闭数据库连接
			myConnection.Close();

			//使用存储过程的输出参数返回UserID并赋值给userId
			int userId = (int)(parameterclientno.Value);
			userID = userId;
			//userid = (int)(parameterclientno.Value);
			//Session["gonguserid"] = userId;
			
			//判断userId的值,如果为零则说明登录失败,函数返回空字符串,
			//反之把userId转换为字符串返回。
			if (userId == 0) 
			{
				return null;
			}
			else 
			{
				return userId.ToString();
			}
		}
		

		public DataSet test()
		{
			string sConnString = " data source =(local); initial catalog = plane project;"+ "user id=sa;password=sa;";
			SqlConnection conn = new SqlConnection(sConnString);
			conn.Open();

			DateTime today = new DateTime();
			string dweek = today.DayOfWeek.ToString();
			dweek = "Monday";
			//string commandstring = "select* from flydetail where week = ";
			SqlCommand cmd = new SqlCommand();
			//cmd.CommandText = "select*from flydetail where week = @week"; //where flydetail.week = '+dweek+'

			cmd.CommandText ="select flyno as 航班,area 地区,ptype 飞机类型,startime 起飞时间,arrivetime 到达时间 from flydetail where week = @week";
			//cmd.CommandText.Sers.Add("@week",SqlDbType.NChar,16).value = dweek;
			//cmd.Parameters.
			cmd.Connection = conn;
			cmd.CommandType = CommandType.Text;
			//SqlDataReader dr = cmd.ExecuteReader();
			SqlDataAdapter da = new SqlDataAdapter();
			da.SelectCommand = cmd;
			da.SelectCommand.Parameters.Add("@week",SqlDbType.NChar,16).Value =dweek;
			//SqlDataAdapter dataAdapter = new SqlDataAdapter(commandstring, connectionstring);
			DataSet myDataSet = new DataSet();
			da.Fill(myDataSet);
			return myDataSet;
		}

		public int countlevel(int clientno) 
		{

			//创建数据库连接和命令的对象

			string sConnString = " data source =(local); initial catalog = plane project;"+ "user id=sa;password=sa;";
			SqlConnection myConnection = new SqlConnection(sConnString);

			//SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("countlevel", myConnection);

			//指明Sql命令的操作类型是使用存储过程
			myCommand.CommandType = CommandType.StoredProcedure;

			//给存储过程添加参数
			SqlParameter parameterclientno = new SqlParameter("@clientno", SqlDbType.Int, 4);
			parameterclientno.Value = clientno;
			myCommand.Parameters.Add(parameterclientno);

			
			SqlParameter parametermileage = new SqlParameter("@mileage", SqlDbType.Int,4);
			//指出该参数是存储过程的OUTPUT参数
			parametermileage.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parametermileage);

			//打开数据库连接
			myConnection.Open();
			//进行数据库操作
			myCommand.ExecuteNonQuery();
			//关闭数据库连接
			myConnection.Close();

			//使用存储过程的输出参数返回UserID并赋值给userId
			int mileage = (int)(parametermileage.Value);
			
			//userid = (int)(parameterclientno.Value);
			//Session["gonguserid"] = userId;
			
			//判断userId的值,如果为零则说明登录失败,函数返回空字符串,
			//反之把userId转换为字符串返回。
			
			
			
				return mileage;
			
		}


	
	}
}

⌨️ 快捷键说明

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