📄 clientbookinmanage.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace HotelManage
{
/// <summary>
/// ClientBookInManage 的摘要说明。
/// </summary>
public class ClientBookInManage
{
private string selectStr;
private SqlCommand sqlCommand1=null;
private SqlCommand sqlCommand2=null;
private SqlDataReader sqlDataReader1=null;
private SqlConnection sqlConnection1;
public ClientBookInManage()
{
this.sqlConnection1=new SqlConnection(HotelManage.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 ClientBookIn_Add(string clientID,string roomID,System.DateTime inDate,string remark)
{
this.selectStr="insert into ClientRecord(ClientID,RoomID,InDate,Remark) values("+"'"+clientID+"',"+"'"+roomID+"',"+"'"+inDate+"',"+"'"+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 clientID,string clientName,string sex,string nativePlace)
{
if(this.Client_Search(clientID))
{
return true;
}
this.selectStr="insert into Client values("+"'"+clientID+"',"+"'"+clientName+"','"+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 clientID)
{
this.selectStr="select count(*) from CLient where ClientID="+"'"+clientID+"'";
this.sqlCommand1.CommandText=this.selectStr;
if(this.sqlConnection1.State==ConnectionState.Closed)
this.sqlConnection1.Open();
if(Convert.ToInt32(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.StoredProcedureAddClient";
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 + -