Beispiel #1
0
        public TimeConstraintsPanel(Constraints constraints)
        {
            if (!(constraints is TimeConstraints constrains))
            {
                throw new ArgumentException(nameof(constraints));
            }

            _constraints = constrains;
            InitializeComponent();
        }
Beispiel #2
0
 public TimeGenerator(Column column) : base(column)
 {
     if (column.Constraints is TimeConstraints constrains)
     {
         Constraints = constrains;
     }
     else
     {
         Constraints = new TimeConstraints();
     }
 }
 static XAttribute GetTimeConstrainsAttribute(TimeConstraints constraints)
 {
     return constraints == null ? null : new XAttribute("time_constraints", constraints);
 }
 /*
  * Method: ChooseFileButton_Click (Open file)
  * Paramters: object Sender, EventArgs e
  * Output: N/A
  * Created By: Scott Smoke
  * Date: 3/25/2015
  * Modified By: Scott Smoke
  * 
  * Description: When this button is clicked an open file dialog will open and allow
  *   the user to enter a file name or select a file.
  * Sources: msdn.Microsoft.com
  */
 private void ChooseFileButton_Click(object sender, EventArgs e)
 {
     OpenFileDialog openFile = new OpenFileDialog();
     openFile.Filter = "Text Files |*.txt";
     openFile.Title = "Open Time Constraints Text File";
     openFile.ShowDialog();
     filename = openFile.FileName;
     if (filename != "")
     {
         FileIn fi = new FileIn(filename);
         if (fi.GetErrors().Count == 0)
         {
             tc = fi.GetTimeConstraints();
             //putting constraints on the display
             numDaysTextBox.Text = tc.GetNumberOfDays().ToString();
             firstExamTimeTextBox.Text = tc.GetStartTime().ToString();
             lengthOfExamsTextBox.Text = tc.GetLengthOfExams().ToString();
             lengthBetweenExamsTextBox.Text = tc.GetTimeBetweenExams().ToString();
             lunchPeriodTextBox.Text = tc.GetLunchPeriod().ToString();
         }
         else
         {
             string errors = Errors(fi.GetErrors());
             MessageBox.Show(errors);
         }
     } 
     
 }
        /*
         * Method: UpdateConstraintsButton_Click (update TimeConstraints)
         * Paramters: object Sender, EventArgs e
         * Output: N/A
         * Created By: Scott Smoke
         * Date: 3/25/2015
         * Modified By: Riley Smith
         * Last Modified: 4/2/2015
         * 
         * Description: When this button is clicked the data that is in the form
         * get saved into the TimeConstraints variable.
         * If no data is entered then the TimeConstraints variable
         * data is all set to zero.
         * 
         */
        private void UpdateConstraintsButton_Click(object sender, EventArgs e)
        {
            if ((numDaysTextBox.Text != "") && (firstExamTimeTextBox.Text != "") &&
                (lengthOfExamsTextBox.Text != "") && (lengthBetweenExamsTextBox.Text != ""))
            {

                if (ValidateBoxes())
                {
                    if (lunchPeriodTextBox.Text == "")
                    {
                        lunchPeriodTextBox.Text = "0";
                    }
                    TimeConstraints t = new TimeConstraints(Convert.ToInt32(numDaysTextBox.Text),
                    Convert.ToInt32(firstExamTimeTextBox.Text), Convert.ToInt32(lengthOfExamsTextBox.Text),
                    Convert.ToInt32(lengthBetweenExamsTextBox.Text), Convert.ToInt32(lunchPeriodTextBox.Text));
                    tc = t;

                    errorProvider1.Clear();
                    MessageBox.Show("Time Constraints Updated");
                    this.Close();
                }

                else
                {
                    MessageBox.Show("Error with Time Constraints");
                }
            }

            else
            {
                // If a text box is empty, show a errorProvider.
                if (numDaysTextBox.Text == string.Empty)
                {
                    errorProvider1.SetError(numDaysTextBox, "Cannot Be Empty");
                }

                else
                {
                    errorProvider1.SetError(numDaysTextBox, "");
                }

                if (firstExamTimeTextBox.Text == string.Empty)
                {
                    errorProvider1.SetError(firstExamTimeTextBox, "Cannot Be Empty");
                }

                else
                {
                    errorProvider1.SetError(firstExamTimeTextBox, "");
                }

                if (lengthOfExamsTextBox.Text == string.Empty)
                {
                    errorProvider1.SetError(lengthOfExamsTextBox, "Cannot Be Empty");
                }

                else
                {
                    errorProvider1.SetError(lengthOfExamsTextBox, "");
                }

                if (lengthBetweenExamsTextBox.Text == string.Empty)
                {
                    errorProvider1.SetError(lengthBetweenExamsTextBox, "Cannot Be Empty");
                }

                else
                {
                    errorProvider1.SetError(lengthBetweenExamsTextBox, "");
                }

                // End of errorProviders.

                TimeConstraints t = new TimeConstraints(0, 0, 0, 0, 0);
                tc = t;

            }
        }
