Example #1
0
        public WeekViewModel(SemesterLogic Semesters, bool IsOldWeek, int WeekNumber)
        {
            if (Semesters == null)
            {
                throw new ArgumentNullException("Semesters");
            }

            _semesters = Semesters;
            int OldOrNew = 0;

            if (!IsOldWeek)
            {
                OldOrNew = 1;
            }

            this.Days = new ObservableCollection <Day>(_semesters.Semesters[OldOrNew].Week(WeekNumber).Days);

            if (IsOldWeek)
            {
                this.Color = Settings.Default.OldSemesterColor;
            }
            else
            {
                this.Color = Settings.Default.NewSemesterColor;
            }
        }
Example #2
0
        public SemestersViewModel(SemesterLogic Semesters)
        {
            _closeCalendarCommand = new RelayCommand(CloseCalendar);

            if (Semesters == null)
            {
                throw new ArgumentNullException("Semesters");
            }


            _semesters = Semesters;

            List <ViewModelBase> weeks = new List <ViewModelBase>();

            int i = 0;

            foreach (Week _week in _semesters.Semesters[0].Weeks)
            {
                weeks.Add(new WeekViewModel(_semesters, true, i));
                weeks.Add(new WeekViewModel(_semesters, false, i));
                i++;
            }

            this.Weeks = new ObservableCollection <ViewModelBase>(weeks);
        }
 public MainWindowViewModel()
 {
     _semesters        = new SemesterLogic();
     _mainView         = new MainViewViewModel(_semesters);
     _currentViewModel = new ObservableCollection <ViewModelBase>();
     _currentViewModel.Add(_mainView);
     _currentViewModel[0].PropertyChanged += MainWindowViewModel_PropertyChanged;
     _settingsCommand = new RelayCommand(SettingsViewShow);
 }
Example #4
0
 protected override void OnLoad(EventArgs e)
 {
     this.SemesterField.DataSource = SemesterLogic.GetAll();
     this.SemesterField.DataBind();
     this.TeacherField.DataSource = TeacherLogic.GetAll();
     this.TeacherField.DataBind();
     this.CourseStatusField.DataSource = Enum.GetValues(typeof(DataAccess.CourseStatus));
     this.CourseStatusField.DataBind();
 }
 public MainViewViewModel(SemesterLogic Semesters)
 {
     _semesters           = Semesters;
     _numberOfWeeks       = (int)Settings.Default.NumberOfWeeks;
     _oldStart            = Settings.Default.OldStart;
     _newStart            = Settings.Default.NewStart;
     _updateCommand       = new RelayCommand(Update, new Predicate <object>(i => (OldDate != null) && (NewDate != null)));
     _nextCommand         = new RelayCommand(Next, new Predicate <object>(i => Settings.Default.CurrentWeek < _numberOfWeeks - 1));
     _previousCommand     = new RelayCommand(Previous, new Predicate <object>(i => Settings.Default.CurrentWeek > 0));
     _fullSemesterCommand = new RelayCommand(FullCalendar, new Predicate <object>(i => (_semesters.Semesters.Count > 1)));
     _breaksChecked       = Settings.Default.IncludeBreaks;
 }
        protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            if ("Edit".Equals(e.CommandName))
            {
                int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex];

                this.OnEdit(SemesterLogic.GetByID(this.DataContext, primaryKey));
            }
            else if ("Delete".Equals(e.CommandName))
            {
                int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex];

                this.OnDelete(SemesterLogic.GetByID(this.DataContext, primaryKey));
            }
        }
Example #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string idString = this.Request.QueryString["ID"];
            int    id;

            if (int.TryParse(idString, out id))
            {
                this.Semester = SemesterLogic.GetByID(this.DataContext, id);

                if (!this.IsPostBack)
                {
                    this.EditControl.DataBind(this.Semester);
                }
            }
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (this.ObjectID.HasValue)
            {
                Semester obj = SemesterLogic.GetByID(this.DataContext, this.ObjectID.Value);

                obj.Begin = this.BeginField.SelectedDate;
                obj.End   = this.EndField.SelectedDate;
                obj.Name  = this.NameField.Text;

                this.DataContext.AcceptAllChanges();
                OnSaved(obj);
            }
            else
            {
                Semester obj = SemesterLogic.CreateSemester(this.DataContext, this.BeginField.SelectedDate, this.EndField.SelectedDate, this.NameField.Text);

                this.DataContext.AcceptAllChanges();
                OnSaved(obj);
            }
        }
Example #9
0
 protected void ListControl_Delete(object sender, Semester obj)
 {
     SemesterLogic.DeleteSemester(this.DataContext, obj.ID);
     this.DataContext.AcceptAllChanges();
     BindList();
 }
Example #10
0
 private void BindList()
 {
     ListControl.DataBind(SemesterLogic.GetAll().ToList());
 }
Example #11
0
 /// <summary>Maps to the UX_Semester_2 foreign key in the database.</summary>
 public SO.Semester GetSemesterByName(string name)
 {
     return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByName(name)));
 }
Example #12
0
 /// <summary>Gets a list of all of the Semesters in the database.</summary>
 /// <returns>An IEnumerable of Semesters.</returns>
 public IEnumerable <SO.Semester> GetSemesters(string page)
 {
     return(GetPage(SemesterLogic.GetAll(), page).Select(o => SO.Semester.FromDataAccessObject(o)));
 }
Example #13
0
 /// <summary>Maps to the UX_Semester_1 foreign key in the database.</summary>
 public SO.Semester GetSemesterByBeginAndEnd(DateTime begin, DateTime end)
 {
     return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByBeginAndEnd(begin, end)));
 }
Example #14
0
 /// <summary>Gets the Semester with the specified primary key.</summary>
 /// <param name="id">The primary key of the Semester to return.</param>
 /// <returns>The matching Semester, if one exists, or null.</returns>
 public SO.Semester GetSemesterByID(int id)
 {
     return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByID(id)));
 }
Example #15
0
 /// <summary>Gets a list of all of the Semesters in the database.</summary>
 /// <returns>An IEnumerable of Semesters.</returns>
 public IEnumerable <SO.Semester> GetSemesters(int page)
 {
     return(ServiceUtil.GetPage(SemesterLogic.GetAll(), page).Select(o => SO.Semester.FromDataAccessObject(o)));
 }
Example #16
0
 /// <summary>Gets the Semester with the specified primary key.</summary>
 /// <param name="id">The primary key of the Semester to return.</param>
 /// <returns>The matching Semester, if one exists, or null.</returns>
 public SO.Semester GetSemesterByID(string id)
 {
     return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByID(ParseInt("id", id))));
 }
Example #17
0
 /// <summary>Maps to the UX_Semester_1 foreign key in the database.</summary>
 public SO.Semester GetSemesterByBeginAndEnd(string begin, string end)
 {
     return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByBeginAndEnd(ParseDateTime("Begin", begin), ParseDateTime("End", end))));
 }