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

📄 ordermanage.cs

📁 本设备管理系统采用了三层结构的设计思想
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;

namespace HotelManage
{
	/// <summary>
	/// ClientOrderManage 的摘要说明。
	/// </summary>
	public class ClientOrderManage
	{
		private string selectStr;
		private SqlCommand sqlCommand1=null;
		private SqlCommand sqlCommand2=null;
		//private SqlDataReader sqlDataReader1=null;
		private SqlConnection sqlConnection1;

		public ClientOrderManage()
		{
			this.sqlConnection1=new SqlConnection(HotelManage.util.Connection.ConnString);
			this.sqlCommand1=new SqlCommand();			
			this.sqlCommand1.CommandType=CommandType.Text;
			this.sqlCommand1.Connection=this.sqlConnection1;	
			this.sqlCommand2=new SqlCommand();
			this.sqlCommand2.CommandType=CommandType.StoredProcedure;
			this.sqlCommand2.Connection=this.sqlConnection1;
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		
		public bool ClientOrder_Add(string CustomerID,string roomID,System.DateTime OrderDate,string remark)
		{			
			this.selectStr="insert into CustomerRecord(CustomerID,RoomID,InDate,Remark) values("+"'"+CustomerID+"',"+"'"+roomID+"',"+"'"+OrderDate+"',"+"'"+remark+"')";
			this.sqlCommand1.CommandText=this.selectStr;
			try
			{
				this.sqlConnection1.Open();
				this.sqlCommand1.ExecuteNonQuery();	
				this.RoomPeopleNum_Add(roomID);
				return true;
			}
			catch(System.Exception E)
			{
				Console.WriteLine(E.ToString());
				this.sqlConnection1.Close();
				return false;
			}
			finally
			{
				this.sqlConnection1.Close();
			}
		}
		public bool Client_Add(string CustomerID,string CustomerName,string sex,string nativePlace)
		{
			if(this.Client_Search(CustomerID))
			{			
				return true;
			}
			this.selectStr="insert into Customer values("+"'"+CustomerID+"',"+"'"+CustomerName+"','"+sex+"','"+nativePlace+"'"+")";
			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();
			}
		}
		private bool Client_Search(string CustomerID)
		{
			this.selectStr="select count(*) from Customer where CustomerID="+"'"+CustomerID+"'";
			this.sqlCommand1.CommandText=this.selectStr;
			if(this.sqlConnection1.State==ConnectionState.Closed)
				this.sqlConnection1.Open();
			if(Convert.ToInt16(this.sqlCommand1.ExecuteScalar())>0)
			{
				this.sqlConnection1.Close();
				return true;

			}
			else
			{
				this.sqlConnection1.Close();
				return false;			
			}

		}

		private  void RoomPeopleNum_Add(string roomID)
		{
			this.sqlCommand2.CommandText="dbo.ProcedureAddCustomer";
			this.sqlCommand2.Parameters.Add(new SqlParameter("@roomID",SqlDbType.Char,4));
			this.sqlCommand2.Parameters["@roomID"].Value=roomID;
			try
			{
				if(this.sqlConnection1.State==ConnectionState.Closed)this.sqlConnection1.Open();
				this.sqlCommand2.ExecuteNonQuery();
			}
			catch(Exception E)
			{
				Console.WriteLine(E.ToString());
			
			}
			finally
			{
				this.sqlConnection1.Close();
			}			
		}

	}
}

⌨️ 快捷键说明

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