예제 #1
0
 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.");
         }
     }
 }
예제 #2
0
        // Find Button.
        private void buttonFind_Click(object sender, EventArgs e)
        {
            String findIn = "";                                                                                    // Needs to be declared otherwise compiler screams at you.

            RadioButton radio = radioGroup.Controls.OfType <RadioButton>().Where(x => x.Checked).FirstOrDefault(); // Gets the radio button in the group thats checked using a simple function and predicate.

            if (radio != null)
            {
                switch (radio.Name)
                {
                case "rbRoomID":
                    findIn = "roomID";
                    break;

                case "rbName":
                    findIn = "roomName";
                    break;

                case "rbDescription":
                    findIn = "roomDescription";
                    break;

                case "rbOpenningHour":
                    findIn = "roomOpeningTime";
                    break;

                case "rbClosingHour":
                    findIn = "roomClosingTime";
                    break;

                case "rbAvaliable":
                    findIn = "roomStatus";
                    break;
                }

                switch (txtBoxFind.Text.ToLower())
                {
                case "true":
                    List(RoomObjCollection.Find(findIn, "1"));
                    break;

                case "false":
                    List(RoomObjCollection.Find(findIn, "0"));
                    break;

                default:
                    List(RoomObjCollection.Find(findIn, txtBoxFind.Text));
                    break;
                }
            }
            else
            {
                MessageBox.Show("Please select an option to find in / filter through.");
            }
        }
예제 #3
0
        private void buttonFilter_Click(object sender, EventArgs e)
        {
            String filterIn = "";

            RadioButton radio = radioGroup.Controls.OfType <RadioButton>().Where(x => x.Checked).FirstOrDefault(); // Gets the radio button in the group thats checked using a simple function and predicate.

            if (radio != null)
            {
                switch (radio.Name) // Converts the radio button to the column name in database.
                {
                case "rbRoomID":
                    filterIn = "roomID";
                    break;

                case "rbName":
                    filterIn = "roomName";
                    break;

                case "rbDescription":
                    filterIn = "roomDescription";
                    break;

                case "rbOpenningHour":
                    filterIn = "roomOpeningTime";
                    break;

                case "rbClosingHour":
                    filterIn = "roomClosingTime";
                    break;

                case "rbAvaliable":
                    filterIn = "roomStatus";
                    break;
                }

                switch (txtBoxFind.Text.ToLower()) // Converts true and false to 1 or 0 respectively else submits a normal request.
                {
                case "true":
                    List(RoomObjCollection.Filter(filterIn, "1"));
                    break;

                case "false":
                    List(RoomObjCollection.Filter(filterIn, "0"));
                    break;

                default:
                    List(RoomObjCollection.Filter(filterIn, txtBoxFind.Text));
                    break;
                }
            }
            else
            {
                MessageBox.Show("Please select an option to find in / filter through.");
            }
        }
예제 #4
0
 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());
         }
     }
 }
예제 #5
0
        // 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.");
            }
        }
예제 #6
0
 // Update/Refresh Button.
 private void button1_Click(object sender, EventArgs e)
 {
     List(RoomObjCollection.List()); // Lists the newest data.
 }
예제 #7
0
 // 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());
 }
예제 #8
0
        public void RoomObjCollectionListOK() // Not null test basically.
        {
            DataTable TestData = RoomObjCollection.List();

            Assert.AreNotEqual(TestData, null);
        }