roomtypemanage.cs

来自「是我见过的一个比较好的管理系统 好东西大家分享 需要的可以下载看看」· CS 代码 · 共 93 行

CS
93
字号
using System;
using System.Data;
using System.Data.SqlClient;


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

		public void RoomType_Add(string typename,int area,int bednum,float price,int telephone,int tv,int toilet,int aircondition)
		{
			this.selectStr="insert into RoomType values("+"'"+typename+"',"+area+","+bednum+","+price+","+aircondition+","+telephone+","+tv+","+toilet+")";
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();				
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
			}
			finally
			{
				this.sqlConnection1.Close();
			}

		}
		
		public void Room_Delete(string roomID)
		{
			this.selectStr="delete from Room where RoomID="+roomID;
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();				
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
			}
			finally
			{
				this.sqlConnection1.Close();
			}
		}
		
		public bool Room_Modify(string typename,int area,int bednum,float price,int telephone,int tv,int toilet,int aircondition)
		{
			this.selectStr="update RoomType set Area="+area+","+"BedNum="+bednum+","+"Price="+price+","+"Toilet="+toilet+","+"AirCondition="+aircondition+","+"Television="+tv+","+"Phone="+telephone+" where RoomTypeName="+"'"+typename+"'";
			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 + =
减小字号Ctrl + -
显示快捷键?