Đang chuẩn bị liên kết để tải về tài liệu:
Network Programming in .NET With C# and Visual Basic .NET phần 9
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
và dtDeparture. Một hộp combo có tên là cbType cũng được yêu cầu. Bạn phải click vào mục tài sản cho hộp kết hợp và bổ sung thêm ba chuỗi: cơ bản, trên bộ, và sang trọng. Nhấp vào nút Send và thêm mã sau đây: C # | 15.3 Implementing a message queue 429 VB.NET Public Class booking Public Enum RoomType BASIC EN_SUITE DELUXE End Enum Public Class Room Public occupants As Int16 Public roomType As RoomType End Class Public name As String Public myRoom As Room Public arrival As DateTime Public departure As DateTime End Class Select the Form Design tab and remove the textbox tbMessage from the form. Now drag on two textboxes named tbName and tbOccupants. If you wish you can use labels to indicate what each textbox is used for although this is not essential. Draw on two Date-Picker controls named dtArrival and dtDeparture. A combo box named cbType is also required. You must click on the Items property for the combo box and add three strings basic en suite and deluxe. Click on the Send button and add the following code C private void btnSend_Click object sender System.EventArgs e string queueName . private test MessageQueue mq if MessageQueue.Exists queueName mq new MessageQueue queueName else _I Chapter 15 430 15.3 Implementing a message queue mq MessageQueue.Create queueName booking hotelBooking new booking hotelBooking.name tbName.Text hotelBooking.departure DateTime.Parse dtDeparture.Text hotelBooking.arrival DateTime.Parse dtArrival.Text hotelBooking.room new booking.Room hotelBooking.room.occupants Convert.ToInt16 tbOccupants.Text switch cbType.SelectedIndex.ToString case basic hotelBooking.room.roomType booking.RoomType.BASIC break case en suite hotelBooking.room.roomType booking.RoomType.EN_SUITE break case deluxe hotelBooking.room.roomType booking.RoomType.DELUXE break mq.Send hotelBooking VB.NET Private Sub btnSend_Click ByVal sender As Object _ ByVal e As System.EventArgs Dim queueName As String . private test Dim mq As MessageQueue If MessageQueue.Exists queueName Then mq New MessageQueue queueName Else mq MessageQueue.Create queueName End If Dim hotelBooking As booking New booking hotelBooking.name .