private void UpdateAddTeacherComboboxes() { var container = SelectDataFromDataBase.SelectSubjectList(); Subject_comboBox.DisplayMember = "Subject"; Subject_comboBox.ValueMember = "Id"; var dataSource = new List <object>(); foreach (var pair in container) { dataSource.Add(new { Id = pair.Key, Subject = pair.Value }); } Subject_comboBox.DataSource = dataSource; container = SelectDataFromDataBase.SelectCabinetList(); Cabinet_comboBox.DisplayMember = "Cabinet"; Cabinet_comboBox.ValueMember = "Id"; dataSource = new List <object>(); foreach (var pair in container) { dataSource.Add(new { Id = pair.Key, Cabinet = pair.Value }); } Cabinet_comboBox.DataSource = dataSource; Subject_comboBox.SelectedItem = null; Cabinet_comboBox.SelectedItem = null; Subject_comboBox.Text = @"Choose subject"; Cabinet_comboBox.Text = @"Choose cabinet"; }
public string TeacherWithLowerSuccessLevel() { double min = int.MaxValue; int minIndex = 0; var list = CountAverageInColumn(); for (int i = 0; i < list.Count; i++) { if (list[i] < min) { min = list[i]; minIndex = i; } } var subjects = SelectDataFromDataBase.SelectSubjectList(); var linq = from subject in subjects where subject.Value == _progressTableColumns[minIndex + 2] select subject.Key; var teacher = ExecuteQuery(true, "SELECT `name`, `surname` FROM `teachers` WHERE `subjectID`=@subject;", new Dictionary <string, string> { { "@subject", linq.ToList()[0] } }, true); return(teacher[0][0] + " " + teacher[0][1]); }
private void PrintTableWithJoinStatement() { var subjects = SelectDataFromDataBase.SelectSubjectList(); string qColumn = ""; foreach (var pair in subjects) { qColumn += $", `progress`.`{pair.Value}`"; } TablePreview_dataGridView.DataSource = SelectDataFromDataBase.SelectAllFromTable( $"SELECT `progress`.`id`, `pupils`.`name`, `pupils`.`surname`{qColumn} FROM `progress` INNER JOIN `pupils` ON `progress`.`pupilID` = `pupils`.`id`;", FormColumnsList(subjects)); TablePreview_dataGridView.AutoResizeColumns(); TablePreview_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; TablePreview_dataGridView.Refresh(); }
private void SelectTable_comboBox_SelectedIndexChanged(object sender, EventArgs e) { if (SelectTable_comboBox.SelectedIndex > -1) { if (SelectTable_comboBox.SelectedValue.ToString() == "progress") { PrintTableWithJoinStatement(); } else { TablePreview_dataGridView.DataSource = SelectDataFromDataBase.SelectAllFromTable(SelectTable_comboBox.SelectedValue.ToString()); TablePreview_dataGridView.AutoResizeColumns(); TablePreview_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; TablePreview_dataGridView.Refresh(); } } }
private void PrepareSubjectCombobox() { var comboboxSource = SelectDataFromDataBase.SelectSubjectList(); // SelectSubject_comboBox.DisplayMember = "subject"; // SelectSubject_comboBox.ValueMember = "id"; var dataSource = new List <object>(); foreach (var list in comboboxSource) { dataSource.Add(list.Value); //new { id = list.Key, subject = list.Value }); } SelectSubject_comboBox.DataSource = dataSource; SelectSubject_comboBox.SelectedItem = null; SelectSubject_comboBox.Text = @"Select subject"; }
private void RefreshReviewTable() { PupilList_dataGridView.Columns.Clear(); PupilList_dataGridView.DataSource = SelectDataFromDataBase.SelectAllFromTable("pupils"); var btc = new DataGridViewButtonColumn { Name = @"Delete_button", HeaderText = @"Delete pupil", Text = @"Delete", UseColumnTextForButtonValue = true }; PupilList_dataGridView.Columns.Add(btc); PupilList_dataGridView.AutoResizeColumns(); PupilList_dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; PupilList_dataGridView.Refresh(); }
private void UpdateAddPupilCombobox() { var container = SelectDataFromDataBase.SelectGroupList(); Group_comboBox.DisplayMember = "Group"; Group_comboBox.ValueMember = "Id"; var dataSource = new List <object>(); foreach (var pair in container) { dataSource.Add(new { Id = pair.Key, Group = pair.Value }); } Group_comboBox.DataSource = dataSource; Group_comboBox.SelectedItem = null; Group_comboBox.Text = @"Choose group"; }