//If all lectures radio button changed private void All_lectures_radio_CheckedChanged(object sender, EventArgs e) { //If the radio button is checked if (All_lectures_radio.Checked == true) { //Clear chart chart.Series["Work Hours"].Points.Clear(); //Change title chart_title.Text = "Lecturers work hours"; int amountOfLecturers; //Get table of all lecturers DataSet lecturersDS = SqlWorker.GetDataSet("Select * from Users where type='Lecturer'"); amountOfLecturers = SqlWorker.getAmountOfLecturers(); //Get work houres for each lecturer and puit it on the chart for (int i = 0; i < amountOfLecturers; i++) { String name = lecturersDS.Tables[0].Rows[i]["Name"].ToString(); String id = lecturersDS.Tables[0].Rows[i]["ID"].ToString(); int workHours = SqlWorker.getWorkHours(Convert.ToInt32(id), false, -1); chart.Series["Work Hours"].Points.AddXY(name, workHours); } //Remove lables with zero values in the pie chart updatePieChart(); } }
//Constructor public Add_new_course() { InitializeComponent(); this.Size = new Size(351, 375); if (SqlWorker.getAmountOfLecturers() > 1 && SqlWorker.getAmountOfPractitioners() > 1) { LecturerID_combo.DataSource = SqlWorker.GetDataSet("SELECT * From Users Where type='Lecturer'").Tables[0]; LecturerID_combo.DisplayMember = "Name"; practitionerID_combo.DataSource = SqlWorker.GetDataSet("SELECT * From Users Where type='Practitioner'").Tables[0]; practitionerID_combo.DisplayMember = "Name"; } else { MessageBox.Show("There is no practitioners/lecturers in the system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
//Ctor public Work_Hours() { InitializeComponent(); //Fill comboboxes of lecturers and practitioners if (SqlWorker.getAmountOfLecturers() > 0 || SqlWorker.getAmountOfPractitioners() > 0) { chart_type_combo.SelectedIndex = 0; if (SqlWorker.getAmountOfLecturers() > 0) { lecturers_combo.DataSource = SqlWorker.GetDataSet("SELECT * From Users Where type='Lecturer'").Tables[0]; lecturers_combo.DisplayMember = "Name"; lecturers_combo.SelectedIndex = 0; } else { All_lectures_radio.Enabled = false; Lecturer_radio.Enabled = false; lecturers_combo.Enabled = false; } if (SqlWorker.getAmountOfPractitioners() > 0) { practitioner_combo.DataSource = SqlWorker.GetDataSet("SELECT * From Users Where type='Practitioner'").Tables[0]; practitioner_combo.DisplayMember = "Name"; practitioner_combo.SelectedIndex = 0; } else { all_practitioner_radio.Enabled = false; practitioner_radio.Enabled = false; practitioner_combo.Enabled = false; } } else { MessageBox.Show("There is no practitioners/lecturers in the system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } All_lectures_radio.Checked = true; }