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

📄 roommanage.cs

📁 宾馆信息管理系统: 采用C#编写
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;


namespace HotelManage
{
	/// <summary>
	/// RoomManage 的摘要说明。
	/// </summary>
	public class RoomManage
	{
		private string selectStr;
		private SqlConnection sqlConnection1;
		private SqlCommand sqlCommand1=null;
		private SqlDataReader sqlDataReader1=null;
		public RoomManage()
		{
			this.sqlConnection1=new SqlConnection(HotelManage.Connection.ConnString);
			this.sqlCommand1=new SqlCommand();
			this.sqlCommand1.CommandType=CommandType.Text;
			this.sqlCommand1.Connection=this.sqlConnection1;
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		public bool Room_Add(string roomID,string roomType,string roomPosition,int bedNum,int peopleNum,string remark)
		{
			int factpeopelenum=0;
			this.selectStr="insert into Room(RoomID,RoomTypeName,RoomPosition,BedNum,PeopleNum,Remark,FactPeopleNum) values("+"'"+roomID+"',"+"'"+roomType+"',"+"'"+roomPosition+"',"+bedNum+","+peopleNum+",'"+remark+"',"+factpeopelenum+")";
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();				
				return true;
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
				this.sqlConnection1.Close();
				return false;
			}
			finally
			{
				this.sqlConnection1.Close();
			}

		}
		public bool Room_Delete(string roomID)
		{
			this.selectStr="delete from Room where RoomID="+"'"+roomID+"'";
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();
				return true;
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
				this.sqlConnection1.Close();
				return false;
			}
			finally
			{
				this.sqlConnection1.Close();
			}
		}
		public bool Room_Modify(string roomID,string roomType,string roomPosition,int bedNum,int peopleNum,string remark)
		{
			this.selectStr="update Room set RoomTypeName="+"'"+roomType+"',"+"RoomPosition="+"'"+roomPosition+"',"+"BedNum="+bedNum+","+"PeopleNum="+peopleNum+","+"Remark="+"'"+remark+"'"+" where RoomID="+roomID;
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();
				return true;
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
				return false;
			}
			finally
			{
				this.sqlConnection1.Close();
			}

		}




	}
}

⌨️ 快捷键说明

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