Example #1
0
        private void editRoomButton_Click(object sender, EventArgs e)
        {
            var toEdit = roomGridView.SelectedRows[0].DataBoundItem as Room;

            if (toEdit.Occupied == false)
            {
                var pf = new RoomForm(hotel, toEdit);
                if (pf.ShowDialog() == DialogResult.OK)
                {
                    roomBindingSource.ResetBindings(false);
                    hotel.IsDirty = true;
                }
            }
            else
            {
                MessageBox.Show("Номер сейчас занят.");
            }
        }
Example #2
0
        private void addRoomButton_Click(object sender, EventArgs e)
        {
            if (hotel.CheckFreeRooms())
            {
                var rf = new RoomForm(hotel);
                if (rf.ShowDialog() == DialogResult.OK)
                {
                    hotel.AddRoom(rf.Room);
                    roomBindingSource.ResetBindings(false);
                    hotel.IsDirty = true;

                    // Обрати та перейти до останнього рядка.
                    var lastIdx = roomGridView.Rows.Count - 1;
                    roomGridView.Rows[lastIdx].Selected          = true;
                    roomGridView.FirstDisplayedScrollingRowIndex = lastIdx;
                }
            }
            else
            {
                MessageBox.Show("В отеле нет свободных для добавления номеров.");
            }
        }