Teacher.cs :  » Business-Application » Timetabler » OpenCTT » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » Timetabler 
Timetabler » OpenCTT » Teacher.cs
#region Open Course Timetabler - An application for school and university course timetabling
//
// Author:
//   Ivan urak (mailto:Ivan.Curak@fesb.hr)
//
// Copyright (c) 2007 Ivan urak, Split, Croatia
//
// http://www.openctt.org
//
//This file is part of Open Course Timetabler.
//
//Open Course Timetabler is free software;
//you can redistribute it and/or modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2 of the License,
//or (at your option) any later version.
//
//Open Course Timetabler is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
//or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//You should have received a copy of the GNU General Public License along with
//Open Course Timetabler; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
//Fifth Floor, Boston, MA  02110-1301  USA

#endregion

using System;
using System.Collections;
using System.Windows.Forms;


namespace OpenCTT{
  /// <summary>
  /// Summary description for Teacher.
  /// </summary>
  public class Teacher: System.Windows.Forms.TreeNode
  {
    private string _name;
    private string _lastName;
    private string _title;
    private string _eduRank;  
    private string _extID;
    private bool[,] _allowedTimeSlots;
    private ArrayList _allowedRoomsList;  

    private int _tempID;
    private ArrayList _tempAllowedRoomsList=null;

        private int _scMaxDaysPerWeek=-1;
        private int _scMaxHoursDaily = -1;
        private int _scMaxHoursContinously = -1;
        

    public Teacher(string name, string lastName, string title, string eduRank, string extID)
    {
      _name=name;
      _lastName=lastName;
      _title=title;
      _eduRank=eduRank;
      _extID=extID;
      _allowedRoomsList=null;

      _allowedTimeSlots = new bool[AppForm.CURR_OCTT_DOC.IncludedTerms.Count,AppForm.CURR_OCTT_DOC.getNumberOfDays()];
      for(int j=0;j<AppForm.CURR_OCTT_DOC.IncludedTerms.Count;j++)
      {
        for(int k=0;k<AppForm.CURR_OCTT_DOC.getNumberOfDays();k++)
        {
          _allowedTimeSlots[j,k]=true;
        }
      }  

      setTreeText();
      this.ImageIndex=6;
      this.SelectedImageIndex=6;

    }

    public string ExtID
    {
      get
      {
        return _extID;
      }
      set
      {
        _extID=value;
      }

    }

    private void setTreeText() 
    {
      string myText=_lastName+" "+_name;
      if(_title!=null && _title!="") myText+=", "+_title;
      if(_eduRank!=null && _eduRank!="") myText+=", "+_eduRank;
      this.Text=myText;
    }

    public void setName(string name) 
    {
      _name=name;
      setTreeText();
    }

    public void setLastName(string lastName) 
    {
      _lastName=lastName;
      setTreeText();
    }

    public void setTitle(string title) 
    {
      _title=title;
      setTreeText();
    }

    public void setEduRank(string eduRank) 
    {
      _eduRank=eduRank;
      setTreeText();
    }

    public string getName() 
    {
      return _name;
    }

    public string getLastName() 
    {
      return _lastName;
    }

    public string getTitle() 
    {
      return _title;
    }

    public string getEduRank() 
    {
      return _eduRank;
    }

    public bool [,] getAllowedTimeSlots() 
    {
      return _allowedTimeSlots;
    }

    public void setAllowedTimeSlots(bool [,] newAllowedTimeSlots)
    {
      _allowedTimeSlots=newAllowedTimeSlots;
    }

    public ArrayList getAllowedRoomsList() 
    {
      return _allowedRoomsList;
    }

    public void setAllowedRoomsList(ArrayList al)
    {
      _allowedRoomsList=al;
    }

    public string getTreeText()
    {
      return this.Text;
    }

    public string getReportTitle()
    {      
      string title= _title+" "+(_name+" "+_lastName).ToUpper();      
      
      if(_eduRank!=null && _eduRank!="")
      {
                title+=", "+_eduRank;
      }
            return title;
    }

