Esempio n. 1
0
        /// <summary>
        /// We handle the RoutedCommand CanExecuteEvent which is triggered by the DataGrid
        /// Interested in the Delete command so that we can ask for permission to delete
        /// the Department
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCanExecuteRoutedEventHandler(object sender, CanExecuteRoutedEventArgs e)
        {
            RoutedCommand routedCommand = (e.Command as RoutedCommand);

            if (routedCommand != null)
            {
                if (routedCommand.Name == "Delete")
                {
                    if (IsInEditMode)
                    {
                        return;
                    }

                    CloseErrorDetail();

                    CACCCheckInDb.Department department = _departmentsView.CurrentItem as CACCCheckInDb.Department;
                    string deleteMessage = String.Format("You have selected the [{0}] department for deletion? Click Yes to delete or No to cancel.",
                                                         department.Name);
                    if (MessageBoxResult.No == MessageBox.Show(deleteMessage, "Delete Department", MessageBoxButton.YesNo,
                                                               MessageBoxImage.Question, MessageBoxResult.No))
                    {
                        e.CanExecute = false;
                        e.Handled    = true;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void classToComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)departmentToComboBox.SelectedItem;
            if (null == selectedDepartment)
            {
                return;
            }
            CACCCheckInDb.Class selectedClass = (CACCCheckInDb.Class)classToComboBox.SelectedItem;
            if (null == selectedClass)
            {
                ClassToList.ItemsSource = null;
                return;
            }
            _presenter.GetDataForClassList(selectedDepartment.Name, selectedClass.Name, false);

            if (null != _classFromComboBoxView && null != _classFromComboBoxView.CurrentItem)
            {
                if (((CACCCheckInDb.Class)_classFromComboBoxView.CurrentItem).Id == selectedClass.Id)
                {
                    ChangeStateOfMovementButtons(false);
                }
                else
                {
                    ChangeStateOfMovementButtons(true);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handles click event of button to move selected unassigned classes into assigned group
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MoveSelectedLeftButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CloseErrorDetail();

                CACCCheckInDb.ClassBindingList selectedClasses =
                    new CACCCheckInDb.ClassBindingList(
                        UnassignedClassListBox.SelectedItems.Cast <CACCCheckInDb.Class>());

                foreach (CACCCheckInDb.Class aClass in selectedClasses)
                {
                    UnassignedClassesDataContext.Remove(aClass);

                    CACCCheckInDb.Department department = DepartmentClassesGroupBox.DataContext as
                                                          CACCCheckInDb.Department;
                    aClass.DeptId = department.Id;
                    _presenter.UpdateClass(aClass);

                    DepartmentClassesDataContext.Add(aClass);
                }

                _unassignedClassesView.Refresh();
                _departmentClassesView.Refresh();
            }
            catch (Exception ex)
            {
                DisplayExceptionDetail(ex);
            }
        }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void departmentToComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)departmentToComboBox.SelectedItem;
     if (null == selectedDepartment)
     {
         return;
     }
     _presenter.GetDataForClassCombo(selectedDepartment.Id, false);
 }
 /// <summary>
 /// Handles when user changes department selection. Will retreive correct classes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DepartmentsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)DepartmentsComboBox.SelectedItem;
     if (null == selectedDepartment)
     {
         return;
     }
     _presenter.GetDepartmentClasses(selectedDepartment.Id);
 }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="department"></param>
        public void UpdateDepartment(CACCCheckInDb.Department department)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.UpdateDepartment(department);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="department"></param>
        public void AddDepartment(CACCCheckInDb.Department department)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.InsertDepartment(department);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _teacherListView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            try
            {
                CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)departmentComboBox.SelectedItem;
                CACCCheckInDb.Class      selectedClass      = (CACCCheckInDb.Class)classComboBox.SelectedItem;

                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    // Teachers have been added to the Teacher list for selected class.
                    // We will add the teacher to the class.
                    foreach (CACCCheckInDb.PeopleWithDepartmentAndClassView person in e.NewItems)
                    {
                        logger.DebugFormat("Adding teacher [{0} {1}] to class [{2}]",
                                           person.FirstName, person.LastName, selectedClass.Name);

                        person.ClassId        = selectedClass.Id;
                        person.ClassName      = selectedClass.Name;
                        person.ClassRole      = ClassRoles.Teacher;
                        person.DepartmentId   = selectedDepartment.Id;
                        person.DepartmentName = selectedDepartment.Name;

                        _presenter.AddPersonAsTeacherToClass(person, selectedClass);
                    }
                    break;

                case NotifyCollectionChangedAction.Move:
                    break;

                case NotifyCollectionChangedAction.Remove:
                    // Teachers have been removed from the Teacher list for selected class.
                    // We will delete the teacher from the class.
                    foreach (CACCCheckInDb.PeopleWithDepartmentAndClassView person in e.OldItems)
                    {
                        logger.DebugFormat("Removing teacher [{0} {1}] from class [{2}]",
                                           person.FirstName, person.LastName, selectedClass.Name);

                        _presenter.DeletePersonAsTeacherFromClass(person, selectedClass);
                    }
                    break;

                case NotifyCollectionChangedAction.Replace:
                    break;

                case NotifyCollectionChangedAction.Reset:
                    break;
                }
            }
            catch (Exception ex)
            {
                DisplayExceptionDetail(ex);
            }
        }
        /// <summary>
        /// When user clicks the button to print the teacher labels for a department,
        /// this will handle the event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintTeacherLabelsForDepartmentButton_Click(object sender, RoutedEventArgs e)
        {
            CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)departmentComboBox.SelectedItem;
            if (null == selectedDepartment)
            {
                return;
            }

            ShowProcessing(true);

            _presenter.PrintTeacherLabelsForDepartment(selectedDepartment.Name);
        }
        /// <summary>
        /// Inserts a new department into database
        /// </summary>
        /// <param name="department"></param>
        /// <returns></returns>
        public CACCCheckInDb.Department InsertDepartment(CACCCheckInDb.Department department)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            db.Log = logwriter;

            logger.DebugFormat("Inserting Department: [{0}]", department.Name);
            db.Departments.InsertOnSubmit(department);

            db.SubmitChanges();

            return(db.Departments.Where(dpt =>
                                        dpt.Id.Equals(department.Id)).Single <CACCCheckInDb.Department>());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void getReportButton_Click(object sender, RoutedEventArgs e)
        {
            SaveReportButton.IsEnabled  = false;
            PrintReportButton.IsEnabled = false;

            CACCCheckInDb.Department selectedDepartment =
                (CACCCheckInDb.Department)DepartmentsComboBox.SelectedItem;

            CACCCheckInDb.Class selectedClass =
                (CACCCheckInDb.Class)ClassComboBox.SelectedItem;

            _presenter.GetClassAttendanceInDateRange(selectedDepartment.Id, selectedClass.Id,
                                                     AttendanceStartDate.SelectedDate, AttendanceEndDate.SelectedDate);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="departmentId"></param>
        private void ChangeDepartmentComboTo(Guid departmentId)
        {
            CACCCheckInDb.Department targetDept = ((List <CACCCheckInDb.Department>)
                                                   _departmentComboBoxView.SourceCollection).Find(d => d.Id.Equals(departmentId));

            if (null == targetDept)
            {
                _departmentComboBoxView.MoveCurrentToFirst();
            }
            else
            {
                _departmentComboBoxView.MoveCurrentTo(targetDept);
            }
        }
Esempio n. 13
0
        public CACCCheckInDb.Department InsertDepartment(CACCCheckInDb.Department department)
        {
            Stopwatch sw = new Stopwatch();

            try
            {
                sw.Start();
                return(Channel.InsertDepartment(department));
            }
            finally
            {
                sw.Stop();
                logger.DebugFormat("Call to CACCCheckInService.InsertDepartment took [{0}] ms",
                                   sw.ElapsedMilliseconds);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void classComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)departmentComboBox.SelectedItem;
            if (null == selectedDepartment)
            {
                return;
            }
            CACCCheckInDb.Class selectedClass = (CACCCheckInDb.Class)classComboBox.SelectedItem;
            if (null == selectedClass)
            {
                TeacherList.ItemsSource = null;
                return;
            }

            _presenter.GetDataForTeacherList(selectedDepartment.Name, selectedClass.Name);
        }
Esempio n. 15
0
        public void DeleteDepartment(CACCCheckInDb.Department department)
        {
            Stopwatch sw = new Stopwatch();

            try
            {
                sw.Start();
                Channel.DeleteDepartment(department);
            }
            finally
            {
                sw.Stop();
                logger.DebugFormat("Call to CACCCheckInService.DeleteDepartment took [{0}] ms",
                                   sw.ElapsedMilliseconds);
            }
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _classToListView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            CACCCheckInDb.Department selectedToDepartment = (CACCCheckInDb.Department)departmentToComboBox.SelectedItem;
            CACCCheckInDb.Class      selectedToClass      = (CACCCheckInDb.Class)classToComboBox.SelectedItem;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                // New members have been added to this class. We will update the class, department
                // details for this person and then update the person in the database.
                // This will effectively remove the person from the previous class.
                foreach (CACCCheckInDb.PeopleWithDepartmentAndClassView person in e.NewItems)
                {
                    logger.DebugFormat("Adding [{0} {1}] to class [{2}]",
                                       person.FirstName, person.LastName, selectedToClass.Name);

                    _presenter.UpdatePersonClassMembership(person, selectedToClass);

                    person.DepartmentId   = selectedToDepartment.Id;
                    person.DepartmentName = selectedToDepartment.Name;
                    person.ClassId        = selectedToClass.Id;
                    person.ClassName      = selectedToClass.Name;
                }
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (CACCCheckInDb.PeopleWithDepartmentAndClassView person in e.OldItems)
                {
                    logger.DebugFormat("Removing [{0} {1}] from class [{2}]",
                                       person.FirstName, person.LastName, selectedToClass.Name);
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                break;

            case NotifyCollectionChangedAction.Reset:
                break;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Whenever a Department in the collection has had its EndEdit
        /// </summary>
        /// <param name="sender"></param>
        private void DepartmentsItemEndEdit(IEditableObject sender)
        {
            try
            {
                // Get the Department that has been edited. This could be a new
                // class or an edit to existing Department.
                CACCCheckInDb.Department updatedDepartment = sender as CACCCheckInDb.Department;

                // If the RowTimestamp is null, this must be brand new Department
                // that hasn't been added to the database yet. If not, this
                // must be an update to existing Department
                if (updatedDepartment.RowTimestamp == null)
                {
                    logger.DebugFormat("Adding department [{0}]", updatedDepartment.Name);

                    AddDepartment(updatedDepartment);

                    logger.DebugFormat("Department [{0}] was added.", updatedDepartment.Name);
                }
                else
                {
                    logger.Debug("Department is being updated.");

                    UpdateDepartment(updatedDepartment);

                    logger.DebugFormat("Department [{0}] was updated.", updatedDepartment.Name);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        /// <summary>
        /// Updates a department in the database
        /// </summary>
        /// <param name="updatedDepartment"></param>
        /// <returns></returns>
        public CACCCheckInDb.Department UpdateDepartment(CACCCheckInDb.Department updatedDepartment)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            db.Log = logwriter;

            logger.DebugFormat("Querying for Department: [{0}]", updatedDepartment.Name);
            CACCCheckInDb.Department currentDepartment = (from dpt in db.Departments
                                                          where dpt.Id == updatedDepartment.Id
                                                          select dpt).Single <CACCCheckInDb.Department>();

            logger.DebugFormat("Updating Department: [{0}][{1}]",
                               updatedDepartment.Name, updatedDepartment.Description);
            currentDepartment.Name        = updatedDepartment.Name;
            currentDepartment.Description = updatedDepartment.Description;

            db.SubmitChanges();

            return((from dpt in db.Departments
                    where dpt.Id.Equals(updatedDepartment.Id)
                    select dpt).Single <CACCCheckInDb.Department>());
        }
Esempio n. 19
0
        private void GroupBox_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue == null)
            {
                DepartmentClassListBox.ItemsSource = null;
                return;
            }

            CACCCheckInDb.Department department = e.NewValue as
                                                  CACCCheckInDb.Department;

            if (null != department)
            {
                DepartmentClassesHeader.Text = String.Format("Department [{0}] Classes", department.Name);
                _presenter.GetDepartmentClasses(department.Id);
            }
            else
            {
                DepartmentClassesHeader.Text       = String.Format("Department Classes");
                DepartmentClassListBox.ItemsSource = null;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Retrieves people in selected department and class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClassesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ShowProcessing(true);

            CACCCheckInDb.Department selectedDepartment = (CACCCheckInDb.Department)DepartmentsComboBox.SelectedItem;
            if (null == selectedDepartment)
            {
                return;
            }
            CACCCheckInDb.Class selectedClass = (CACCCheckInDb.Class)ClassesComboBox.SelectedItem;
            if (null == selectedClass)
            {
                PeopleDataGrid.ItemsSource = null;
                return;
            }
            else
            {
                CurrentClass = selectedClass;
            }

            logger.Debug("Getting list of people for department and class.");
            _presenter.GetPeopleByDeptIdAndClassId(selectedDepartment.Id, selectedClass.Id);
        }
        /// <summary>
        /// Deletes the specified department from database
        /// </summary>
        /// <param name="department"></param>
        public void DeleteDepartment(CACCCheckInDb.Department department)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            db.Log = logwriter;

            try
            {
                logger.DebugFormat("Attaching Department: [{0}] to DataContext", department.Name);
                db.Departments.Attach(department);
                logger.DebugFormat("Deleting Department: [{0}]", department.Name);
                db.Departments.DeleteOnSubmit(department);

                db.SubmitChanges();
            }
            catch (ChangeConflictException ex)
            {
                logger.Error("ChangeConflictException:", ex);
                foreach (ObjectChangeConflict occ in db.ChangeConflicts)
                {
                    occ.Resolve(RefreshMode.OverwriteCurrentValues);
                }
            }
        }