protected virtual void PMTimeActivityFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { PXDBDateAndTimeAttribute.SetTimeVisible <EPActivityApprove.date>(Activity.Cache, null, EPsetingst.Current.RequireTimes == true); PMTimeActivityFilter row = (PMTimeActivityFilter)e.Row; if (row != null) { row.BillableTime = 0; row.BillableOvertime = 0; row.BillableTotal = 0; row.RegularTime = 0; row.RegularOvertime = 0; row.RegularTotal = 0; foreach (PXResult <EPActivityApprove, EPEarningType> item in Activity.Select()) { EPActivityApprove rowActivity = (EPActivityApprove)item; EPEarningType rowEarningType = (EPEarningType)item; if (rowEarningType.IsOvertime == true) { row.RegularOvertime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableOvertime += rowActivity.TimeBillable.GetValueOrDefault(0); } else { row.RegularTime += rowActivity.TimeSpent.GetValueOrDefault(0); row.BillableTime += rowActivity.TimeBillable.GetValueOrDefault(0); } row.BillableTotal = row.BillableTime + row.BillableOvertime; row.RegularTotal = row.RegularTime + row.RegularOvertime; } } }
protected virtual void StartDateFieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e) { PMTimeActivityFilter rowFilter = Filter.Current; EPActivityApprove row = (EPActivityApprove)e.Row; if (rowFilter == null || e.NewValue == null) { return; } DateTime?newValue = null; DateTime valFromString; if (e.NewValue is string && DateTime.TryParse((string)e.NewValue, sender.Graph.Culture, System.Globalization.DateTimeStyles.None, out valFromString)) { newValue = valFromString; } if (e.NewValue is DateTime) { newValue = (DateTime)e.NewValue; } if (newValue != null) { int weekId = PXWeekSelector2Attribute.GetWeekID(this, newValue.Value.Date); if (weekId < rowFilter.FromWeek || weekId > rowFilter.TillWeek) { sender.RaiseExceptionHandling <EPActivityApprove.date>(row, e.NewValue, new PXSetPropertyException(Messages.StartDateOutOfRange)); e.Cancel = true; } } }
protected virtual void PMTimeActivityFilter_ProjectTaskID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { PMTimeActivityFilter row = (PMTimeActivityFilter)e.Row; if (row == null) { return; } if (e.NewValue != null && e.NewValue is int) { PMTask task = PXSelect <PMTask> .Search <PMTask.taskID>(sender.Graph, e.NewValue); if (task != null) { if (task.IsCompleted == true) { var ex = new PXSetPropertyException(PM.Messages.ProjectTaskIsCompleted); ex.ErrorValue = task.TaskCD; throw ex; } if (task.IsCancelled == true) { var ex = new PXSetPropertyException(PM.Messages.ProjectTaskIsCanceled); ex.ErrorValue = task.TaskCD; throw ex; } } } }
protected virtual void PMTimeActivityFilter_ProjectID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { PMTimeActivityFilter row = (PMTimeActivityFilter)e.Row; if (row == null) { return; } PMProject proj = PXSelect <PMProject> .Search <PMProject.contractID>(sender.Graph, e.NewValue); if (proj != null) { if (proj.IsCompleted == true) { var ex = new PXSetPropertyException(PM.Messages.ProjectIsCompleted); ex.ErrorValue = proj.ContractCD; throw ex; } if (proj.IsCancelled == true) { var ex = new PXSetPropertyException(PM.Messages.ProjectIsCanceled); ex.ErrorValue = proj.ContractCD; throw ex; } if (proj.Status == Contract.status.Expired) { var ex = new PXSetPropertyException(PM.Messages.ProjectIsSuspended); ex.ErrorValue = proj.ContractCD; throw ex; } } }
protected virtual void PMTimeActivityFilter_TillWeek_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { PMTimeActivityFilter row = (PMTimeActivityFilter)e.Row; if (row != null && e.ExternalCall && row.FromWeek > row.TillWeek) { row.FromWeek = row.TillWeek; } }
protected virtual void EPActivityApprove_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; PMTimeActivityFilter rowFilter = (PMTimeActivityFilter)Filter.Current; if (row == null || rowFilter == null) { return; } if (row.Released == true) { PXUIFieldAttribute.SetEnabled(sender, row, false); PXDBDateAndTimeAttribute.SetTimeEnabled <EPActivityApprove.date>(sender, row, false); PXDBDateAndTimeAttribute.SetDateEnabled <EPActivityApprove.date>(sender, row, false); } else if (row.ApprovalStatus == CR.ActivityStatusListAttribute.Open) { PXUIFieldAttribute.SetEnabled(sender, row, true); PXUIFieldAttribute.SetEnabled <EPActivityApprove.timeBillable>(sender, row); PMProject project = (PMProject)PXSelectorAttribute.Select <EPActivityApprove.projectID>(sender, row); PXUIFieldAttribute.SetEnabled <EPActivityApprove.projectID>(sender, row, rowFilter.ProjectID == null); if (project != null) { PXUIFieldAttribute.SetEnabled <EPActivityApprove.projectTaskID>(sender, row, rowFilter.ProjectTaskID == null && project.BaseType == CT.CTPRType.Project); } else { PXUIFieldAttribute.SetEnabled <EPActivityApprove.projectTaskID>(sender, row, rowFilter.ProjectTaskID == null); } PXDBDateAndTimeAttribute.SetTimeEnabled <EPActivityApprove.date>(sender, row, true); PXDBDateAndTimeAttribute.SetDateEnabled <EPActivityApprove.date>(sender, row, true); PXUIFieldAttribute.SetEnabled <EPActivityApprove.approvalStatus>(sender, row, false); PXUIFieldAttribute.SetEnabled <EPActivityApprove.approverID>(sender, row, false); PXUIFieldAttribute.SetEnabled <EPActivityApprove.timeCardCD>(sender, row, false); } else { PXUIFieldAttribute.SetEnabled(sender, row, false); PXDBDateAndTimeAttribute.SetTimeEnabled <EPActivityApprove.date>(sender, row, false); PXDBDateAndTimeAttribute.SetDateEnabled <EPActivityApprove.date>(sender, row, false); PXUIFieldAttribute.SetEnabled <EPActivityApprove.hold>(sender, row, true); } PXUIFieldAttribute.SetEnabled <EPActivityApprove.approvalStatus>(sender, row, false); PXUIFieldAttribute.SetEnabled <EPActivityApprove.employeeRate>(sender, row, false); if (row.ApprovalStatus == CR.ActivityStatusListAttribute.Rejected) { sender.RaiseExceptionHandling <EPActivityApprove.hold>(row, null, new PXSetPropertyException(Messages.Rejected, PXErrorLevel.RowWarning)); } }
protected virtual IEnumerable activity() { List <object> args = new List <object>(); PMTimeActivityFilter filterRow = Filter.Current; if (filterRow == null) { return(null); } BqlCommand cmd; cmd = BqlCommand.CreateInstance(typeof(Select2 < EPActivityApprove, LeftJoin <EPEarningType, On <EPEarningType.typeCD, Equal <EPActivityApprove.earningTypeID> >, LeftJoin <CRActivityLink, On <CRActivityLink.noteID, Equal <EPActivityApprove.refNoteID> >, LeftJoin <CRCase, On <CRCase.noteID, Equal <CRActivityLink.refNoteID> >, LeftJoin <ContractEx, On <CRCase.contractID, Equal <ContractEx.contractID> > > > > >, Where <EPActivityApprove.ownerID, Equal <Current <PMTimeActivityFilter.ownerID> >, And <EPActivityApprove.trackTime, Equal <True>, And <EPActivityApprove.isCorrected, Equal <False> > > >, OrderBy <Desc <EPActivityApprove.date> > >)); if (filterRow.ProjectID != null) { cmd = cmd.WhereAnd <Where <EPActivityApprove.projectID, Equal <Current <PMTimeActivityFilter.projectID> > > >(); } if (filterRow.ProjectTaskID != null) { cmd = cmd.WhereAnd <Where <EPActivityApprove.projectTaskID, Equal <Current <PMTimeActivityFilter.projectTaskID> > > >(); } if (filterRow.FromWeek != null || filterRow.TillWeek != null) { List <Type> cmdList = new List <Type>(); if (filterRow.IncludeReject == true) { cmdList.Add(typeof(Where <, ,>)); cmdList.Add(typeof(EPActivityApprove.approvalStatus)); cmdList.Add(typeof(Equal <CR.ActivityStatusListAttribute.rejected>)); cmdList.Add(typeof(Or <>)); } if (filterRow.FromWeek != null) { if (filterRow.TillWeek != null) { cmdList.Add(typeof(Where <, ,>)); } else { cmdList.Add(typeof(Where <,>)); } cmdList.Add(typeof(EPActivityApprove.weekID)); cmdList.Add(typeof(GreaterEqual <Required <PMTimeActivityFilter.fromWeek> >)); args.Add(filterRow.FromWeek); if (filterRow.TillWeek != null) { cmdList.Add(typeof(And <>)); } } if (filterRow.TillWeek != null) { cmdList.Add(typeof(Where <EPActivityApprove.weekID, LessEqual <Required <PMTimeActivityFilter.tillWeek> > >)); args.Add(filterRow.TillWeek); } cmd = cmd.WhereAnd(BqlCommand.Compose(cmdList.ToArray())); } PXView view = new PXView(this, false, cmd); return(view.SelectMultiBound(new object[] { Filter.Current }, args.ToArray())); }