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");
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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"));
 }