Beispiel #6
0
        /*
        * Method: ReadFromCSV
        * Parameters: N/A
        * Output: Saved file in the CSV format
        * Created By: Jeffrey Allen
        * Date: 5/4/2015
        * Modified By: 
        * 
        * Description: Reads the data from an output CSV file
        *  
        */
        public void ReadOutput(string filename)
        {

            if (filename != "")
            {
                System.IO.StreamReader file =
                    new System.IO.StreamReader(filename);

                Globals.totalEnrollemntsFileName = filename;

                string[] splitFileName = filename.Split('.');
                string extention = splitFileName[1];
                string[] semesterAndYear;

                string semesterAndYearLine = file.ReadLine();
                char delimitingFactor = '0';

                if (extention == "csv")
                {
                    delimitingFactor = ',';
                    semesterAndYear = semesterAndYearLine.Split(delimitingFactor);
                    
                }
                else
                {
                    delimitingFactor = ' ';
                    semesterAndYear = semesterAndYearLine.Split(delimitingFactor);
                }

                Globals.semester = semesterAndYear[0];
                Globals.year = semesterAndYear[1];

                // read enrollments file name
                Globals.totalEnrollemntsFileName = file.ReadLine();
                CompressedClassTimes ct = new CompressedClassTimes(Globals.totalEnrollemntsFileName);
                Globals.compressedTimes = ct.GetCompressedClassTimes();

                // read time constraints
                string days = file.ReadLine();
                string starttime = file.ReadLine();
                string lengthofexam = file.ReadLine();
                string btwclass = file.ReadLine();
                string lunchtime = file.ReadLine();

                TimeConstraints readConstraints = new TimeConstraints(Convert.ToInt32(days),
                                                    Convert.ToInt32(starttime), Convert.ToInt32(lengthofexam),
                                                    Convert.ToInt32(btwclass), Convert.ToInt32(lunchtime));

                Globals.timeConstraints = readConstraints;

                // read adminApproved
                string adminApp = file.ReadLine();
                if (adminApp[0] == 'S')
                {
                    Globals.adminApproved = true;
                } 
                else
                {
                    Globals.adminApproved = false;
                }
				Scheduler schedule = new Scheduler(Globals.compressedTimes, Globals.timeConstraints);
				schedule.Schedule();
				Globals.examWeek = schedule.GetExams();

				//string nextLine = file.ReadLine();

				//while (nextLine != "")
				//{
				//	nextLine = file.ReadLine();
				//}

				//// Read and display lines from the file until the end of
				//// the file is reached.
				//while ((nextLine = file.ReadLine()) != null)
				//{
				//	// if header, discard and get next line
				//	if (nextLine[0] == 'D')
				//		nextLine = file.ReadLine();

				//	// if line has single digit, then increment day
				//	if (nextLine[0] == ' ')
				//		continue;
                    

				//	// if line has two exam times, 
				//}

            }
        }
Beispiel #7
0
 /*
  * Name:        getLines
  * Author:      Joshua Ford
  * Created:     3/25/15
  * Modified by: Joshua Ford
  * Parameters:  NONE
  * Output: tc - Returns time constraints.
  * Purpose: Acts as the getter for this class 
  *          (This should also be pretty obvious)
  */
 public TimeConstraints GetTimeConstraints()
 {
     TimeConstraints tc= null;
     if (lines != null)
     {
         tc = new TimeConstraints(Convert.ToInt32(lines[0]),
         Convert.ToInt32(lines[1]), Convert.ToInt32(lines[2]),
         Convert.ToInt32(lines[3]), Convert.ToInt32(lines[4]));        
     }
   
     return tc;
 }