Exemple #1
0
 public Subject(int aID, string aName, SubjectGroup aGroup)
 {
     ID = aID;
     Name = aName;
     ShortName = Name.Substring(0, 3);
     Group = aGroup;
 }
Exemple #2
0
        private void ImportSubjects(ref OleDbConnection connection)
        {
            string SubjectGroupsSelect = "SELECT * FROM [Code SubjectGroup]";
            OleDbCommand ClassesQuery = new OleDbCommand(SubjectGroupsSelect, connection);

            Dictionary<int, SubjectGroup> d = new Dictionary<int, SubjectGroup>() { };
            using (OleDbDataReader GroupsReader = ClassesQuery.ExecuteReader())
            {
                while (GroupsReader.Read())
                {
                    int id = int.Parse(GroupsReader["SubjGroup ID"].ToString());
                    int norma;
                    if (int.TryParse(GroupsReader["NormaBasic"].ToString(), out norma) == false)
                    {
                        norma = 0;
                    }
                    SubjectGroup group = new SubjectGroup(
                        id,
                        GroupsReader["SubjGroup Name"].ToString(),
                        norma);
                    d.Add(id, group);
                }
            }
            string SubjectsSelect = "SELECT * FROM [Code Subject] WHERE [Subject Name] IS NOT NULL";
            OleDbCommand SubjectsQuery = new OleDbCommand(SubjectsSelect, connection);
            using (OleDbDataReader SubjectsReader = SubjectsQuery.ExecuteReader())
            {
                while (SubjectsReader.Read())
                {
                    int id = int.Parse(SubjectsReader["Subject ID"].ToString());

                    int group_id = int.Parse(SubjectsReader["SubjectGroup"].ToString());
                    string name = SubjectsReader["Subject Name"].ToString();
                    SubjectGroup gr = d[group_id];
                    Subject s = new Subject(id, name, gr);
                    this.mSubjects.Add(s);
                }
            }
        }