roomtypemanage.cs
来自「基于 VC# 开发的一套旅馆信息管理系统系统。采用了三层结构的设计思想」· 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.util.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 HasToilet,int aircondition)
{
this.selectStr="insert into RoomType values("+"'"+typename+"',"+area+","+bednum+","+price+","+aircondition+","+telephone+","+tv+","+HasToilet+")";
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 HasToilet,int aircondition)
{
this.selectStr="update RoomType set Area="+area+","+"BedNum="+bednum+","+"Price="+price+","+"HasToilet="+HasToilet+","+"AirCondition="+aircondition+","+"HasTelevision="+tv+","+"HasPhone="+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 + -
显示快捷键?