示例#1
0
 public void RemoveTermin(MyTermin termin)
 {
     try
     {
         TerminsByClassrooms[termin.InClassroom.Id].Remove(termin.Id);
         TerminsBySubjects[termin.ForSubject.Id].Remove(termin.Id);
         TerminsByIds.Remove(termin.Id);
     }
     catch (Exception e)
     {
         Console.WriteLine("Neuspjeli pokusaj brisanja termina {0} u ucionici {1}", termin.HeaderText, termin.InClassroom.Id);
         Console.WriteLine("Razlog: " + e.Message + "\n");
         //throw;
     }
 }
示例#2
0
        private void XMLDeSerializeTermins(string fileName)
        {
            using (Stream file = File.Open(fileName + "_XML_ByID.xml", FileMode.Open))
            {
                var doc = new XmlDocument();
                doc.Load(file);

                var context = new XmlSerializationContext(new Schedule(), doc);

                SubjectHandler.Instance.ResetAllUncheduledTermins();

                foreach (var itemElement in doc.SelectNodes("root/item"))
                {
                    MyTermin item = new MyTermin();
                    item.LoadFrom((XmlElement)itemElement, context);
                    TerminsByIds.Add(item.Id, item);
                    // smanjimo broj NEraspoređenih termina za odgovarajući predmet.
                    SubjectHandler.Instance.ChangeUnscheduledTermins(item.ForSubject.Id);
                }
            }
        }
示例#3
0
        public void AddTermin(MyTermin termin)
        {
            try
            {
                termin.Id = NextId();
                TerminsByIds.Add(termin.Id, termin);
                if (!TerminsByClassrooms.ContainsKey(termin.InClassroom.Id))
                {
                    TerminsByClassrooms.Add(termin.InClassroom.Id, new List <string>()
                    {
                        termin.Id
                    });
                }
                else
                {
                    TerminsByClassrooms[termin.InClassroom.Id].Add(termin.Id);
                }

                if (!TerminsBySubjects.ContainsKey(termin.ForSubject.Id))
                {
                    TerminsBySubjects.Add(termin.ForSubject.Id, new List <string>()
                    {
                        termin.Id
                    });
                }
                else
                {
                    TerminsBySubjects[termin.ForSubject.Id].Add(termin.Id);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Neuspjeli pokusaj dodavanja termina {0}<{1}> u ucionicu {2}",
                                  termin.HeaderText, termin.Id, termin.InClassroom.Id);
                Console.WriteLine("Razlog: " + e.Message + "\n");
                //throw;
            }
        }
示例#4
0
        /// <summary>
        /// Nepotrebno? A Clone override that enables interactive item cloning.
        /// </summary>
        public override object Clone()
        {
            MyTermin clone = new MyTermin();

            // The following code replicates the code used in
            // the Appointment's Clone method
            clone.AllDayEvent     = this.AllDayEvent;
            clone.DescriptionText = this.DescriptionText;
            clone.EndTime         = this.EndTime;
            clone.HeaderText      = this.HeaderText;
            clone.Location        = this.Location;
            clone.Locked          = this.Locked;
            clone.Priority        = this.Priority;
            clone.Reminder        = this.Reminder;
            //clone.SelectedStyle = this.SelectedStyle.Clone() as Style;
            clone.StartTime = this.StartTime;
            //clone.Style = this.Style.Clone() as Style;
            clone.Tag     = this.Tag;
            clone.Task    = this.Task;
            clone.Visible = this.Visible;

            foreach (Resource resource in this.Resources)
            {
                clone.Resources.Add(resource);
            }

            foreach (Contact contact in this.Contacts)
            {
                clone.Contacts.Add(contact);
            }

            // Now copy the custom fields
            clone.InClassroom = this.InClassroom;
            clone.ForSubject  = this.ForSubject;

            return(clone);
        }