public void GetTable(Subject subject)
        {
            var connector = new DBConnector();
            var sourceTable = connector.GetTable(Settings.conn_string);
            var studentsList = new List<Student>();
            //Формирование древовидного списка
            foreach (DataRow row in sourceTable.Rows)
            {
                DateTime value;
                var result = DateTime.TryParse(row.ItemArray[5].ToString(), out value);
                var newSurvey = new Survey
                                    {
                                        Time = Convert.ToDateTime(row.ItemArray[5].ToString()),
                                        PQRST = Convert.ToInt32(row.ItemArray[8].ToString()),
                                        BRS = Convert.ToInt32(row.ItemArray[9].ToString()),
                                        AD = Convert.ToInt32(row.ItemArray[10].ToString()),
                                        VAD = Convert.ToInt32(row.ItemArray[11].ToString()),
                                        Psychomotor = Convert.ToInt32(row.ItemArray[13].ToString()),
                                        breath = Convert.ToInt32(row.ItemArray[15].ToString())
                                    };

                var newStudent = new Student
                                     (
                                         row.ItemArray[0].ToString(),
                                         row.ItemArray[2].ToString(),
                                         Convert.ToDateTime(row.ItemArray[1].ToString())
                                     );

                if (!studentsList.Contains(newStudent))
                {
                    newStudent.Surveys.Add(newSurvey);
                    var kodorg = new Subject {Kodorg = row.ItemArray[0].ToString()};
                    newStudent.StudentSubjects.Add(kodorg);
                    studentsList.Add(newStudent);
                }
                else
                {
                    var index = studentsList.FindIndex(newStudent.Equals);
                    var kodorg = new Subject { Kodorg = row.ItemArray[0].ToString() };
                    studentsList[index].StudentSubjects.Add(kodorg);
                    studentsList[index].Surveys.Add(newSurvey);
                }
            }
            //Формирование списка по запросу
            var finalStudentList = new List<Student>();
            foreach (var student in studentsList)
            {
                if (student.StudentSubjects.Contains(subject))
                {
                    finalStudentList.Add(student);
                }
            }
            //Формирование таблицы

            var i = 0;
            i++;
        }
示例#2
0
 private void ConnectButton_Click(object sender, EventArgs e)
 {
     var dbConnect = new DBConnectForm();
     if(dbConnect.ShowDialog() == DialogResult.OK)
     {
         Dyn_Stat.Enabled = true;
         var connector = new DBConnector();
         Settings.conn_string = dbConnect.GetFileName();
         connector.TestConnection(Settings.conn_string);
     }
     else
     {
         MessageBox.Show(Resources.MainForm_mdbNotSet,Resources.MainForm_Attention);
     }
 }