Beispiel #1
0
        private void Delete()
        {
            try
            {
                // Store name to call the actual delete method
                string firstName = _displayEmployee.FirstName;
                string lastName  = _displayEmployee.LastName;

                // Update the screen to make it blank
                _displayEmployee = new Employee();
                base.OnPropertyChanged("FirstName");
                base.OnPropertyChanged("LastName");
                base.OnPropertyChanged("PhoneNumber");
                base.OnPropertyChanged("Email");
                base.OnPropertyChanged("GenderType");
                base.OnPropertyChanged("Street");
                base.OnPropertyChanged("City");
                base.OnPropertyChanged("State");
                base.OnPropertyChanged("ZipCode");
                base.OnPropertyChanged("RankType");
                base.OnPropertyChanged("EmployeesJobs");
                AddFamilyPerson   = new Person();
                SelectedJobOption = new Job();

                // Delete the employee, update employees collection, and fire change event
                if (_persMgr.DeletePerson(firstName, lastName))
                {
                    _employees = new CollectionView(_persMgr.GetEmployees());
                    base.OnPropertyChanged("Employees");
                    _familyOptions = new CollectionView(_persMgr.GetPeople());
                    base.OnPropertyChanged("FamilyOptions");
                    _jobOptions = new CollectionView(_jobMgr.GetAllJobs());
                    base.OnPropertyChanged("JobOptions");

                    // Success
                    _labelMessage = String.Format("Deleted {0} {1}", firstName, lastName);
                    base.OnPropertyChanged("LabelMessage");
                }
                else
                {
                    // Error
                    _labelMessage = String.Format("Unable to Delete {0} {1}", firstName, lastName);
                    base.OnPropertyChanged("LabelMessage");
                }
            }
            catch (Exception e)
            {
                _labelMessage = String.Format("Error in Delete Message");
                base.OnPropertyChanged("LabelMessage");
            }
        }
Beispiel #2
0
        public EditEmployeeViewModel(PersonnelManager persMgr, JobManager jobMgr)
        {
            if (persMgr == null)
            {
                throw new ArgumentNullException("personnel manager");
            }
            this._persMgr = persMgr;
            this._jobMgr  = jobMgr;

            // Need three collection views for the main selector, 'family options', & 'job options' listbox
            IList <Employee> e = _persMgr.GetEmployees();
            IList <Person>   p = _persMgr.GetPeople();
            IList <Job>      j = _jobMgr.GetAllJobs();

            this._employees     = new CollectionView(e);
            this._familyOptions = new CollectionView(p);
            this._jobOptions    = new CollectionView(j);

            this._displayEmployee   = new Employee();
            this._addFamilyPerson   = new Person();
            this._selectedJobOption = new Job();
        }