    public ArrayList getUnallocatedLessonsList()
    {
      ArrayList alist= new ArrayList();
      foreach(EduProgramGroup eduProgramGroup in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
      {
        foreach(EduProgram ep in eduProgramGroup.Nodes)
        {
          ArrayList unallocatedLessonsList=ep.getUnallocatedLessonsList();
          foreach(ListViewItem lvi in unallocatedLessonsList)
          {
            Course edu_program_group = (Course)lvi.Tag;
            Teacher teacher = edu_program_group.getTeacher();
            if(teacher==this)
            {
              alist.Add(lvi);
            }
          }
          
        }
      }

      return alist;

    }


    public bool getIsUsedAsTeacherForAnyCourse()
    {
      foreach(EduProgramGroup eduProgramGroup in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
      {
        foreach(EduProgram ep in eduProgramGroup.Nodes)
        {
          foreach(Course edu_program_group in ep.Nodes)
          {
            if(edu_program_group.getTeacher()==this)
            {
              return true;
            }
          }
        }
      }

      return false;
    }

    public static bool getIsTeacherDataOK(Teacher currTeacher,string name, string lastName, string title, string eduRank)
    {
      foreach(Teacher teacher in AppForm.CURR_OCTT_DOC.TeachersRootNode.Nodes)
      {        
        if(teacher!=currTeacher)
        {
          if(teacher.getName().ToUpper()==name.ToUpper() && teacher.getLastName().ToUpper()==lastName.ToUpper()
            && teacher.getTitle().ToUpper()==title.ToUpper() && teacher.getEduRank().ToUpper()==eduRank.ToUpper())
          {
            return false;
          }
        }
        
      }
      
      return true;
    }

    public void getIsThereMoreUnallowedThanAllowedTimeSlots(out int allowed, out int unallowed)
    {  
      int p=0,i=0;

      for(int j=0;j<AppForm.CURR_OCTT_DOC.IncludedTerms.Count;j++)
      {        
        for(int k=0;k<AppForm.CURR_OCTT_DOC.getNumberOfDays();k++)
        {
          if(_allowedTimeSlots[j,k]==true)
          {
                        p++;
          }
          else
          {
            i++;
          }
        }        
      }
      allowed=p;
      unallowed=i;      
    }

    public int getTempID()
    {
      return _tempID;
    }

    public void setTempID(int id)
    {
      _tempID=id;
    }

    public ArrayList getTempAllowedRoomsList()
    {
      return _tempAllowedRoomsList;
    }

    public void setTempAllowedRoomsList(ArrayList tempAllowedRoomsList)
    {
      _tempAllowedRoomsList=tempAllowedRoomsList;
    }

    public static Teacher getTeacherByData(string name,string lastName,string title,string eduRank)
    {
      foreach(Teacher teacher in AppForm.CURR_OCTT_DOC.TeachersRootNode.Nodes)
      {
        if(teacher.getName()==name && teacher.getLastName()==lastName && teacher.getTitle()==title && teacher.getEduRank()==eduRank)
        {
          return teacher;
        }
      }

      return null;
    }


        public int getNumberOfMyLessonsPerWeek()
        {
            ArrayList resList = new ArrayList();

            int numOfHPW = 0;
            int numOfTimePeriods = AppForm.CURR_OCTT_DOC.IncludedTerms.Count;
            int numOfDays = AppForm.CURR_OCTT_DOC.getNumberOfDays();

            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
            {
                foreach (EduProgram ep in epg.Nodes)
                {
                    ArrayList[,] myttT = ep.getTimetable();
                    for (int j = 0; j < numOfTimePeriods; j++)
                    {
                        for (int k = 0; k < numOfDays; k++)
                        {
                            ArrayList lessonsInOneTimeSlot = myttT[j, k];
                            if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                            {
                                foreach (Object[] courseAndRoomPair in lessonsInOneTimeSlot)
                                {
                                    Course course = (Course)courseAndRoomPair[0];
                                    Teacher teacherFromModel = course.getTeacher();
                                    if (teacherFromModel == this)
                                    {                                        
                                        bool addMe = true;

                                        foreach (int[] ots in resList)
                                        {
                                            if(ots[0]==j && ots[1]==k)
                                            {
                                                addMe = false;
                                                break;                                                
                                            }
                                        }

                                        if (addMe)
                                        {
                                            int[] occupTS= new int[2];
                                            occupTS[0]=j;
                                            occupTS[1]=k;
                                            resList.Add(occupTS);
                                        }
                                        
                                        break;
                                    }
                                }

                            }
                        }
                    }
                }
            }

            numOfHPW = resList.Count;
            return numOfHPW;

        }



        public int SCMaxDaysPerWeek
        {
            get
            {
                return _scMaxDaysPerWeek;
            }
            set
            {
                _scMaxDaysPerWeek = value;
            }
        }


        public int SCMaxHoursDaily
        {
            get
            {
                return _scMaxHoursDaily;
            }
            set
            {
                _scMaxHoursDaily = value;
            }
        }

        public int SCMaxHoursContinously
        {
            get
            {
                return _scMaxHoursContinously;
            }
            set
            {
                _scMaxHoursContinously = value;
            }
        }


  
  
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.