public void Populate_User_Search_List()
        {
            //Clear the ListView of all entries
            UserSearch_List.Items.Clear();

            // Run MySQL statement to find incidents by user name. It will populate the list
            // that's called in the foreach loop below. Only populate the list if incidents
            // exist in the database for that name
            if (Incidents.Get_Incidents_By_Name(Search_User_Textbox.Text) || Incidents.Get_Incidents_By_Dates(searchStartDate, searchEndDate))
            {
                foreach (RecordedIncident r in Incidents.ListOfIncidents)
                {
                    // First item is the UID. It's hidden in the list view, but
                    // the UID is needed to fill in the incident report details.
                    ListViewItem lvi = new ListViewItem(r.User_id);
                    lvi.SubItems.Add(r.First_name + " " + r.Last_name);
                    lvi.SubItems.Add(r.Incident_date);
                    lvi.SubItems.Add(r.Incident_time);
                    lvi.SubItems.Add(r.Incident_description);
                    UserSearch_List.Items.Add(lvi);

                    user_UID      = r.User_id;
                    user_fullName = r.First_name + " " + r.Last_name;

                    Add_Incident_Button.Enabled = true; // Also allow user to add a new incident for the user
                }
            }
            else
            {
                Add_Incident_Button.Enabled = false;
                MessageBox.Show("No incidents found. Most likely due to incorrect name");
            }
        }
        private void Add_Button_Clicked(object sender, EventArgs e)
        {
            this.Hide();

            Incidents.Add_Incident(_user_id, Description_Textbox.Text);
            // Repopulate the list, so the new description is can be seen
            _incidentsForm.Populate_User_Search_List();
        }
        /// <summary>
        /// Update the incident's description to what the user has entered
        /// </summary>
        private void Update_Button_Clicked(object sender, EventArgs e)
        {
            string uid = label_UID.Text;

            Console.WriteLine("UID = " + uid);
            Incidents.Update_Incident(uid, originalDescription, IncidentDescriber_TextBox.Text);

            // Repopulate the list, so the new description is can be seen
            Populate_User_Search_List();
        }
示例#4
0
        public void Staff_should_search_resident_by_name()
        {
            // Add an incident before hand
            string theIncident = "Resident dropped item on their foot.";

            Incidents.Add_Incident("5", theIncident);

            // Test should only pass if the program returns the name of the resident the user was searching for
            Assert.IsTrue(Incidents.Get_Incidents_By_Name("resident"));

            // Delete the entry once done
            string[] columnNames          = { "UID", "IncidentDescription" };
            string[] columnExpectedValues = { "5", theIncident };
            _mysql.Delete_Entries("5", "Incidents", columnNames, columnExpectedValues);
        }
示例#5
0
        public void Staff_should_add_incidents()
        {
            string theIncident = "Resident refused to take their medicine";

            // Add the incident
            Incidents.Add_Incident("5", theIncident);
            // It should only pass if the incident now exists in the database
            string[] columnsToCheck = { "UID", "IncidentDescription" };
            string[] columnValues   = { "5", theIncident };

            Assert.IsTrue(_mysql.DataDoesExist("Incidents", columnsToCheck, columnValues));

            // Remove the test entry from the database
            _mysql.Delete_Entries("5", "Incidents", columnsToCheck, columnValues);
        }
示例#6
0
        public void Staff_should_update_incident_details()
        {
            // First add a sample incident to the database.
            string theIncident = "Resident refused to take their medicine";

            // User ID is 5
            Incidents.Add_Incident("5", theIncident);

            // Change the description
            string updatedDesc = "Resident refused to take their medicine, SuperDrug. They became aggressive" +
                                 " when confronted by staff";

            // Update the entry
            Incidents.Update_Incident("5", theIncident, updatedDesc);

            string[] columnNames          = { "UID", "IncidentDescription" };
            string[] columnExpectedValues = { "5", updatedDesc };

            // Test passes if the entry has changed
            Assert.IsTrue(_mysql.DataDoesExist("Incidents", columnNames, columnExpectedValues));

            // Delete once done
            _mysql.Delete_Entries("5", "Incidents", columnNames, columnExpectedValues);
        }
示例#7
0
 public void Staff_should_search_by_date()
 {
     // Test should only pass if the program returns the incidents for a given time period and not before or after
     Assert.IsTrue(Incidents.Get_Incidents_By_Date("2018-05-23"));
 }
示例#8
0
 public void Staff_should_see_list_of_users_incidents()
 {
     // It should only pass if it finds the incident reports from the database
     Assert.IsTrue(Incidents.Get_Incidents_By_Name("resident"));
 }