Exemple #1
0
 //If lecturer radio button changed
 private void Lecturer_radio_CheckedChanged(object sender, EventArgs e)
 {
     //If the radio button is checked
     if (Lecturer_radio.Checked == true)
     {
         //Clear chart
         chart.Series["Work Hours"].Points.Clear();
         //Enable combobox of lecturers
         lecturers_combo.Enabled = true;
         string[] days = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
         //Get name and id of the lecturer
         DataRowView oDataRowView = lecturers_combo.SelectedItem as DataRowView;
         string      name         = oDataRowView.Row["Name"] as string;
         int         id           = (int)oDataRowView.Row["ID"];
         //Change title
         chart_title.Text        = name + " work hours";
         lecturers_combo.Enabled = true;
         int     workHours;
         DataSet LecturerDS;
         //Get all lectures of the lecturer
         LecturerDS = SqlWorker.GetDataSet("Select * From Lecture Where Lecturer='" + id + "'");
         for (int i = 1; i <= 6; i++)
         {
             //Add each day work hours to the chart
             workHours = SqlWorker.getWorkHours(Convert.ToInt32(id), false, i);
             chart.Series["Work Hours"].Points.AddXY(days[i - 1], workHours);
         }
         //Remove lables with zero values in the pie chart
         updatePieChart();
     }
     else
     {
         lecturers_combo.Enabled = false;
     }
 }
Exemple #2
0
        //If all practitioners radio button was changed
        private void all_practitioner_radio_CheckedChanged(object sender, EventArgs e)
        {
            //If the radio button is checked
            if (all_practitioner_radio.Checked == true)
            {
                //Clear chart
                chart.Series["Work Hours"].Points.Clear();
                //Change title
                chart_title.Text = "Practitioners work hours";

                int amountOfPractitioners;
                //Get table containing all the practitioners
                DataSet practitionersDS = SqlWorker.GetDataSet("Select * from Users where type='Practitioner'");
                amountOfPractitioners = SqlWorker.getAmountOfPractitioners();
                //Get work hours for each practitioner and put it on the chart
                for (int i = 0; i < amountOfPractitioners; i++)
                {
                    String name      = practitionersDS.Tables[0].Rows[i]["Name"].ToString();
                    String id        = practitionersDS.Tables[0].Rows[i]["ID"].ToString();
                    int    workHours = SqlWorker.getWorkHours(Convert.ToInt32(id), true, -1);
                    chart.Series["Work Hours"].Points.AddXY(name, workHours);
                }
                //Remove lables with zero values in the pie chart
                updatePieChart();
            }
        }
Exemple #3
0
        private void practitioner_most_button_Click(object sender, EventArgs e)
        {
            //Get all practitioners
            DataSet practitioners = SqlWorker.GetDataSet("Select * from Users Where type='Practitioner'");

            //Show error message and exit if there is no practitioners
            if (practitioners.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("There is no practitioners in the system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            int maxWorkHours = 0, id, numOfLecturers = 0;

            //Find max of work hours
            for (int i = 0; i < practitioners.Tables[0].Rows.Count; i++)
            {
                id = Convert.ToInt32(practitioners.Tables[0].Rows[i]["ID"].ToString());
                int tmpWorkHours = SqlWorker.getWorkHours(id, true, -1);
                if (tmpWorkHours > maxWorkHours)
                {
                    maxWorkHours = tmpWorkHours;
                }
            }
            //Show error message and exit if none of the practitioners is working
            if (maxWorkHours == 0)
            {
                MessageBox.Show("There is no practitioner that is working!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Find the amount of practitioners with the maximum amount of work hours
            for (int i = 0; i < practitioners.Tables[0].Rows.Count; i++)
            {
                id = Convert.ToInt32(practitioners.Tables[0].Rows[i]["ID"].ToString());
                if (maxWorkHours == SqlWorker.getWorkHours(id, true, -1))
                {
                    numOfLecturers++;
                }
            }
            String msg;

            //Create the message
            if (numOfLecturers == 1)
            {
                msg = "The practitioner with the most hours is\n";
            }
            else
            {
                msg = "The practitioners with the most hours are\n";
            }
            //Add all practitioners to the message
            for (int i = 0; i < practitioners.Tables[0].Rows.Count; i++)
            {
                id = Convert.ToInt32(practitioners.Tables[0].Rows[i]["ID"].ToString());
                if (maxWorkHours == SqlWorker.getWorkHours(id, true, -1))
                {
                    msg += "Name: " + SqlWorker.getNameById(id.ToString()) + "\n";
                    msg += "ID: " + id + "\n";
                    msg += "Number of work hours: " + maxWorkHours.ToString() + "\n\n";
                }
            }
            //Show all lecturers with maximum amount of work hours
            MessageBox.Show(msg, "Works the most", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }