HotelManagerDAL/RoomTypeService.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HotelManager.Models;
using System.Data.SqlClient;
namespace HotelManager.DAL
{
public class RoomTypeService
{
public static List<RoomType> GetAllType()
{
List<RoomType> allType = new List<RoomType>();
using (SqlConnection conn = DBHelper.GetConn())
{
string sql = "select * from RoomType";
SqlCommand cmd = new SqlCommand(sql, conn);
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
RoomType type = new RoomType();
type.Id = (int)dr["TypeId"];
type.TypeName = dr["TypeName"].ToString();
type.TypePrice = (Decimal)dr["TypePrice"];
allType.Add(type);
}
}
return allType;
}
}
public static int AddType(string typeName, Decimal price)
{
using (SqlConnection conn = DBHelper.GetConn())
{
string sql = "insert RoomType values (@TypeName,@Price)";
SqlCommand cmd = new SqlCommand(sql,conn);
SqlParameter[] para = {
new SqlParameter("@TypeName",typeName),
new SqlParameter("@Price",price)
};
cmd.Parameters.AddRange(para);
return cmd.ExecuteNonQuery();
}
}
public static int UpdateType(string typeName, Decimal price, int Id)
{
using (SqlConnection conn = DBHelper.GetConn())
{
string sql = "update RoomType set TypeName=@TypeName,TypePrice=@Price where TypeId=@Id";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlParameter[] para = {
new SqlParameter("@TypeName",typeName),
new SqlParameter("@Price",price),
new SqlParameter("@Id",Id)
};
cmd.Parameters.AddRange(para);
return cmd.ExecuteNonQuery();
后面还有 15 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
