Ejemplo n.º 1
0
        public virtual void VerifyBeforeTransaction(string action, string type)
        {
            int  itemsSelectedCount = 0;
            bool canPerformAction   = false;

            if (action == ID.LogActions.START)
            {
                if (type == ID.Type_Log.TRAVEL || type == ID.Type_Log.SERVICE)
                {
                    itemsSelectedCount = StaffMemberLogStartAction.Select().RowCast <FSAppointmentEmployeeFSLogStart>().Where(x => x.Selected == true).Count();
                    canPerformAction   = LogActionFilter.Current.Me == true || itemsSelectedCount > 0;

                    if (type == ID.Type_Log.SERVICE && LogActionFilter.Current.DetLineRef == null)
                    {
                        LogActionFilter.Cache.RaiseExceptionHandling <FSLogActionFilter.detLineRef>(LogActionFilter.Current,
                                                                                                    LogActionFilter.Current.DetLineRef,
                                                                                                    new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix(TX.Error.FIELD_MAY_NOT_BE_EMPTY,
                                                                                                                                                                 PXUIFieldAttribute.GetDisplayName <FSLogActionFilter.detLineRef>(LogActionFilter.Cache))));

                        canPerformAction = false;
                    }
                }
                else if (type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    itemsSelectedCount = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>().Where(x => x.Selected == true).Count();
                    canPerformAction   = itemsSelectedCount > 0;
                }
                else if (type == ID.Type_Log.SERV_BASED_ASSIGMENT)
                {
                    itemsSelectedCount = ServicesLogAction.Select().RowCast <FSDetailFSLogAction>().Where(x => x.Selected == true).Count();
                    canPerformAction   = itemsSelectedCount > 0;
                }
            }
            else if (action == ID.LogActions.COMPLETE)
            {
                if (type == ID.Type_Log.TRAVEL)
                {
                    itemsSelectedCount = LogActionTravelDetails.Select().RowCast <FSLogActionTravelDetail>().Where(x => x.Selected == true).Count();
                }
                else if (type == ID.Type_Log.SERVICE || type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    itemsSelectedCount = LogActionServiceDetails.Select().RowCast <NoTravelLogInProcess>().Where(x => x.Selected == true).Count();
                }

                canPerformAction = itemsSelectedCount > 0;
            }

            if (canPerformAction == false)
            {
                LogActionFilter.Cache.RaiseExceptionHandling <FSLogActionFilter.action>(LogActionFilter.Current,
                                                                                        LogActionFilter.Current.Action,
                                                                                        new PXSetPropertyException(TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED));

                throw new PXRowPersistingException(null, null, TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED);
            }
        }
Ejemplo n.º 2
0
        public virtual void RunLogActionBase(string action, string type, FSAppointmentDet apptDet, PXSelectBase <FSAppointmentLog> logSelect, params object[] logSelectArgs)
        {
            if (action == ID.LogActions.START)
            {
                bool saveDocument = false;

                if (type == ID.Type_Log.TRAVEL)
                {
                    StartTravelAction();
                    saveDocument = LogRecords.Cache.IsDirty == true || AppointmentServiceEmployees.Cache.IsDirty;
                }
                else if (type == ID.Type_Log.SERVICE)
                {
                    StartServiceAction();
                    saveDocument = LogRecords.Cache.IsDirty == true;
                }
                else if (type == ID.Type_Log.NON_STOCK)
                {
                    StartNonStockAction(apptDet);
                    saveDocument = true;
                }
                else if (type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    StartStaffAction();
                    saveDocument = LogRecords.Cache.IsDirty == true || AppointmentServiceEmployees.Cache.IsDirty == true;
                }
                else if (type == ID.Type_Log.SERV_BASED_ASSIGMENT)
                {
                    StartServiceBasedOnAssignmentAction();
                    saveDocument = LogRecords.Cache.IsDirty == true || AppointmentServiceEmployees.Cache.IsDirty == true;
                }

                if (saveDocument == true)
                {
                    this.Actions.PressSave();
                }
            }
            else if (action == ID.LogActions.COMPLETE)
            {
                /***************************************************************/
                // Change this to use logSelect and logSelectArgs

                IEnumerable <ILogDetail> completeLogItems = null;

                if (type == ID.Type_Log.TRAVEL)
                {
                    completeLogItems = LogActionTravelDetails.Select().RowCast <FSLogActionTravelDetail>().Where(_ => _.Selected == true);
                }
                else if (type == ID.Type_Log.SERVICE || type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    completeLogItems = LogActionServiceDetails.Select().RowCast <NoTravelLogInProcess>().Where(_ => _.Selected == true);
                }

                /***************************************************************/

                CompleteAction(apptDet, completeLogItems, LogActionFilter.Current.LogTime, logSelect, logSelectArgs);

                if (type == ID.Type_Log.TRAVEL &&
                    ServiceOrderTypeSelected.Current.OnTravelCompleteStartAppt == true &&
                    (AppointmentRecords.Current?.Status == ID.Status_Appointment.AUTOMATIC_SCHEDULED ||
                     AppointmentRecords.Current?.Status == ID.Status_Appointment.MANUAL_SCHEDULED))
                {
                    startAppointment.PressImpl();
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void UpdateLogActionViews(string type, bool fromStaffTab)
        {
            if (type == ID.Type_Log.TRAVEL)
            {
                if (AppointmentDetails.Current?.IsTravelItem == true)
                {
                    LogActionFilter.Current.DetLineRef = AppointmentDetails.Current.LineRef;
                }
                else
                {
                    LogActionFilter.Current.DetLineRef = SharedFunctions.GetItemLineRef(this, AppointmentRecords.Current.AppointmentID, true);
                }

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    foreach (FSLogActionTravelDetail row in LogActionTravelDetails.Select())
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;

                        if (LogActionTravelDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                        {
                            LogActionTravelDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                        }
                    }
                }
            }
            else if (type == ID.Type_Log.SERVICE)
            {
                LogActionFilter.Current.DetLineRef = AppointmentDetails.Current?.LineType == ID.LineType_ALL.SERVICE ? AppointmentDetails.Current.LineRef : null;

                foreach (NoTravelLogInProcess row in LogActionServiceDetails.Select())
                {
                    if (fromStaffTab == false)
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;
                    }
                    else
                    {
                        row.Selected = row.BAccountID == AppointmentServiceEmployees.Current?.EmployeeID;
                    }

                    if (LogActionServiceDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogActionServiceDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
            else if (type == ID.Type_Log.STAFF_ASSIGMENT)
            {
                FSStaffLogActionDetail row = LogStaffActionDetails.Select()
                                             .RowCast <FSStaffLogActionDetail>()
                                             .Where(_ => _.LineRef == AppointmentServiceEmployees.Current.LineRef)
                                             .FirstOrDefault();

                if (row != null)
                {
                    foreach (FSStaffLogActionDetail selectedRow in LogStaffActionDetails.Select()
                             .RowCast <FSStaffLogActionDetail>()
                             .Where(_ => _.Selected == true))
                    {
                        selectedRow.Selected = false;

                        if (LogStaffActionDetails.Cache.GetStatus(selectedRow) == PXEntryStatus.Notchanged)
                        {
                            LogStaffActionDetails.Cache.SetStatus(selectedRow, PXEntryStatus.Updated);
                        }
                    }

                    row.Selected = row.BAccountID == AppointmentServiceEmployees.Current.EmployeeID;

                    if (LogStaffActionDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogStaffActionDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
        }