Esempio n. 1
0
        public ModuleEditFrm(Module module)
        {
            InitializeComponent();
            InitializeCmBoxes();
            _module = module;
            _existing = true;

            Initialize();
        }
Esempio n. 2
0
        // List of all Events of one type (of one Module)
        public List<Event> getAllEvents(Module module, string type)
        {
            List<Event> list = new List<Event>();

            foreach (Event sgevent in module.Events)
            {
                if (sgevent.Type == type)
                {
                    list.Add(sgevent);
                }
            }
            return list;
        }
Esempio n. 3
0
        private void txBoxID_Change(object sender, EventArgs e)
        {
            Module module = _parser.getModule(txBoxID.Text);

            if (module != null)
            {
                _module = module;
                _existing = true;
                Initialize();
            }
            else
            {
                _module = new Module();
                _module.Uni = "001_UHH";        // dynamic
                _module.Region = "Informatik";  // ---"---
                _module.Semester = "Winter";    // ---"---
                _existing = false;
                Initialize();
            }
        }
Esempio n. 4
0
        // Writes the data of a Module/Event to the XML //
        public void writeModule(Module module)
        {
            foreach (XmlDocument doc in _libraries)
            {
                XmlElement uni = doc.GetElementById(module.Uni);

                if (uni != null)
                {
                    foreach (XmlNode region in uni.GetElementsByTagName("region"))
                    {
                        if (region.Attributes["id"].Value == module.Region)
                        {
                            // <module [...]>
                            XmlNode nodemodule = doc.CreateElement("module");

                            // <module id="_id_" [...]>
                            XmlAttribute moduleid = doc.CreateAttribute("id");
                            moduleid.Value = module.ID;
                            nodemodule.Attributes.Append(moduleid);

                            // <module name="_name_" [...]>
                            XmlAttribute modulename = doc.CreateAttribute("name");
                            modulename.InnerText = module.Name;
                            nodemodule.Attributes.Append(modulename);

                            // <module short="_short_" [...]>
                            XmlAttribute moduleshort = doc.CreateAttribute("short");
                            moduleshort.InnerText = module.Short;
                            nodemodule.Attributes.Append(moduleshort);

                            {
                                // <semester>_semester_</semester>
                                XmlNode subnodesem = doc.CreateElement("semester");
                                subnodesem.InnerText = module.Semester;
                                nodemodule.AppendChild(subnodesem);

                                // <bools>
                                XmlNode subnodebools = doc.CreateElement("bools");
                                {
                                    // <lectures></lectures>
                                    XmlNode subsubnodelectures = doc.CreateElement("lectures");
                                    subnodebools.AppendChild(subsubnodelectures);

                                    // <exercises></exercises>
                                    XmlNode subsubexercises = doc.CreateElement("exercises");
                                    subnodebools.AppendChild(subsubexercises);

                                    // <tutorials></tutorials>
                                    XmlNode subsubtutorials = doc.CreateElement("tutorials");
                                    subnodebools.AppendChild(subsubtutorials);

                                    // <internships></internships>
                                    XmlNode subsubinternships = doc.CreateElement("internships");
                                    subnodebools.AppendChild(subsubinternships);
                                }
                                // </bools>
                                nodemodule.AppendChild(subnodebools);

                                // <event [...]>[...]</event>
                                // has to be done afterwards, because of recursion.
                            }
                            // </module>
                            region.AppendChild(nodemodule);

                            // <event [...]>[...]</event>
                            if (module.Events != null)
                            {
                                foreach (Event ievent in module.Events)
                                {
                                    writeEvent(ievent);
                                }
                            }

                            saveLibDoc(doc);
                            updateBools();
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public void updateModule(Module module)
        {
            foreach (XmlDocument doc in _libraries)
            {
                XmlElement xmlmodule = doc.GetElementById(module.ID);

                if (xmlmodule != null)
                {
                    xmlmodule.Attributes["name"].Value = module.Name;
                    xmlmodule.Attributes["short"].Value = module.Short;
                    xmlmodule["semester"].InnerText = module.Semester;
                    xmlmodule["bools"]["lectures"].InnerText = module.Lectures.ToString();
                    xmlmodule["bools"]["exercises"].InnerText = module.Exercises.ToString();
                    xmlmodule["bools"]["tutorials"].InnerText = module.Tutorials.ToString();
                    xmlmodule["bools"]["internships"].InnerText = module.Internships.ToString();

                    // events missing

                    saveLibDoc(doc);
                    updateBools();
                }
            }
        }
Esempio n. 6
0
        // Creates a Module/Event with the data out of the XML //
        public Module getModule(string id)
        {
            foreach (XmlDocument doc in _libraries)
            {
                XmlElement modulexml = doc.GetElementById(id);

                if (modulexml != null)
                {
                    Module module = new Module(
                        modulexml.ParentNode.ParentNode.Attributes["id"].Value,             // uni
                        modulexml.ParentNode.Attributes["id"].Value);                       // region
                    module.ID = id;                                                         // id
                    module.Name = modulexml.Attributes["name"].Value;                       // name
                    module.Short = modulexml.Attributes["short"].Value;                      // short
                    module.Semester = modulexml.ChildNodes[0].InnerText;                    // semester

                    XmlNode bools = modulexml["bools"];
                    module.Lectures = Convert.ToInt32(bools["lectures"].InnerText);         // lectures (bool)
                    module.Exercises = Convert.ToInt32(bools["exercises"].InnerText);       // exercises (bool)
                    module.Tutorials = Convert.ToInt32(bools["tutorials"].InnerText);       // tutorials (bool)
                    module.Internships = Convert.ToInt32(bools["internships"].InnerText);   // internships (bool)

                    XmlNodeList events = modulexml.GetElementsByTagName("event");
                    module.Events = new List<Event>();
                    foreach (XmlNode eventxml in events)
                    {
                        module.Events.Add(getEvent(eventxml.Attributes["id"].Value));       // events
                    }

                    return module;
                }
            }
            return null;
        }