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 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";
        }
예제 #3
0
        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 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";
        }