Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!currentTT.IsFinalised())
            {
                currentTT.Finalise();                           //finalises structure, so that we can't change it.
            }
            if (cb_periodStart.Text == "")
            {
                return;
            }
            if (cb_noOfPeriods.Text == "")
            {
                return;
            }
            if ((cb_periodStart.SelectedIndex < 0) || (cb_periodStart.SelectedIndex > 255))
            {
                return;
            }

            byte   periodIndex    = Convert.ToByte(cb_periodStart.SelectedIndex);
            byte   dayIndex       = Convert.ToByte(cb_day.SelectedIndex);
            byte   noOfPeriods    = Convert.ToByte(cb_noOfPeriods.Text);
            string teacherCode    = cb_teacherCode.Text;
            string subjectCode    = cb_subjectCode.Text;
            string roomCode       = cb_room.Text;
            byte   yearIndex      = Convert.ToByte(cb_yearGroup.SelectedIndex);
            byte   formIndex      = Convert.ToByte(cb_class.SelectedIndex);
            byte   homeworkAmount = Convert.ToByte(num_hwkAmount.Value);
            string message        = "";
            string m2             = "";

            if (currentTT.IsClassClash(dayIndex, periodIndex, yearIndex, formIndex, out message))
            {
                m2 += message + Environment.NewLine;
            }
            if (currentTT.IsRoomClash(dayIndex, periodIndex, cb_room.SelectedIndex, out message))
            {
                m2 += message;
            }
            if (currentTT.IsStaffClash(dayIndex, periodIndex, cb_teacherCode.SelectedIndex, out message))
            {
                m2 += message;
            }

            if (m2 != "")
            {
                MessageBox.Show(m2);
                return;
            }

            if (mode == AddLessonMode.Edit)
            {
                currentTT.DeleteLesson(loadedLesson);
            }

            currentTT.AddLesson(dayIndex, periodIndex, noOfPeriods, subjectCode, teacherCode, roomCode, yearIndex, formIndex, homeworkAmount, ck_locked.Checked, ck_invisible.Checked);

            this.Close();
        }
Example #2
0
        //drawing lesson blocks onto the screen.
        private void DrawMainViewLessons(Graphics G, int cellWidth, int cellHeight, int marginLeft, int marginTop)
        {
            if (!currentTT.IsFinalised())
            {
                return;
            }
            //int xCoord =  cellWidth + MarginLeft;
            int yCoord = cellHeight + marginTop;

            for (int dayIndex = 0; dayIndex < currentTT.Week.Count; dayIndex++)
            {
                for (int periodIndex = 0; periodIndex < currentTT.Week[dayIndex].PeriodsInDay.Count; periodIndex++)
                {
                    int xCoord = 2 * cellWidth + marginLeft;
                    yCoord += cellHeight;
                    for (int yearIndex = 0; yearIndex < currentTT.Years.Count; yearIndex++)
                    {
                        for (int formIndex = 0; formIndex < currentTT.Years[yearIndex].Forms.Count; formIndex++)
                        {
                            Lesson obj = currentTT.mainTT[dayIndex][periodIndex][yearIndex][formIndex];
                            if (obj != null)
                            {
                                currentTT.mainTT[dayIndex][periodIndex][yearIndex][formIndex].DrawOnPage(xCoord, yCoord, cellWidth, cellHeight, G, presentLesson, invisibleBrush, lockedBrush);
                            }
                            xCoord += cellWidth;
                        }
                    }
                }
            }
        }
Example #3
0
        private void DrawSchoolView(Graphics G, int cellWidth, int cellHeight, int marginLeft, int marginTop, bool printInvisible)
        {
            int col = 2 * cellWidth;

            foreach (YearGroup year in currentTT.Years)
            {
                G.DrawRectangle(Pens.Black, col + marginLeft, marginTop, cellWidth * year.Forms.Count, cellHeight);
                G.DrawString(year.YearName, new Font("Segoe UI", 12), Brushes.Black, col, marginTop);

                foreach (FormClass fc in year.Forms)
                {
                    G.DrawRectangle(Pens.Black, col + marginLeft, cellHeight + marginTop, cellWidth, cellHeight);
                    G.DrawString(fc.FormName, new Font("Segoe UI", 12), Brushes.Black, col + marginLeft, cellHeight + marginTop);
                    col += cellWidth;
                }
            }

            int row = 2 * cellHeight;

            foreach (Day schoolDay in currentTT.Week)
            {
                G.DrawRectangle(Pens.Black, marginLeft, row + marginTop, cellWidth, cellHeight);
                G.DrawString(schoolDay.DayName, new Font("Segoe UI", 12), Brushes.Black, marginLeft, row + marginTop);
                //G.FillRectangle(Brushes.SkyBlue, schoolDay.dayBounds);
                foreach (Period singlePeriod in schoolDay.PeriodsInDay)
                {
                    G.DrawRectangle(Pens.Black, marginLeft + cellWidth, row + marginTop, cellWidth, cellHeight);
                    G.DrawString(singlePeriod.PeriodDisplay, new Font("Segoe UI", 12), Brushes.Black, marginLeft + cellWidth, row + marginTop);
                    row += cellHeight;
                    // G.FillRectangle(Brushes.Purple,singlePeriod.periodBounds);
                }

                if (!currentTT.IsFinalised())
                {
                    return;
                }
                //int xCoord =  cellWidth + MarginLeft;
                int yCoord = cellHeight + marginTop;
                for (int dayIndex = 0; dayIndex < currentTT.Week.Count; dayIndex++)
                {
                    for (int periodIndex = 0; periodIndex < currentTT.Week[dayIndex].PeriodsInDay.Count; periodIndex++)
                    {
                        int xCoord = 2 * cellWidth + marginLeft;
                        yCoord += cellHeight;
                        for (int yearIndex = 0; yearIndex < currentTT.Years.Count; yearIndex++)
                        {
                            for (int formIndex = 0; formIndex < currentTT.Years[yearIndex].Forms.Count; formIndex++)
                            {
                                Lesson obj = currentTT.mainTT[dayIndex][periodIndex][yearIndex][formIndex];
                                if ((obj != null) && (!obj.invisible | (obj.invisible & printInvisible)))
                                {
                                    G.DrawRectangle(Pens.Black, xCoord, yCoord, cellWidth, cellHeight);
                                    G.DrawString(currentTT.mainTT[dayIndex][periodIndex][yearIndex][formIndex].ToString(), new Font("Segoe UI", 12), Brushes.Black, xCoord, yCoord);
                                }
                                xCoord += cellWidth;
                            }
                        }
                    }
                }
            }
        }