public bool AddNewRoomType(RoomType roomType)
 {
     SqlParameter[] parameters = new SqlParameter[]
     {
         new SqlParameter("Name", roomType.Name),
         new SqlParameter("MaxCapacity", roomType.MaxCapacity)
     };
     return DBHelper.ExecuteNonQuery("sp_AddNewRoomType", CommandType.StoredProcedure, parameters);
 }
        public bool DeleteRoomType(RoomType roomType)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@TypeID", roomType.TypeID)
            };

            return DBHelper.ExecuteNonQuery("sp_DeleteRoomType", CommandType.StoredProcedure, parameters);
        }
        public bool UpdateRoomType(RoomType roomType)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@TypeID", roomType.TypeID),
                new SqlParameter("@Name", roomType.Name),
                new SqlParameter("@MaxCapacity", roomType.MaxCapacity),
                new SqlParameter("@RatePerNight", roomType.RatePerNight)
            };

            return DBHelper.ExecuteNonQuery("sp_UpdateRoomType", CommandType.StoredProcedure, parameters);
        }
        public RoomType ValidateRoomTypeName(string name)
        {
            RoomType roomType = null;

            SqlParameter[] paramaters = new SqlParameter[]
            {
                new SqlParameter("@Name", name)
            };

            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_CheckForDuplicateRoomTypeNames", CommandType.StoredProcedure, paramaters))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];

                    roomType = new RoomType();

                    roomType.Name = row["Name"].ToString();
                }
            }
            return roomType;
        }
        public List<RoomType> GetRoomTypeList(string selectedRadioButton)
        {
            string sqlCommand = "";
            if (selectedRadioButton == "Yes")
            {
                sqlCommand = "sp_GetAvailableRoomTypes";
            }

            else
            {
                sqlCommand = "sp_GetDeletedRoomTypes";
            }
            List<RoomType> roomTypeList = null;

            using (DataTable table = DBHelper.ExecuteSelectCommand(sqlCommand, CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    roomTypeList = new List<RoomType>();
                    foreach (DataRow row in table.Rows)
                    {
                        RoomType roomType = new RoomType();
                        roomType.TypeID = Convert.ToInt32(row["TypeID"]);
                        roomType.Name = row["Name"].ToString();
                        roomType.MaxCapacity = Convert.ToInt32(row["MaxCapacity"]);
                        roomType.Available = row["Available"].ToString();
                        roomType.RatePerNight = Convert.ToDouble(row["RatePerNight"]);
                        roomTypeList.Add(roomType);
                    }
                }
            }
            return roomTypeList;
        }
        public List<RoomType> GetRoomTypeList()
        {
            List<RoomType> listRoomTypes = null;

            using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetRoomTypeList", CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    listRoomTypes = new List<RoomType>();
                    foreach (DataRow row in table.Rows)
                    {
                        RoomType roomType = new RoomType();
                        roomType.TypeID = Convert.ToInt32(row["TypeID"]);
                        roomType.Name = row["Name"].ToString();

                        listRoomTypes.Add(roomType);
                    }
                }
            }
            return listRoomTypes;
        }
        public RoomType GetRoomTypeDetails(int typeID)
        {
            RoomType roomType = null;
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@TypeID", typeID)
            };
            using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetRoomTypeDetails", CommandType.StoredProcedure, parameters))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];
                    roomType = new RoomType();
                    roomType.TypeID = Convert.ToInt32(row["TypeID"]);
                    roomType.Name = row["Name"].ToString();
                    roomType.MaxCapacity = Convert.ToInt32(row["MaxCapacity"]);
                    roomType.RatePerNight = Convert.ToDouble(row["RatePerNight"]);

                }
            }
            return roomType;
        }
Beispiel #8
0
        /// <summary>
        /// 根据ID修改
        ///</summary>
        public static int UpdateRoomType(RoomType RoomTypeModel)
        {
            string sql = string.Format(" UPDATE RoomType  set Rt_Name='{0}',Rt_Price={1},Rt_Note='{2}' where Rt_Id={3} ", RoomTypeModel.Rt_Name, RoomTypeModel.Rt_Price, RoomTypeModel.Rt_Note, RoomTypeModel.Rt_Id);

            return(DBHelper.ExecuteCommand(sql));
        }
Beispiel #9
0
        /// <summary>
        /// 添加
        ///</summary>
        public static int AddRoomType(RoomType RoomTypeModel)
        {
            string sql = string.Format("insert into  RoomType (Rt_Name,Rt_Price,Rt_Note )values('{0}',{1},'{2}')", RoomTypeModel.Rt_Name, RoomTypeModel.Rt_Price, RoomTypeModel.Rt_Note);

            return(DBHelper.ExecuteCommand(sql));
        }