Beispiel #1
0
        public virtual DateTime?GetProjectOrEmployeeStartDate(PMLaborCostRate row)
        {
            if (row == null)
            {
                return(null);
            }

            if (!AllParametersEntered(row))
            {
                return(null);
            }

            DateTime?result = null;

            DateTime?employeeDate = null;
            DateTime?projectDate  = null;

            if (row.EmployeeID != null)
            {
                EPEmployeePosition activePosition = PXSelect <EPEmployeePosition, Where <EPEmployeePosition.employeeID, Equal <Required <EPEmployeePosition.employeeID> >,
                                                                                         And <EPEmployeePosition.isActive, Equal <True> > > > .Select(this, row.EmployeeID);

                if (activePosition != null)
                {
                    employeeDate = activePosition.StartDate;
                }
            }

            if (row.ProjectID != null)
            {
                PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(this, row.ProjectID);

                if (project != null)
                {
                    projectDate = project.StartDate;
                }
            }

            if (employeeDate != null && projectDate != null)
            {
                if (employeeDate > projectDate)
                {
                    result = employeeDate;
                }
                else
                {
                    result = projectDate;
                }
            }
            else
            {
                result = employeeDate ?? projectDate;
            }

            return(result);
        }
        protected virtual IEnumerable members()
        {
            Caches[typeof(EPCompanyTreeMember)].AllowInsert = Folders.Current.ParentWGID != null && Folders.Current != null;
            Caches[typeof(EPCompanyTreeMember)].AllowDelete = Folders.Current.ParentWGID != null;
            Caches[typeof(EPCompanyTreeMember)].AllowUpdate = Folders.Current.ParentWGID != null;

            if (Folders.Current != null)
            {
                foreach (var res in
                         PXSelectJoin <EPCompanyTreeMember,
                                       LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <EPCompanyTreeMember.userID> >,
                                                 LeftJoin <EPEmployeePosition, On <EPEmployeePosition.employeeID, Equal <EPEmployee.bAccountID>,
                                                                                   And <EPEmployeePosition.isActive, Equal <True> > >,
                                                           LeftJoin <Users, On <Users.pKID, Equal <EPCompanyTreeMember.userID> > > > >,
                                       Where <EPCompanyTreeMember.workGroupID, Equal <Required <EPCompanyTreeMember.workGroupID> > > > .Select(this, Folders.Current.WorkGroupID))
                {
                    EPCompanyTreeMember _companyTreeMember = res[typeof(EPCompanyTreeMember)] as EPCompanyTreeMember;
                    EPEmployee          _employeer         = res[typeof(EPEmployee)] as EPEmployee;
                    Users _user = res[typeof(Users)] as Users;
                    EPEmployeePosition _ePEmployeeposision = res[typeof(EPEmployeePosition)] as EPEmployeePosition;

                    if (_companyTreeMember.UserID != null)
                    {
                        if (_user == null)
                        {
                            this.Caches[typeof(EPCompanyTreeMember)].RaiseExceptionHandling <EPCompanyTreeMember.userID>(_companyTreeMember, null, new PXSetPropertyException(PX.Objects.EP.Messages.UserDeleted, PXErrorLevel.Warning));
                        }
                        else if (_user.State != Users.state.Active && _user.State != Users.state.Online)
                        {
                            this.Caches[typeof(EPCompanyTreeMember)].RaiseExceptionHandling <EPCompanyTreeMember.userID>(_companyTreeMember, null, new PXSetPropertyException(PX.Objects.EP.Messages.UserIsInactive, PXErrorLevel.Warning));
                        }
                        if (_employeer == null)
                        {
                            this.Caches[typeof(EPEmployee)].RaiseExceptionHandling <EPEmployee.acctCD>(_employeer, null, new PXSetPropertyException(PX.Objects.EP.Messages.EmployeeDeleted, PXErrorLevel.Warning));
                        }

                        else if (_employeer.Status == null)
                        {
                            this.Caches[typeof(EPEmployee)].RaiseExceptionHandling <EPEmployee.acctCD>(_employeer, null, new PXSetPropertyException(PX.Objects.EP.Messages.Employeedeattach, PXErrorLevel.Warning));
                        }

                        else if (_employeer.Status != BAccount.status.Active)
                        {
                            this.Caches[typeof(EPEmployee)].RaiseExceptionHandling <EPEmployee.acctCD>(_employeer, null, new PXSetPropertyException(PX.Objects.EP.Messages.EmployeeIsInactive, PXErrorLevel.Warning));
                        }
                    }
                    yield return(new PXResult <EPCompanyTreeMember, EPEmployee, EPEmployeePosition>(_companyTreeMember, _employeer, _ePEmployeeposision));
                }
            }
        }
        protected virtual IEnumerable members(
            [PXInt]
            int?WorkGroupID)
        {
            this.Members.Cache.AllowInsert = (WorkGroupID != null);
            CurrentSelected.WorkGroupID    = WorkGroupID;
            foreach (PXResult <EPCompanyTreeMember, EPEmployee, EPEmployeePosition, Users> res in PXSelectJoin <EPCompanyTreeMember,
                                                                                                                LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <EPCompanyTreeMember.userID> >,
                                                                                                                          LeftJoin <EPEmployeePosition, On <EPEmployeePosition.employeeID, Equal <EPEmployee.bAccountID>, And <EPEmployeePosition.isActive, Equal <True> > >,
                                                                                                                                    LeftJoin <Users, On <Users.pKID, Equal <EPCompanyTreeMember.userID> > > > >,
                                                                                                                Where <EPCompanyTreeMember.workGroupID, Equal <Required <EPCompanyTreeMember.workGroupID> > > > .Select(this, WorkGroupID))
            {
                EPCompanyTreeMember member = res;
                EPEmployee          emp    = res;
                EPEmployeePosition  pos    = res;
                Users user = res;

                if (string.IsNullOrEmpty(emp.AcctCD))
                {
                    Members.Cache.RaiseExceptionHandling <EPCompanyTreeMember.userID>(member, null, new PXSetPropertyException(PX.Objects.EP.Messages.UserWithoutEmployee, PXErrorLevel.RowWarning, user.Username));
                }
                yield return(new PXResult <EPCompanyTreeMember, EPEmployee, EPEmployeePosition>(member, emp, pos));
            }
        }