/// <summary> /// Handle createCentreButtonClick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createCentreButton_Click(object sender, RoutedEventArgs e) { string description = new TextRange(centreDescriptionText.Document.ContentStart, centreDescriptionText.Document.ContentEnd).Text; InputTester checker = new InputTester(); //Checkiung input if (checker.ensureName(centreNameBox.Text) && checker.ensureCode(centreCodeBox.Text) && checker.ensureDescription(description)) { MeetingCentre newMeetingCentre = new MeetingCentre(centreNameBox.Text, centreCodeBox.Text, description); Globals.meetingCentresList.Add(newMeetingCentre); Globals.needSave = true; MainWindow newMain = new MainWindow(); newMain.Show(); this.Close(); } else { string message = "Bad data format:" + Environment.NewLine + "Name – text in 2 - 100 characters." + Environment.NewLine + "Code - unique code length 5 to 50, can contain numbers, letters a-z and A-Z, also special characters (. : - _)" + Environment.NewLine + "Description - length 10 - 300 characters" + Environment.NewLine + "Capacity - integer 1 to 100 if requested"; MessageBox.Show(message); } }
/// <summary> /// handles edit centre click.Checks all inputs and update data if pass. otherwise popup message window w2ith general info about data format. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditMeetingCentreButton_Click(object sender, RoutedEventArgs e) { if (MeetingCentres.SelectedItem != null) { InputTester checker = new InputTester(); //checking inputs if (checker.ensureName(editCentreName.Text) && checker.ensureCode(editCentreCode.Text) && checker.ensureDescription(editCentreDescription.Text)) { MeetingCentre selected = (MeetingCentre)MeetingCentres.SelectedItem; selected.centreName = editCentreName.Text; selected.centreCode = editCentreCode.Text; selected.centreDescription = editCentreDescription.Text; Globals.needSave = true; MeetingCentres.Items.Refresh(); } else { string message = "Bad data format:" + Environment.NewLine + "Name – text in 2 - 100 characters." + Environment.NewLine + "Code - unique code length 5 to 50, can contain numbers, letters a-z and A-Z, also special characters (. : - _)" + Environment.NewLine + "Description - length 10 - 300 characters" + Environment.NewLine + "Capacity - integer 1 to 100 if requested"; MessageBox.Show(message); } } else { MessageBox.Show("Select Meeting Centre first!"); } }
/// <summary> /// Handle Create button click. Should check user input and redirect me back to main window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createRoomButton_Click(object sender, RoutedEventArgs e) { MeetingCentre cent = (MeetingCentre)test; InputTester checker = new InputTester(); int capacity = 0; int.TryParse(roomCapacity.Text, out capacity); string description = new TextRange(roomDescription.Document.ContentStart, roomDescription.Document.ContentEnd).Text; //checking user input if (checker.ensureName(roomName.Text) && checker.ensureCode(roomCode.Text) && checker.ensureDescription(description) && checker.ensureCapacity(capacity)) { cent.meetingRoomsList.Add(new MeetingRoom(roomName.Text, roomCode.Text, description, capacity, (bool)videoCheck.IsChecked, cent.centreCode)); Globals.needSave = true; MainWindow newMain = new MainWindow(); newMain.Show(); this.Close(); } else { string message = "Bad data format:" + Environment.NewLine + "Name – text in 2 - 100 characters." + Environment.NewLine + "Code - unique code length 5 to 50, can contain numbers, letters a-z and A-Z, also special characters (. : - _)" + Environment.NewLine + "Description - length 10 - 300 characters" + Environment.NewLine + "Capacity - integer 1 to 100 if requested"; MessageBox.Show(message); } }
/// <summary> /// Method to handle edit room button, works only if room is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editRoomButton_Click(object sender, RoutedEventArgs e) { if (MeetingRooms.SelectedItem != null) { MeetingRoom selected = (MeetingRoom)MeetingRooms.SelectedItem; InputTester checker = new InputTester(); int capacity = 0; int.TryParse(editRoomCapacity.Text, out capacity); //ensure correct inputs if (checker.ensureName(editRoomName.Text) && checker.ensureCode(editRoomCode.Text) && checker.ensureDescription(editRoomDescription.Text) && checker.ensureCapacity(capacity)) { selected.roomName = editRoomName.Text; selected.roomCode = editRoomCode.Text; selected.roomDescription = editRoomDescription.Text; selected.roomCapacity = capacity; selected.roomVideo = (bool)editVideo.IsChecked; Globals.needSave = true; MeetingRooms.Items.Refresh(); } else { string message = "Bad data format:" + Environment.NewLine + "Name – text in 2 - 100 characters." + Environment.NewLine + "Code - unique code length 5 to 50, can contain numbers, letters a-z and A-Z, also special characters (. : - _)" + Environment.NewLine + "Description - length 10 - 300 characters" + Environment.NewLine + "Capacity - integer 1 to 100 if requested"; MessageBox.Show(message); } } else { MessageBox.Show("Select Meeting Room first!"); } }