private void buttonEdit_Click(object sender, EventArgs e) { if (txtBoxRoomID.TextLength <= 0 || txtBoxName.TextLength <= 0) { MessageBox.Show("Please select a room to edit first or make sure a name is provided.\nRequest Failed."); } else { try { RoomObj UsersRoom = new RoomObj(int.Parse(txtBoxRoomID.Text), txtBoxName.Text, rtxtBoxDesc.Text, TimeSpan.Parse(txtBoxOpenHour.Text), TimeSpan.Parse(txtBoxCloseHour.Text), checkBoxAvaliable.Checked); if (UsersRoom.Validate() == "") // Checking for anything not caught by the handle exception. { RoomObjCollection.Edit(UsersRoom); List(RoomObjCollection.List()); //Refresh } else { MessageBox.Show("Error: Your Room contains invalid values\n" + UsersRoom.Validate()); } } catch (Exception) { MessageBox.Show("One or more of your values is incorrect. Please check for mistakes.\nRequest Failed."); } } }
private void buttonDelete_Click(object sender, EventArgs e) { if (txtBoxRoomID.TextLength <= 0) { MessageBox.Show("Please select a room to edit first, then try deleting again."); } else { RoomObj UsersRoom = new RoomObj(int.Parse(txtBoxRoomID.Text), txtBoxName.Text, rtxtBoxDesc.Text, TimeSpan.Parse(txtBoxOpenHour.Text), TimeSpan.Parse(txtBoxCloseHour.Text), checkBoxAvaliable.Checked); if (UsersRoom.Validate() == "") // Checking for anything not caught by the handle exception. { RoomObjCollection.Delete(UsersRoom); List(RoomObjCollection.List()); //Refresh } else { MessageBox.Show("Error: Your Room contains invalid values\n" + UsersRoom.Validate()); } } }
// New Room/Row button private void buttonNew_Click(object sender, EventArgs e) { //Creates a new room obj and gives it to the Add method. Aftwards List is called to automatically refresh the data. try { RoomObj UsersRoom = new RoomObj(0, txtBoxName.Text, rtxtBoxDesc.Text, TimeSpan.Parse(txtBoxOpenHour.Text), TimeSpan.Parse(txtBoxCloseHour.Text), checkBoxAvaliable.Checked); if (UsersRoom.Validate() == "") // Checking for anything not caught by the handle exception. { RoomObjCollection.Add(UsersRoom); List(RoomObjCollection.List()); } else { MessageBox.Show("Error: Your Room contains invalid values\n" + UsersRoom.Validate()); } } catch (Exception) { MessageBox.Show("One or more of your values is incorrect. Please check for mistakes.\nRequest Failed."); } }
// Update/Refresh Button. private void button1_Click(object sender, EventArgs e) { List(RoomObjCollection.List()); // Lists the newest data. }
// Upon Initalisation, load the form and list everything in the database using this list class (to list given data) // and RoomObjCollection.List(); to give a list of all from the roommangement table. public rmsForm() { InitializeComponent(); List(RoomObjCollection.List()); }
public void RoomObjCollectionListOK() // Not null test basically. { DataTable TestData = RoomObjCollection.List(); Assert.AreNotEqual(TestData, null); }