Ejemplo n.º 1
0
 /// <summary>
 /// オブジェクトをコピーする
 /// </summary>
 /// <param name="editData"></param>
 internal void Clone(Alerm editData)
 {
     try
     {
         Name          = editData.Name;
         Message       = editData.Message;
         LabelColor    = editData.LabelColor;
         EdgeColor     = editData.EdgeColor;
         ForeColor     = editData.ForeColor;
         Enable        = editData.Enable;
         ExecPath      = editData.ExecPath;
         ExecType      = editData.ExecType;
         ExecTypeIndex = editData.ExecTypeIndex;
         FontName      = editData.FontName;
         TimeAddUpDown = editData.TimeAddUpDown;
         ScheduleList.Clear();
         foreach (var s in editData.ScheduleList)
         {
             ScheduleList.Add(s);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Конструктор списка событий
 /// </summary>
 /// <param name="input">Список событий</param>
 public Schedule(params Schedule[] input)
 {
     foreach (Schedule s in input)
     {
         ScheduleList.Add(s);
     }
 }
Ejemplo n.º 3
0
        // Commands

        public void CreateNewSchedule()
        {
            var newSchedule             = new Schedule();
            var categorySelectViewModel = new CategorySelectViewModel(newSchedule);

            _windowManager.ShowDialog(categorySelectViewModel);

            ScheduleList.Add(newSchedule);
        }
Ejemplo n.º 4
0
 public override void AddItem(RITE Item)
 {
     ScheduleList.Add(Item);
     if (ScheduleList.Count == 1)
     {
         IsLocation = true;
     }
     else if (ScheduleList.Count > 1)
     {
         IsLocation = false;
     }
 }
Ejemplo n.º 5
0
 public override void AddItem(GraphInfo Item)
 {
     ScheduleList.Add(Item);
 }
Ejemplo n.º 6
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            //declare a schedule object to store the information of the schedule
            Schedule sch = new Schedule();

            //setting the properties of the schedule from the infromation provided in the form
            sch.setID(this.txtScheduleID.Text.ToString());
            //using a section object and a location object to access the instructor id from section and capacity from location for validation
            Section section = (Section)this.cmbSections.SelectedItem;

            sch.SectionID = section.getID();
            Location location = (Location)this.cmbLocations.SelectedItem;

            sch.LocationID = location.getID();
            sch.Day        = cmbDays.SelectedItem.ToString();
            Boolean isValid = true;

            //checks if the duration enters is valid
            foreach (char c in this.txtDuration.Text.ToString())
            {
                //if the character is not between 0 and 9, isValid is set to false.
                if (c < '0' || c > '9')
                {
                    isValid = false;
                }
            }
            //if statment to check if the isValid changed in the loop or not
            if (isValid)
            {
                //assiging the value from the text box to the property
                sch.Duration = this.txtDuration.Text.ToString();
            }
            else
            {
                //if input is not valid a default value of 0 will be entered
                sch.Duration = "0";
                //warning message will show to the user
                MessageBox.Show("Duration entered is invalid.");
            }
            sch.Time = this.txtTime.Text.ToString();
            //The below code checks for double scheduling for instructor, location and capacity of the location
            Boolean chkInstructor = false;
            int     newTime       = Convert.ToInt32(sch.Time);
            int     schDuration   = Convert.ToInt32(sch.Duration);

            //while loop to check if the instructor is busy in schedule start time and through out the duration as well. to prevent overlapping between two schedules
            while (schDuration >= 1 & !chkInstructor)
            {
                //calls the method for every hour of the schedule. i.e. class starts at 3 and lasts for 2 hourse. The loop will check the hourse 3, 4 and 5
                chkInstructor = schedules.Exist("Section", "Schedule.SectionID", "Section.SectionID", "Day", "'" + sch.Day.ToString() + "'",
                                                "Time", newTime.ToString(), "Section.instructorID", section.InstructorID.ToString());
                newTime++;
                schDuration--;
            }
            //if instructor has no double scheduling execute code
            if (!chkInstructor)
            {
                //check if location is busy at specific day and time to prevent double scheduling
                Boolean chkLocation = schedules.Exist("Day", sch.Day.ToString(), "Time",
                                                      sch.Time.ToString(), "LocationID", sch.LocationID.ToString());
                //if locaion has no double scheduling, execute code inside
                if (!chkLocation)
                {
                    //checks for the capacity of the section and the location and if it will fit
                    if (Convert.ToInt32(section.Capacity) <= Convert.ToInt32(location.Capacity))
                    {
                        //if all condition were satified, add the schedule object to the databse
                        schedules.Add(sch);
                        //clear the tet boxes after a seccuessful insertion in the database
                        clear();
                        nextID();
                        //this if statment checks if the execution was successful or not and show a message acoordingly
                        if (sch.getValid() == true)
                        {
                            MessageBox.Show("Schedule have been added successfully.");
                        }
                        else
                        {
                            MessageBox.Show("An error has occured. Record was not added.");
                        }
                        //the below else statment will show an error message if the conditions were not satified
                    }
                    else
                    {
                        MessageBox.Show("Section's capacity is larger than the location's capacity.");
                    }
                }
                else
                {
                    MessageBox.Show("Location is busy at this time.");
                }
            }
            else
            {
                MessageBox.Show("Instructor is busy at this time.");
            }
        }