示例#1
0
        private async void OnReserveRoom(object sender, EventArgs e)
        {
            try
            {
                roomReservice           = new RoomReservaton();
                roomReservice.RoomName  = this.txtRoom.Text;
                roomReservice.StartTime = this.startDate.Value;
                roomReservice.EndTime   = this.endDate.Value;
                roomReservice.Contact   = this.txtContract.Text;
                roomReservice.Text      = this.text.Text;
                var client = new RoomServiceClient();
                //bool reserve = await client.ReserveRoomAsync(roomReservice);
                //client.Close();
                var          binding     = new BasicHttpBinding();
                var          address     = new EndpointAddress("http://localhost:9000/RoomReservation");
                var          factory     = new ChannelFactory <IRoomService>(binding, address);
                IRoomService roomService = factory.CreateChannel();
                bool         reserve     = await roomService.ReserveRoomAsync(roomReservice);

                if (reserve)
                {
                    MessageBox.Show("注册成功!", "提示");
                }
                else
                {
                    MessageBox.Show("注册失败!", "提示");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("服务器忙!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
 public bool ReserveRoom(RoomReservaton roomReservaton)
 {
     using (var data = new RoomReservationContext())
     {
         data.RoomReservaton.Add(roomReservaton);
         return(data.SaveChanges() > 0);
     }
 }
示例#3
0
        public bool ReserveRoom(RoomReservaton roomReservaton)
        {
            RoomReservationData data = new RoomReservationData();

            return(data.ReserveRoom(roomReservaton));
        }