📄 hotelroomprice.cs.svn-base
字号:
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//请先添加引用
namespace Maticsoft.DAL
{
/// <summary>
/// 数据访问类HotelRoomPrice。
/// </summary>
public class HotelRoomPrice
{
public HotelRoomPrice()
{}
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(string HotelID,string RoomType)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from HotelRoomPrice");
strSql.Append(" where HotelID=@HotelID and RoomType=@RoomType ");
SqlParameter[] parameters = {
new SqlParameter("@HotelID", SqlDbType.NVarChar,50),
new SqlParameter("@RoomType", SqlDbType.NVarChar,50)};
parameters[0].Value = HotelID;
parameters[1].Value = RoomType;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public void Add(Maticsoft.Model.HotelRoomPrice model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into HotelRoomPrice(");
strSql.Append("HotelID,RoomType,Price,CashPrice,HasBreakfast,BedType,HasInternet,LocalFloor,RoomTrait,BreakfastPrice1,BreakfastPrice2,Area,AddBedPrice,RoomAmount,Remark)");
strSql.Append(" values (");
strSql.Append("@HotelID,@RoomType,@Price,@CashPrice,@HasBreakfast,@BedType,@HasInternet,@LocalFloor,@RoomTrait,@BreakfastPrice1,@BreakfastPrice2,@Area,@AddBedPrice,@RoomAmount,@Remark)");
SqlParameter[] parameters = {
new SqlParameter("@HotelID", SqlDbType.NVarChar,12),
new SqlParameter("@RoomType", SqlDbType.NVarChar,20),
new SqlParameter("@Price", SqlDbType.Decimal,9),
new SqlParameter("@CashPrice", SqlDbType.Decimal,9),
new SqlParameter("@HasBreakfast", SqlDbType.Bit,1),
new SqlParameter("@BedType", SqlDbType.NVarChar,10),
new SqlParameter("@HasInternet", SqlDbType.Bit,1),
new SqlParameter("@LocalFloor", SqlDbType.NVarChar,20),
new SqlParameter("@RoomTrait", SqlDbType.NVarChar,100),
new SqlParameter("@BreakfastPrice1", SqlDbType.Decimal,9),
new SqlParameter("@BreakfastPrice2", SqlDbType.Decimal,9),
new SqlParameter("@Area", SqlDbType.Decimal,9),
new SqlParameter("@AddBedPrice", SqlDbType.Decimal,9),
new SqlParameter("@RoomAmount", SqlDbType.Int,4),
new SqlParameter("@Remark", SqlDbType.Text)};
parameters[0].Value = model.HotelID;
parameters[1].Value = model.RoomType;
parameters[2].Value = model.Price;
parameters[3].Value = model.CashPrice;
parameters[4].Value = model.HasBreakfast;
parameters[5].Value = model.BedType;
parameters[6].Value = model.HasInternet;
parameters[7].Value = model.LocalFloor;
parameters[8].Value = model.RoomTrait;
parameters[9].Value = model.BreakfastPrice1;
parameters[10].Value = model.BreakfastPrice2;
parameters[11].Value = model.Area;
parameters[12].Value = model.AddBedPrice;
parameters[13].Value = model.RoomAmount;
parameters[14].Value = model.Remark;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public void Update(Maticsoft.Model.HotelRoomPrice model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update HotelRoomPrice set ");
strSql.Append("Price=@Price,");
strSql.Append("CashPrice=@CashPrice,");
strSql.Append("HasBreakfast=@HasBreakfast,");
strSql.Append("BedType=@BedType,");
strSql.Append("HasInternet=@HasInternet,");
strSql.Append("LocalFloor=@LocalFloor,");
strSql.Append("RoomTrait=@RoomTrait,");
strSql.Append("BreakfastPrice1=@BreakfastPrice1,");
strSql.Append("BreakfastPrice2=@BreakfastPrice2,");
strSql.Append("Area=@Area,");
strSql.Append("AddBedPrice=@AddBedPrice,");
strSql.Append("RoomAmount=@RoomAmount,");
strSql.Append("Remark=@Remark");
strSql.Append(" where HotelID=@HotelID and RoomType=@RoomType ");
SqlParameter[] parameters = {
new SqlParameter("@HotelID", SqlDbType.NVarChar,12),
new SqlParameter("@RoomType", SqlDbType.NVarChar,20),
new SqlParameter("@Price", SqlDbType.Decimal,9),
new SqlParameter("@CashPrice", SqlDbType.Decimal,9),
new SqlParameter("@HasBreakfast", SqlDbType.Bit,1),
new SqlParameter("@BedType", SqlDbType.NVarChar,10),
new SqlParameter("@HasInternet", SqlDbType.Bit,1),
new SqlParameter("@LocalFloor", SqlDbType.NVarChar,20),
new SqlParameter("@RoomTrait", SqlDbType.NVarChar,100),
new SqlParameter("@BreakfastPrice1", SqlDbType.Decimal,9),
new SqlParameter("@BreakfastPrice2", SqlDbType.Decimal,9),
new SqlParameter("@Area", SqlDbType.Decimal,9),
new SqlParameter("@AddBedPrice", SqlDbType.Decimal,9),
new SqlParameter("@RoomAmount", SqlDbType.Int,4),
new SqlParameter("@Remark", SqlDbType.Text)};
parameters[0].Value = model.HotelID;
parameters[1].Value = model.RoomType;
parameters[2].Value = model.Price;
parameters[3].Value = model.CashPrice;
parameters[4].Value = model.HasBreakfast;
parameters[5].Value = model.BedType;
parameters[6].Value = model.HasInternet;
parameters[7].Value = model.LocalFloor;
parameters[8].Value = model.RoomTrait;
parameters[9].Value = model.BreakfastPrice1;
parameters[10].Value = model.BreakfastPrice2;
parameters[11].Value = model.Area;
parameters[12].Value = model.AddBedPrice;
parameters[13].Value = model.RoomAmount;
parameters[14].Value = model.Remark;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public void Delete(string HotelID,string RoomType)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete HotelRoomPrice ");
strSql.Append(" where HotelID=@HotelID and RoomType=@RoomType ");
SqlParameter[] parameters = {
new SqlParameter("@HotelID", SqlDbType.NVarChar,50),
new SqlParameter("@RoomType", SqlDbType.NVarChar,50)};
parameters[0].Value = HotelID;
parameters[1].Value = RoomType;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Maticsoft.Model.HotelRoomPrice GetModel(string HotelID,string RoomType)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select HotelID,RoomType,Price,CashPrice,HasBreakfast,BedType,HasInternet,LocalFloor,RoomTrait,BreakfastPrice1,BreakfastPrice2,Area,AddBedPrice,RoomAmount,Remark from HotelRoomPrice ");
strSql.Append(" where HotelID=@HotelID and RoomType=@RoomType ");
SqlParameter[] parameters = {
new SqlParameter("@HotelID", SqlDbType.NVarChar,50),
new SqlParameter("@RoomType", SqlDbType.NVarChar,50)};
parameters[0].Value = HotelID;
parameters[1].Value = RoomType;
Maticsoft.Model.HotelRoomPrice model=new Maticsoft.Model.HotelRoomPrice();
DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
if(ds.Tables[0].Rows.Count>0)
{
model.HotelID=ds.Tables[0].Rows[0]["HotelID"].ToString();
model.RoomType=ds.Tables[0].Rows[0]["RoomType"].ToString();
if(ds.Tables[0].Rows[0]["Price"].ToString()!="")
{
model.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
}
if(ds.Tables[0].Rows[0]["CashPrice"].ToString()!="")
{
model.CashPrice=decimal.Parse(ds.Tables[0].Rows[0]["CashPrice"].ToString());
}
if(ds.Tables[0].Rows[0]["HasBreakfast"].ToString()!="")
{
if((ds.Tables[0].Rows[0]["HasBreakfast"].ToString()=="1")||(ds.Tables[0].Rows[0]["HasBreakfast"].ToString().ToLower()=="true"))
{
model.HasBreakfast=true;
}
else
{
model.HasBreakfast=false;
}
}
model.BedType=ds.Tables[0].Rows[0]["BedType"].ToString();
if(ds.Tables[0].Rows[0]["HasInternet"].ToString()!="")
{
if((ds.Tables[0].Rows[0]["HasInternet"].ToString()=="1")||(ds.Tables[0].Rows[0]["HasInternet"].ToString().ToLower()=="true"))
{
model.HasInternet=true;
}
else
{
model.HasInternet=false;
}
}
model.LocalFloor=ds.Tables[0].Rows[0]["LocalFloor"].ToString();
model.RoomTrait=ds.Tables[0].Rows[0]["RoomTrait"].ToString();
if(ds.Tables[0].Rows[0]["BreakfastPrice1"].ToString()!="")
{
model.BreakfastPrice1=decimal.Parse(ds.Tables[0].Rows[0]["BreakfastPrice1"].ToString());
}
if(ds.Tables[0].Rows[0]["BreakfastPrice2"].ToString()!="")
{
model.BreakfastPrice2=decimal.Parse(ds.Tables[0].Rows[0]["BreakfastPrice2"].ToString());
}
if(ds.Tables[0].Rows[0]["Area"].ToString()!="")
{
model.Area=decimal.Parse(ds.Tables[0].Rows[0]["Area"].ToString());
}
if(ds.Tables[0].Rows[0]["AddBedPrice"].ToString()!="")
{
model.AddBedPrice=decimal.Parse(ds.Tables[0].Rows[0]["AddBedPrice"].ToString());
}
if(ds.Tables[0].Rows[0]["RoomAmount"].ToString()!="")
{
model.RoomAmount=int.Parse(ds.Tables[0].Rows[0]["RoomAmount"].ToString());
}
model.Remark=ds.Tables[0].Rows[0]["Remark"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select HotelID,RoomType,Price,CashPrice,HasBreakfast,BedType,HasInternet,LocalFloor,RoomTrait,BreakfastPrice1,BreakfastPrice2,Area,AddBedPrice,RoomAmount,Remark ");
strSql.Append(" FROM HotelRoomPrice ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
/*
/// <summary>
/// 分页获取数据列表
/// </summary>
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@IsReCount", SqlDbType.Bit),
new SqlParameter("@OrderType", SqlDbType.Bit),
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
};
parameters[0].Value = "HotelRoomPrice";
parameters[1].Value = "ID";
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = 0;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/
#endregion 成员方法
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -