Beispiel #1
0
        private void Rect_MouseMove(object sender, MouseEventArgs e)
        {
            rect = (Button)sender;
            if (!rect.IsMouseCaptured)
            {
                return;
            }
            if (moveButton)
            {
                // get the position of the mouse relative to the Canvas
                var mousePos = e.GetPosition(RoomCanvas);

                // center the rect on the mouse
                double left = mousePos.X - (rect.ActualWidth / 2);
                double top  = mousePos.Y - (rect.ActualHeight / 2);
                if (isEdit)
                {//boundary for left side
                    if (left < 0)
                    {
                        left = 0;
                    }
                    //boundary for right side
                    if (left > this.ActualWidth - rect.ActualWidth * 1.16)
                    {
                        left = this.ActualWidth - rect.ActualWidth * 1.16;
                    }
                    //boundary for top
                    if (top < 0)
                    {
                        top = 0;
                    }
                    //boundary for bottom
                    if (top > this.ActualHeight - rect.ActualHeight * 2.58)
                    {
                        top = this.ActualHeight - rect.ActualHeight * 2.58;
                    }
                    Canvas.SetLeft(rect, left);
                    Canvas.SetTop(rect, top);
                    foreach (var e1 in roomList)
                    {
                        //check room list to see if object selected is any of the room
                        if (rect == e1.RoomButton)
                        {
                            room = e1; // grabs room object if the rect is selected
                        }
                    } //this loop is to find the room object that is attached to rect
                    room.Left = Canvas.GetLeft(rect);
                    room.Top  = Canvas.GetTop(rect);

                    //create updated entity
                    var modifiedRoom = new Room()
                    {
                        RoomNo   = room.RoomNo,
                        Left     = room.Left,
                        Top      = room.Top,
                        NoOfBeds = room.NoOfBeds,
                        BedType  = room.BedType,
                        //  Checkin = room.Checkin,
                        //  Checkout = room.Checkout,
                        Legend  = room.Legend,
                        Price   = room.Price,
                        Smoking = room.Smoking
                                  // create room object and store input to local variables
                    };

                    using (DatabaseContext dbContext = new DatabaseContext())
                    {
                        dbContext.Update <Room>(modifiedRoom); //update database
                        dbContext.SaveChanges();               //save changes
                    }
                }
            }
            else
            {
                foreach (var e1 in roomList)
                {
                    //check room list to see if object selected is any of the room
                    if (rect == e1.RoomButton)
                    {
                        room = e1; // grabs room object if the rect is selected
                    }
                } //this loop is to find the room object that is attached to rect
                if (isEdit && !deleteButton) //edit room info
                {
                    RoomInfo editRoom = new RoomInfo(ref room);
                    //fill out textbox with room data
                    editRoom.TextBoxBedType.Text          = room.BedType;
                    editRoom.TextBoxRoomNo.Text           = room.RoomNo.ToString();
                    editRoom.TextBoxRoomNo.IsReadOnly     = true;
                    editRoom.TextBoxRoomNo.Background     = new SolidColorBrush(Color.FromArgb(115, 220, 220, 220));
                    editRoom.TextBoxNoOfBeds.Text         = room.NoOfBeds.ToString();
                    editRoom.TextBoxPrice.Text            = room.Price.ToString();
                    editRoom.ComboBoxSmoking.SelectedItem = room.Smoking;
                    editRoom.ShowDialog();
                }
                else if (deleteButton)
                {
                    foreach (var e1 in roomList)
                    {
                        //check room list to see if object selected is any of the room
                        if (rect == e1.RoomButton)
                        {
                            room = e1; // grabs room object if the rect is selected
                        }
                    } //this loop is to find the room object that is attached to rect
                    //Room delete dailog
                    string           sMessageBoxText = "Do you want to delete this room?";
                    string           sCaption        = "Delete Room";
                    MessageBoxButton btnMessageBox   = MessageBoxButton.YesNo;
                    MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

                    MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                    switch (rsltMessageBox)
                    {
                    case MessageBoxResult.Yes:

                        if (room.Legend.Equals("Vacant") || room.Legend.Equals("Dirty"))
                        {
                            roomList.Remove(room);
                            RoomCanvas.Children.Remove(rect);
                            var deletedRoom = new Room()
                            {
                                RoomNo = room.RoomNo
                            };
                            using (var context = new DatabaseContext())
                            {
                                context.Remove <Room>(deletedRoom);
                                context.SaveChanges();
                            }
                            InvalidateVisual();
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("There is a customer in the current room.");
                        }
                        break;

                    case MessageBoxResult.No:
                        /* ... */
                        break;
                    }
                }
            }
        }
Beispiel #2
0
 public Check(RoomData room)
 {
     this.room = room;
     InitializeComponent();
     UpdateLabels();
 }
Beispiel #3
0
        void CheckButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (var e1 in roomList)
            {
                //check room list to see if object selected is any of the room
                if (rect == e1.RoomButton)
                {
                    room = e1; // grabs room object if the rect is selected
                }
            } //this loop is to find the room object that is attached to rect

            //checking in customer window
            rect = (Button)sender;
            if (room.Legend.Equals("Dirty"))
            {
                //Room delete dailog
                string           sMessageBoxText = "Has this room been cleaned?";
                string           sCaption        = "Room Clean and Vacant";
                MessageBoxButton btnMessageBox   = MessageBoxButton.YesNo;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

                MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.Yes:
                    room.Empty();
                    room.Legend = "Vacant";

                    using (DatabaseContext dbContext = new DatabaseContext())
                    {
                        roomQuery        = dbContext.Rooms.Find(room.RoomNo);
                        roomQuery.Legend = "Vacant";
                    }
                    break;

                case MessageBoxResult.No:
                    break;
                }
            }
            else if (!isEdit)
            {
                Check checkWindow = new Check(room);
                //  checkWindow.TextBofRoom.Text = Convert.ToString(room.RoomNo);
                using (DatabaseContext dbContext = new DatabaseContext())
                {
                    roomQuery = dbContext.Rooms.Find(room.RoomNo);
                    if (roomQuery.Legend == "Occupied")
                    {
                        checkWindow.PopulateTextBoxes();
                        checkWindow.DisableTextBoxes();
                        //checkWindow.CheckOutEnable();
                        //checkWindow.ShowDialog();
                        Main.NavigationService.Navigate(checkWindow);
                    }
                    else
                    {   // N a v i g a t e   b  a c k  h o m e
                        //checkWindow.CheckInEnable();
                        //checkWindow.ShowDialog();
                        Main.NavigationService.Navigate(checkWindow);
                    }
                }
            }
        }