コード例 #1
0
        public static List <RoomTypeModel> GetAllRoomTypeModel()
        {
            List <RoomTypeModel> list = new List <RoomTypeModel>();
            SqlConnection        conn = Connection.GetConnection();

            if (conn != null)
            {
                string     sql = "select * from RoomType";
                SqlCommand cm  = new SqlCommand(sql, conn);
                var        rs  = cm.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        RoomTypeModel rt = new RoomTypeModel();
                        rt.RoomTypeID  = rs.GetInt32(0);
                        rt.RoomStyle   = RoomStyleDAO.GetRoomStyle(rs.GetInt32(1));
                        rt.RoomSize    = RoomSizeDAO.GetRoomSize(rs.GetInt32(2));
                        rt.Price       = rs.GetInt32(3);
                        rt.Description = rs.GetString(4);
                        list.Add(rt);
                    }
                }
                conn.Close();
            }
            ;
            return(list);
        }
コード例 #2
0
        public static RoomTypeModel GetRoomTypeModel(int id)
        {
            RoomTypeModel rt   = null;
            SqlConnection conn = Connection.GetConnection();

            if (conn != null)
            {
                string     sql = "select * from RoomType where RoomTypeID = @id";
                SqlCommand cm  = new SqlCommand(sql, conn);
                cm.Parameters.AddWithValue("@id", id);
                var rs = cm.ExecuteReader();
                if (rs.HasRows)
                {
                    if (rs.Read())
                    {
                        rt             = new RoomTypeModel();
                        rt.RoomTypeID  = rs.GetInt32(0);
                        rt.RoomStyle   = RoomStyleDAO.GetRoomStyle(rs.GetInt32(1));
                        rt.RoomSize    = RoomSizeDAO.GetRoomSize(rs.GetInt32(2));
                        rt.Price       = rs.GetInt32(3);
                        rt.Description = rs.GetString(4);
                    }
                }
                conn.Close();
            }
            ;
            return(rt);
        }